[SCRIPT]Station Freight Transporter v2.1.2 - 06/05/07

The place to discuss scripting and game modifications for X³: Reunion.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

Post Reply

How is this script

Excellent
4
57%
Good
2
29%
OK
0
No votes
Not good
1
14%
Rubbish
0
No votes
 
Total votes: 7

Heretic666
Posts: 461
Joined: Fri, 20. Feb 04, 18:30
x3tc

[SCRIPT]Station Freight Transporter v2.1.2 - 06/05/07

Post by Heretic666 » Sun, 22. Apr 07, 23:56

Station Freight Transporter V2.1.2
-------------------------------------

When activated from your trade station's command menu, this script will transfer products from player owned stations to other player owned stations in the sector that requires them as a resource. There is a 100,000cr activation fee every time the script is activated, as well as an additional fee for every unit of product transferred.


To use:
--------
Only available on Trading Stations, Equipment Docks and the PHQ
First ensure the trade station has a (recommended) minimum of 1,000,000 cr, then select 'Station Commands>SFS'
You will be asked 2 questions. The first is to determine the maximum range the station should transport goods from/to, so if you only want stations within your small loop to transfer between themselves and not transfer to your other stations in the sector, type something small like 10-15 (distances in Km). If you want your stations to transfer between all of your other stations in the sector, type a suitably large number, eg. 1000 to encompass the whole sector.
The second is how many goods the station should retain, in %, either for trading with free traders or for stockpiling purposes.

*Note* The charge for transferring products is now 5% of the wares average price (1cr min) * (distance from sending station). This means that although you set the max range to 1000 to encompass the whole sector, if the station is only 50Km away the cost per unit transferred will be (5% * 50).

*Note 2* Although I am working on a way to be able to change the values without being charged, I have so far been unable to to so :( this means you will have to restart the script (and therefore pay another 100,000cr) but I'll keep looking into it for the next release :)


The script transfers every 5 seconds (so it shouldn't massively slow down with lots of stations), if you want to change it the wait time is in 'HI.StationFreightTransporter' on line 1.


Link to my script:
http://www.xai-corp.net/en/files/xaicor ... V2.1.2.spk


Changelog:
-------------
2.1.2
Added a list of stations in range to the incomming message.

2.1.1
Working release.

2.1BETA
Further code refinements, only released so I could get help fixing a few little bugs

2.0BETA
Major update, command now only available on trade docks/PHQ
Arguement added for % ware to be retained
Pricing now 5% * dist per unit transferred, only charged for goods going from producing station to trade dock
Small code refinements
**Didn't work as planned, note the BETA**

1.2.1
Small update, now the command is visible when running from the station command menu.

1.2
Added a distance arguement to set the max distance for transfer,
Changed the pricing from 1cr/unit to 1%/unit * dist

1.1
A few code updates,
Small alterations to the text file,
No longer BETA

1.0
Initial BETA release


Possible Additions:
:arrow: Add support for hubs and therefore multiple product wares. [Should be ok now..]
:arrow: Question to allow player to change Max distance and Stored % without having to pay again


Thanks and look forward to your replies :)

-------------------------------------------
Resources Used
-------------------
Text file: 7666
Command slot: COMMAND_TYPE_STATION_40

Special thanks:
------------------
Tomcat: he began this script, I'm just changing it a bit. Original script here: http://forum.egosoft.com/viewtopic.php?t=125074
B-O'F: For help with the code when I made stupid mistakes :P and basically writing the script for me...ahem
Last edited by Heretic666 on Sun, 6. May 07, 16:39, edited 14 times in total.

B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

Post by B-O'F » Mon, 23. Apr 07, 00:38

Hi Heretic666,

Just had a quick look through your script, and I think I have spotted the reasons for your problems:-

Line 29 needs a few things:-
Set 'Asked' to null, as is still set from earlier (lines 12-20)

Need to re-check $StationMoney - you have only checked it before taking anything out - it has not been updated.

Also need to re-check $FactoryArraySize, as you decrement it in line 41, and is currently zero - so will do nothing after the first run through.

I would suggest that you re-get the Factory Array to allow for new stations being added

Also need lines 31 to 37 in a loop to await reply - as in lines 12-20


I am not saying that these are your only errors - I only had a quick look to try and spot your listed problems.

See what happens after these changes,

Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

Heretic666
Posts: 461
Joined: Fri, 20. Feb 04, 18:30
x3tc

Post by Heretic666 » Mon, 23. Apr 07, 01:57

Yeah I thought it would be something small and stupid, I've implemented the changes you suggested and it seems to be working fine, I'll be leaving it on overnight to try and fill an energy loop, I'll see what happens and if it works post an updated version.

One small thing:

Code: Select all

037   while $StationMoney == 0
038    $Var1 = [THIS] -> get local variable: name='Asked'
039    if not $Var1
040     [THIS] -> set local variable: name='Asked' value=[TRUE]
041     $Msg3 = sprintf: pageid=7666 textid=3, $StationName, $StationSec, null, null, null
042     send incoming message $Msg3 to player: display it=[TRUE]
043    end
044 @  = wait 10 ms
045   end
This part is supposed to loop while the station has no money, but continue when the station has money again. However it seems only to send the message telling the player there is no money, it doesn't seem to carry on after money is added to the station. Any ideas why?

[EDIT] I should say that the variable 'Asked' has already been set to null before this point (thanks for that do'h!)

B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

Post by B-O'F » Mon, 23. Apr 07, 11:40

Hi Heretic666,

Glad I could hep with your questions, most scripting errors are of the 'small and stupid' type - I know, we all make them at some time or other.

As to your current problem - same type....

Look at your loop - it is While money == 0... where do you check the money ? Before the loop starts.. you need to re-check the money - I suggest at line 44, before the wait.

'Asked' is just to stop spamming the message - it has nothing to do with the money.....

Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

Heretic666
Posts: 461
Joined: Fri, 20. Feb 04, 18:30
x3tc

Post by Heretic666 » Mon, 23. Apr 07, 13:12

lol :P

sorted now heh


UPDATED TO V1.1
See first post.
Last edited by Heretic666 on Wed, 25. Apr 07, 18:55, edited 1 time in total.

B-O'F
Posts: 719
Joined: Sat, 21. Feb 04, 03:15
x3tc

Post by B-O'F » Mon, 23. Apr 07, 13:23

Hi Heretic666,

Glad to hear that you are now sorted out.

For hosting, have a look at Xai Corporation - it is run by Moggy2.. you can PM him to get the details (see his sig.) This is an interesting site, lots of good info, and - most importantly - most of my scripts... and lots of good scripts as well. (you can read this last sentence any way you wish).

Enjoy, and learn,

Boron - Ol Fh'art
Public Service announcement

Growing old is not a disease - it is a delayed symptom of birth trauma.

Heretic666
Posts: 461
Joined: Fri, 20. Feb 04, 18:30
x3tc

Post by Heretic666 » Mon, 23. Apr 07, 18:11

Changed the download link, thanks to moggy2 and Xai Corp for that :)
Station Freight Transporter
B-O'F: Enjoy whatever you are doing, if you decide to try real scripting one day..

Heretic666
Posts: 461
Joined: Fri, 20. Feb 04, 18:30
x3tc

Post by Heretic666 » Wed, 25. Apr 07, 18:55

UPDATED TO V1.2
See first post for link.

Changes:
Added a distance arguement to set the max distance for transfer,
Changed the pricing from 1cr/unit to 1%/unit * dist
Station Freight Transporter
B-O'F: Enjoy whatever you are doing, if you decide to try real scripting one day..

Schabernack
Posts: 215
Joined: Wed, 18. Apr 07, 19:32

Post by Schabernack » Thu, 26. Apr 07, 19:58

Only the resources of a station or their products, too?

Is it possible to transfer multiple wares from one station to another?

Is it possible to transfer from a hub to a hq?


solong
learn from the past, live the moment, dream of the future
tc-ap minimax

Heretic666
Posts: 461
Joined: Fri, 20. Feb 04, 18:30
x3tc

Post by Heretic666 » Thu, 26. Apr 07, 20:29

Schabernack wrote:Only the resources of a station or their products, too?

Is it possible to transfer multiple wares from one station to another?

Is it possible to transfer from a hub to a hq?


solong
1 :arrow: It transfers the product of the station you activate it on to any other station within range that uses that product.

eg. If you activate it on an SPP, it will transfer energy cells to every station that uses them within range.


2 :arrow: Not as yet, but I'll put it onto the 'todo' list


3 :arrow: Not looked into that, but once I put your other idea into it I'll test it out, cant see why it wouldn't though..
Station Freight Transporter
B-O'F: Enjoy whatever you are doing, if you decide to try real scripting one day..

Schabernack
Posts: 215
Joined: Wed, 18. Apr 07, 19:32

Post by Schabernack » Fri, 27. Apr 07, 13:46

nevertheless it sounds good to me, another workarround for complexbuilding,
you don't need the tubes, you dont need to extract them with the tubeles complex mod. So if this script is not too processor intensiv it should spare performance. Thx&solong
learn from the past, live the moment, dream of the future
tc-ap minimax

Heretic666
Posts: 461
Joined: Fri, 20. Feb 04, 18:30
x3tc

Post by Heretic666 » Sat, 28. Apr 07, 11:53

Whoever put 'not good' on the poll...why? Tell me what you thought so I can look at it.
Station Freight Transporter
B-O'F: Enjoy whatever you are doing, if you decide to try real scripting one day..

Heretic666
Posts: 461
Joined: Fri, 20. Feb 04, 18:30
x3tc

Post by Heretic666 » Sat, 5. May 07, 08:23

UPDATED TO V2.1.1
See first post for link.

Changes:

2.1.1
Working release.

2.1BETA
Further code refinements, only released so I could get help fixing a few little bugs

2.0BETA
Major update, command now only available on trade docks/PHQ
Arguement added for % ware to be retained
Pricing now 5% * dist per unit transferred, only charged for goods going from producing station to trade dock
Small code refinements
**Didn't work as planned, note the BETA**

1.2.1
Small update, now the command is visible when running from the station command menu.
Station Freight Transporter
B-O'F: Enjoy whatever you are doing, if you decide to try real scripting one day..

Heretic666
Posts: 461
Joined: Fri, 20. Feb 04, 18:30
x3tc

Post by Heretic666 » Sun, 6. May 07, 16:41

UPDATED TO V2.1.2
See first post for link.

Changes:

Added a list of stations in range to the incomming message


On this point:
*Note 2* Although I am working on a way to be able to change the values without being charged, I have so far been unable to to so :( this means you will have to restart the script (and therefore pay another 100,000cr) but I'll keep looking into it for the next release :)
the script files are all there, 'HI.SFTQuestion' is the response script for the question, if someone could have a look at it and see if you can find any problems with it.. 'HI.StationFreightTransporter' has the actual question, just do the following:
Line 64: uncomment
Line 81: uncomment
Line 82: comment

Then re-init scripts and run the command, you will get a question instead of a message, press no and the script will end with no charge, press yes however, no charge still (although it should) and after the random wait, you will be bombarded by incomming questions telling you to the effect 'Unknown Station in sector null has insufficient funds...'
That message is from 'HI.TransportToTradeStation', but if you look at it, it is set up so it should only be sent once. If anyone can see the problem, let me know please :)
Last edited by Heretic666 on Mon, 7. May 07, 00:18, edited 2 times in total.
Station Freight Transporter
B-O'F: Enjoy whatever you are doing, if you decide to try real scripting one day..

Heretic666
Posts: 461
Joined: Fri, 20. Feb 04, 18:30
x3tc

Post by Heretic666 » Sun, 6. May 07, 23:45

Anyone that downloaded the updated script before now will have to d/l it again, I missed a file out...sorry :oops:
Station Freight Transporter
B-O'F: Enjoy whatever you are doing, if you decide to try real scripting one day..

Post Reply

Return to “X³: Reunion - Scripts and Modding”