EnglishGermanFrenchRussianItalianSpanish
Log inRegister
 
[LIB] Find Hub of station
Post new topic Reply to topic Goto page 1, 2  Next
View previous topic :: View next topic
Author Message
s9ilent





Joined: 29 Jun 2005
Posts: 2009 on topic
Location: Galactic Sector ZZ9-Plural Z alpha +10 GMT
Thank you for registering your game
modified
PostPosted: Mon, 26. Jan 09, 10:23    Post subject: [LIB] Find Hub of station Reply with quote Print

A basic lib pack for telling if a station is in a hub (true/false?), and what hub a station is in.



stat_hub_check
Hub/Station Checks

stat_hub_check.zip


2 Scripts
lib.stat.findhub
-NO args. Finds the hub that the THIS (station,factory) is attached to. Returns the Hub. Otherwise if there is no hub, then it returns null.

lib.stat.hubsinsect
-1 Arg: sector. Returns an array of all the hubs in a sector, or zero if there aren't any.



As a note, Garbage in garbage out. These are low level lib scripts so there are no error checks
Make sure THIS, is indeed a station.








***old junk below here****
This script doesn't seem that fantastic.. but .. it used to be super complex as I had no idea how to do it and I did some wierd round about way of doing it. But then Gazz is like: Use this command. bang done. So yep.. just the one script now...

*Final note, I removed the , checkinhub
Simply because its a one liner

if not $station docking is possible $smallship (a small ship, or m6 ship, not an object class, but an actual object)
is a station in a hub (not the hub it self thou)
else
is not
endif

The small ship has to be able to land on a station in the first place. And getting a small ship via generic searches are probably as CPU consuming as the findhub command. (The former loops through all sector ships in X3 till it finds a match, the other loops through all stations until it finds a match)



Last edited by s9ilent on Mon, 4. May 09, 03:22; edited 8 times in total
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Gazz





Joined: 13 Jan 2006
Posts: 12407 on topic
Location: Bavaria
Thank you for registering your game
modified
PostPosted: Mon, 26. Jan 09, 12:18    Post subject: Re: [LIB] Hub/Station Checks Reply with quote Print

s9ilent wrote:
If it can't find a match (i.e. Its not in a hub) it returns null. The other script is more efficient (I think.... is the search command efficient?) for checking if a station is in a hub or not

If you want to make certain a station is a hub use

= get station array from sector $Hub

If you get results it's a real active hub and then you also get the stations it contains.
Scripts can create a hub without a complex (for whatever reason) so the above way is the only one to make sure.


_________________
My complete script download page. . . . . . Xai-Corp MSCI List is scripter's friend. I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.


Last edited by Gazz on Mon, 26. Jan 09, 12:21; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
s9ilent





Joined: 29 Jun 2005
Posts: 2009 on topic
Location: Galactic Sector ZZ9-Plural Z alpha +10 GMT
Thank you for registering your game
modified
PostPosted: Mon, 26. Jan 09, 12:20    Post subject: Reply with quote Print

Gazz Sad I wish I knew that.. like 3 days ago....

*edit*
Wait Gazz, I just tried it, it returns null when I use it on a hub?

Wait.. it works.. just not as I expected.. or.. well strangely.. Ill test it out properlly



Last edited by s9ilent on Mon, 26. Jan 09, 12:27; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Logain Abler





Joined: 31 Oct 2005
Posts: 2253 on topic
Location: Norwich, UK
Thank you for registering your game
PostPosted: Mon, 26. Jan 09, 12:26    Post subject: Re: [LIB] Hub/Station Checks Reply with quote Print

s9ilent wrote:
A basic lib pack for telling if a station is in a hub (true/false?), and what hub a station is in.



stat_hub_check
Hub/Station Checks

stat_hub_check.zip


4 Scripts

  • lib.stat.checkinhub.findsmall -No args. Returns a small ship (required for checkinhub), just any small ship from the entire universe owned by anyone
  • lib.stat.checkinhub -Arg1: a smallship (Any one's any where, use the above if you can't get one). Run on the station your enquiring about. Returns TRUE if THIS is in a hub, returns FALSE if it isn't
  • lib.stat.findhub -NO args. Finds the hub that the THIS (station,factory) is attached to. Returns the station, if multiple matches, returns an array of stations, if no matches, returns null
  • lib.stat.findhub.single -Same as above, but will return the first result, or null (not an array if 2+ results)



As a note, Garbage in garbage out. These are low level lib scripts so there are no error checkers.
N.B. If I say small ships, I actually mean obj class "littleships"
N.B. Complex Hubs are considered to be obj class Complex Hubs, which is a subset of Factories

1. The first script can only fail if there are no flying smallships in the universe. Failure return = null.
(At least I think flying ships don't show up on generic ship searches.. I Could be wrong thou)

2. The second script, make sure that the smallship does exist, and is indeed a small ship, and that THIS is a valid station (factory).
It works by checking if $smallship can dock at THIS. (If not, is hub)
So obviously complex hubs, docks, shipyards, carriers etc. will return false.
If THIS is a ship or something undockable, it will return true. Garbage in Garbage out

3. The third script, make sure THIS is a valid station (factory), and is actually in a hub (other wise ret = null, the other script is better for checking thou.. I think at least.. I have no idea how Egosoft's ship search works).
This script works by checking the current ware quantity and the max quantity of all hubs in THIS's sector, against THIS's current and max quantities.
It can be fooled if you have 2 identical complexes, in which case it will return an array containing both.
If it can't find a match (i.e. Its not in a hub) it returns null. The other script is more efficient (I think.... is the search command efficient?) for checking if a station is in a hub or not


Sounds interesting will have a look.

I hit this issue in my FDN mod/script.

I solved it as follows.

1) Check the is detectable settings as this changes if the factory is part of the Hub
2) Check the Product and level of the factory to see if it’s the same as the Hub. Both Hub & Factory will return the same value on the level of a ware.
3) Check distance of between Hub & Factory.

The above is what I use to group Factories under Complexes as below:



Was a complete bitch to get right! Strange there’s no inbuilt script command to do it.


LA


_________________
Freight Distribution Network|Strategic Sector Defence Network|Production Modules|Capital Ship Energy Cell Generator
Back to top
View user's profile Send private message Send e-mail
s9ilent





Joined: 29 Jun 2005
Posts: 2009 on topic
Location: Galactic Sector ZZ9-Plural Z alpha +10 GMT
Thank you for registering your game
modified
PostPosted: Mon, 26. Jan 09, 12:31    Post subject: Reply with quote Print

I don't like distance checking as you can build them upto 35km away (i think.. a long way a way any way) and if you make 2 hubs and connect those, and then those 2 hubs are 35km away, then you can effective get 75km, and so on and so forth

(I linked up all the high yield roids in Ore belt like that... lagged like... well alot thou.. all those pipes... and I think I lost a few hubs to collisions (with the M2 or the roids.. I can't remember)

*Edit* Gazz's way doesn't work, it just returns null




GAH!!!!


Gazz was half right


Get FACTORY array from sector

Does work like a charm <3



Last edited by s9ilent on Mon, 26. Jan 09, 12:38; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Logain Abler





Joined: 31 Oct 2005
Posts: 2253 on topic
Location: Norwich, UK
Thank you for registering your game
PostPosted: Mon, 26. Jan 09, 12:35    Post subject: Re: [LIB] Hub/Station Checks Reply with quote Print

Gazz wrote:
s9ilent wrote:
If it can't find a match (i.e. Its not in a hub) it returns null. The other script is more efficient (I think.... is the search command efficient?) for checking if a station is in a hub or not

If you want to make certain a station is a hub use

= get station array from sector $Hub



It does not work, it returns null Sad

I've tried that in X3:R and TX:TC and I've never been able to get it to work.


LA


_________________
Freight Distribution Network|Strategic Sector Defence Network|Production Modules|Capital Ship Energy Cell Generator
Back to top
View user's profile Send private message Send e-mail
s9ilent





Joined: 29 Jun 2005
Posts: 2009 on topic
Location: Galactic Sector ZZ9-Plural Z alpha +10 GMT
Thank you for registering your game
PostPosted: Mon, 26. Jan 09, 12:39    Post subject: Reply with quote Print

(JUst in case you didn't see my edit to the above post -i edited it like... 7 times??? so it might've changed a bit)

<retvar> = <value i.e the hub your checking> Get factory array from sector


It only works with the factory one, not the sector one.

Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Logain Abler





Joined: 31 Oct 2005
Posts: 2253 on topic
Location: Norwich, UK
Thank you for registering your game
PostPosted: Mon, 26. Jan 09, 12:41    Post subject: Reply with quote Print

s9ilent wrote:
I dont like distance checking as you can build them upto 35km away (i think.. a long way a way any way) and if you make 2 hubs, and then those 2 hubs are 35km away, then you can effective get 75km, and so on and so forth


I've set the distance to something really stupid, like 1000000. Not even sure if it's needed, just that it works Wink

I could send you the file if your interested, it's not pretty but it's always good to get another view Question

s9ilent wrote:

*Edit* Gazz's way doesn't work, it just returns null


Beat me to it Smile


LA


_________________
Freight Distribution Network|Strategic Sector Defence Network|Production Modules|Capital Ship Energy Cell Generator
Back to top
View user's profile Send private message Send e-mail
Logain Abler





Joined: 31 Oct 2005
Posts: 2253 on topic
Location: Norwich, UK
Thank you for registering your game
PostPosted: Mon, 26. Jan 09, 12:49    Post subject: Reply with quote Print

s9ilent wrote:
(JUst in case you didn't see my edit to the above post -i edited it like... 7 times??? so it might've changed a bit)

<retvar> = <value i.e the hub your checking> Get factory array from sector


It only works with the factory one, not the sector one.


D'oh Exclamation Now I get it Idea


_________________
Freight Distribution Network|Strategic Sector Defence Network|Production Modules|Capital Ship Energy Cell Generator
Back to top
View user's profile Send private message Send e-mail
Gazz





Joined: 13 Jan 2006
Posts: 12407 on topic
Location: Bavaria
Thank you for registering your game
PostPosted: Mon, 26. Jan 09, 12:52    Post subject: Reply with quote Print

s9ilent wrote:
Gazz was half right
Get FACTORY array from sector
Does work like a charm <3

Uhh, err... just keeping you on your toes y'know!


_________________
My complete script download page. . . . . . Xai-Corp MSCI List is scripter's friend. I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
Back to top
View user's profile Send private message Visit poster's website
s9ilent





Joined: 29 Jun 2005
Posts: 2009 on topic
Location: Galactic Sector ZZ9-Plural Z alpha +10 GMT
Thank you for registering your game
PostPosted: Mon, 26. Jan 09, 12:55    Post subject: Reply with quote Print

<3 Gazz

Although... I needed this script like 5 days ago... and it's taken me this long to figure it out.. I don't actually remember what I needed it for any more Oops
(Well... 5 days to figure it out sort of right.. and then for Gazz to tell us the answer)

Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Logain Abler





Joined: 31 Oct 2005
Posts: 2253 on topic
Location: Norwich, UK
Thank you for registering your game
PostPosted: Mon, 26. Jan 09, 13:03    Post subject: Reply with quote Print

s9ilent wrote:
<3 Gazz

Although... I needed this script like 5 days ago... and it's taken me this long to figure it out.. I don't actually remember what I needed it for any more Oops
(Well... 5 days to figure it out sort of right.. and then for Gazz to tell us the answer)


I know, I lost could of the hours I spent on this. Now I'll be able to cut the code down by about 80 lines Exclamation

Laughing Cheers Gazz


_________________
Freight Distribution Network|Strategic Sector Defence Network|Production Modules|Capital Ship Energy Cell Generator
Back to top
View user's profile Send private message Send e-mail
Gazz





Joined: 13 Jan 2006
Posts: 12407 on topic
Location: Bavaria
Thank you for registering your game
PostPosted: Mon, 26. Jan 09, 13:12    Post subject: Re: [LIB] Find Hub of station Reply with quote Print

s9ilent wrote:
*Final note, I removed the , checkinhub
Simply because its a one liner
if not $station docking is possible $smallship (a small ship, or m6 ship, not an object class, but an actual object)
is a station in a hub (not the hub it self thou)

Well.... if you use if docking allowed it works independant of ship class or free docking slots so you can always reference PLAYERSHIP and don't need to find a ship first.
if docking possible returns a diffuse result.

So if docking allowed directly tells you if the station is in any complex or not.

Okay, with AI stations it has notoriety/relation implications but not for your purposes...


_________________
My complete script download page. . . . . . Xai-Corp MSCI List is scripter's friend. I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
Back to top
View user's profile Send private message Visit poster's website
s9ilent





Joined: 29 Jun 2005
Posts: 2009 on topic
Location: Galactic Sector ZZ9-Plural Z alpha +10 GMT
Thank you for registering your game
PostPosted: Mon, 26. Jan 09, 13:30    Post subject: Reply with quote Print

The ship has to be a small ship/m6 (not big ship)

Pretty much, a station in a hub, can not be docked at (But big ships already can't dock at them so it give null)

Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Gazz





Joined: 13 Jan 2006
Posts: 12407 on topic
Location: Bavaria
Thank you for registering your game
PostPosted: Mon, 26. Jan 09, 14:09    Post subject: Reply with quote Print

s9ilent wrote:
The ship has to be a small ship/m6 (not big ship)

Pretty much, a station in a hub, can not be docked at (But big ships already can't dock at them so it give null)

If all docking clamps are all full then docking possible returns null for any ship.
What did you do in case number of free docking bays == 0 ?


Anyway, if I may be so bold as to sug... ahwell. I'll do it anyway!
Some useful possible features:

One script argument.

1) If it's object_ class_sector, the return is null or an array of all active hubs in the sector.
Always null or an array, even if it's only 1 hub.
A find may not guarantee that you get them all and that they are actual hubs but mostly this is a good start for the other functions:

2) If the argument is a vartype_array (sector position) the return is null or the hub closest to this position in the sector.
(for extra trickiness the library can call itself with option 1) to get the hubs in sector first)

3) If the argument is object_ class_factory the return is null or the "master" hub of this factory
(for extra trickiness the library can call itself with option 1) to get the hubs in sector first. That's what libraries are for! =)


Checking if a particular station is a hub or if a particular factory is in a complex are pretty much one liners so no need for a library there.

Using THIS as the argument may sound good but will often be undesirable because you have to start the task on that object and that implies that you have found a free task to run it on.
If you connect a factory to a complex all running scripts on it are killed which further complicates this.
Save yourself the headaches and supply THIS as an argument when apropriate.


_________________
My complete script download page. . . . . . Xai-Corp MSCI List is scripter's friend. I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic Reply to topic Goto page 1, 2  Next
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Control Panel
Login Data
The time now is Mon, 11. Dec 17, 13:36

All times are GMT + 2 Hours


Board Security

Copyright © EGOSOFT 1989-2017
Powered by phpBB © 2001, 2005 phpBB Group
Template created by Avatar & BurnIt!
Debug: page generation = 0.12893 seconds, sql queries = 29