GLOBAL array of stations - can it be done?

The place to discuss scripting and game modifications for X²: The Threat.

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

xdfcvg
Posts: 9
Joined: Wed, 14. Jan 04, 02:12
x2

GLOBAL array of stations - can it be done?

Post by xdfcvg »

Hello,

Anyone know how to set up a GLOBAL array. I'm having problems
with my trading scripts bogging things down and was hoping I could
use a global array of all stations that all scripts could access, rather
then having to go through each sector to grab them everytime they
run.

Also, is www.x2scripting.com down? I cannot get through to it.
AalaarDB
Posts: 2282
Joined: Thu, 29. Jan 04, 08:19
x3tc

Post by AalaarDB »

This might not be a new feature, but I saw it right after 1.3 came out. At the bottom of general commands section is set global variable and get global variable, it would be perfect for this.
xdfcvg
Posts: 9
Joined: Wed, 14. Jan 04, 02:12
x2

Post by xdfcvg »

Sounds fantastic, but guess what, I just got the upgrade and
was trying to find my original cd case. This is really stupid, but
I can't find it( had my room renovated last week and it might
have got lost in the shuffle!)

So here is a really dumb question:

Are there 2 cds or just one? (I really can't remember)

I have my cd key and I have the play disc (Disc 1). I would REALLY
like to know I can reinstall if something goes wonky on the upgrade!!
kryptyk
Posts: 483
Joined: Fri, 5. Dec 03, 20:19
x4

Post by kryptyk »

xdfcvg wrote:Sounds fantastic, but guess what, I just got the upgrade and
was trying to find my original cd case. This is really stupid, but
I can't find it( had my room renovated last week and it might
have got lost in the shuffle!)

So here is a really dumb question:

Are there 2 cds or just one? (I really can't remember)

I have my cd key and I have the play disc (Disc 1). I would REALLY
like to know I can reinstall if something goes wonky on the upgrade!!
You need both discs for a reinstall. I hope you find the other one.

BTW xscripting.com is currently being updated and php removed so it might take a while. :wink:
xdfcvg
Posts: 9
Joined: Wed, 14. Jan 04, 02:12
x2

Post by xdfcvg »

Muchos regarde amigo!

I got so excited about the possibilities of the global set/get I went
ahead with the upgrade even though I still have not found my other
cd!. Alas, if I end up having to buy a new copy, it will still be
worth it, this is one of, if not THE (second only to IL2 Forgotten
Battles) most amazing sim I've ever had the pleasure to play.

To my elation the globals work perfectly and have eliminated most of
the nasty pauses I was getting before. However, I still get a pause
after just about every sale. That is when the ship docks to sell its
load at a station the game habitually siezes for about 1 - 3 seconds.
I traced the code but cannot find anything at that point that would
cause it( that is no loops or heavy processing going on - it is just
making the sale ). Bizarrely this never happens on a buy. I can only
guess the script engine is having to do disc I/O on the sale for some
reason, but should that be happening when I have 1 Gig of RAM?. Would
be really nice to get rid of that pause, as it compounds as you get
more and more ships trading.

The other problem I had last night was that after about 15 minutes of
game play it consistently went into an endless loop and I had to
reboot. This could easily be the result of a memory leak that takes
that much time to cause a problem. I had similar problems with my
scripts before and terminating them solved it and I was able to fix
the infinite loop problem. This time however, the problem is clearly
not my scripts, as I was able to run them on SETA from the same point
in the game while on standby and they chugged along famously for
hours. It was only when I was in motion (actually following the plot,
from Mankossek/Paranid Prime going to Nyana'a Hideout), that this
happened.

I tried to use infinite loop detection as well, but that just spewed
out errors showing random lines of code and the ship running the
script. There was one odd 'hidden goto' err message that troubled me.
I myself cannot see any infinite loops in my code so I'm wondering how
effective infinite loop detection really is.

Any advice on this would be appreciated. And please egosoft - give us
some more thorough documentation on the script engine - WE REALLY NEED
IT!!!


- Peace!
stella
Posts: 1004
Joined: Tue, 17. Feb 04, 18:41
x2

Post by stella »

Do the "global" commands render their values to all ships running all commands, or do they effectively, just make them global to the chain of scripts being run for each ship? Ie If I make a variable global, then run the script on 2 ships, will they both retain their own unique values.

Sorry if this isn't very clear, but I've just been viciously assaulted by Mr Stella :roll:
xdfcvg
Posts: 9
Joined: Wed, 14. Jan 04, 02:12
x2

Post by xdfcvg »

I can only explain from a programatic perspective:

- global means only one exists and it is accessible
from all scripts.
- if one script changes the global, all other scripts
will see that change.

ex. if you have a ship update the global array of sectors every time
it finds one you have not been in by adding the new sector to it, then
all other scripts (and ships running those scripts) will see that new
sector from then on.


Anyway here is my update on my previous memory/infinite loop problems.
Since that last post I have enjoyed about 20+ hours of game play with
only 2-3 reboots needed because of infinite loop problems. And the
slowdowns caused on the sale operation are not that noticible now with
30+ ships trading on my scripts. I just bought my first Hydra last
night since I had 14 million in the can, thought I'd splurge. YES!!!

There was however, a very strange problem with one script I was running,
in fact, the very one that was complaining about the hidden goto. I
put an if compare on a station in that script:

if $station == TerraCorp Headquarters(Home of Light)
...
end

This script would NOT SAVE!!?!?!?!! As soon as I reloaded a game the
changes disappeared. Other scripts I changed were fine, just this
one. In fact if I put the above line in another script (the one
calling it) then that script would not save either. Something about
using a hard-coded station name seems to cause this, and I think that
might be because there are TONS of stations (over 1000 with 70+
sectors) and the save mechanism drops the script on the save as a
result.

Any rate - looking forward to those docs;-), but having loads of fun
groping in the quasi-darkness of X2 script land.
easternblocrobotcowboy
Posts: 120
Joined: Sun, 15. Feb 04, 23:21
x2

Post by easternblocrobotcowboy »

I had something odd like that happen in my game last night as I was scripting. I had to edit, save the script, then save the game, and then when I reloaded the saved game it came up with the proper script. Dont know why, its wierd.

what trading scripts are you running?

TW
xdfcvg
Posts: 9
Joined: Wed, 14. Jan 04, 02:12
x2

Post by xdfcvg »

Howdy,


Sorry for the delay in response, just playing X2 too much I guess. :wink:

These are my own trade scripts, that I am fine tuning every time
I play. As I mentioned the save problem only happens with
the hard-coded station, and what you've suggested did not
solve that problem unfortunately.

The other time that scripts disappear is when you happen
to have renamed your script directory (ie. ..\x2\scripts ).
I did this once so I could save the scripts to a unique named dir,
forgot to change the name back to scripts. Spent 2 hours writing
more scripts, only to have them all disappear because they
did not save to disk at all. That was very aggravating! Wish
egosoft had warned me about the fact that I was not saving
to disk! Really was my own fault though.


Anyway, thanks for the info! Happy scripting!

Return to “X²: The Threat - Scripts and Modding”