Saving scripts problem
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 1627
- Joined: Thu, 5. Aug 04, 01:57
Saving scripts problem
Hi all, I'm trying to write my very first script and have come across a little problem...
I wrote 3 lines, just to see if it is going to work, hit ESC, answer YES to save it, run the script and it didn't work...
went back into my script, changed it, hit esc again, saved it and it worked.
Closed down X3, load it again, and my script is back to what it originally was (Not the new alterations)
Am I doing something wrong??
Yes, I am absolutly sure I saved the script the second time.. - Just tried it a 3rd time, saved it, everything was fine, rebooted X3, and I was back to the first mess again...
Can anyone help please??
I wrote 3 lines, just to see if it is going to work, hit ESC, answer YES to save it, run the script and it didn't work...
went back into my script, changed it, hit esc again, saved it and it worked.
Closed down X3, load it again, and my script is back to what it originally was (Not the new alterations)
Am I doing something wrong??
Yes, I am absolutly sure I saved the script the second time.. - Just tried it a 3rd time, saved it, everything was fine, rebooted X3, and I was back to the first mess again...
Can anyone help please??
Link to the list of Mods working in X4-Foundations and also Link to the list of Mods working in X-Rebirth
NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.
NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.
-
- Sith Lord
- Posts: 8255
- Joined: Wed, 6. Nov 02, 20:31
-
- Posts: 1627
- Joined: Thu, 5. Aug 04, 01:57
Basically I was trying to create a mobile HQ - I decided to use the movable pirate base (choose it in the list of ships options in the editor, then I choose Home of light and terracorp as where it was to be at the start (I used the sector map to pinpoint terracorp..)
Will try it again and take a screenie of what I did....
Will try it again and take a screenie of what I did....
Link to the list of Mods working in X4-Foundations and also Link to the list of Mods working in X-Rebirth
NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.
NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.
-
- Posts: 1627
- Joined: Thu, 5. Aug 04, 01:57
Link to the list of Mods working in X4-Foundations and also Link to the list of Mods working in X-Rebirth
NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.
NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.
-
- Posts: 597
- Joined: Tue, 6. Jul 04, 08:48
Like LV said the SE might not like it the way it is.
First do a search for the Terracorp HQ eg:
or something like this, I'm not sure what class or type the TC HQ is.
First do a search for the Terracorp HQ eg:
Code: Select all
$sector = get sector from universe index: x = 1 y = 4
if $sector exist
$Terracorp= find station: sector <$sector> class or type < classtype> race <Argon> flags <null> refobj <null> maxdist <null> maxnum <1> refpos <null>
end
-
- Posts: 1627
- Joined: Thu, 5. Aug 04, 01:57
Thanks for the replies 
Not meaning to sound condesending or anything, but I find it a bit strange that a script editor won't accept its own commands...
Maybe you could tell me how to enter stuff like you just said to, as far as I can see the editor is all menu driven, and there no place to manually enter lines etc...
I thought when I first looked at the editor that this wouldn't be as bad as I thought it would be, I figured I would have to just pick the right bits out of the menus and everything would be fine, but looks like I was wrong....

Not meaning to sound condesending or anything, but I find it a bit strange that a script editor won't accept its own commands...
Maybe you could tell me how to enter stuff like you just said to, as far as I can see the editor is all menu driven, and there no place to manually enter lines etc...
I thought when I first looked at the editor that this wouldn't be as bad as I thought it would be, I figured I would have to just pick the right bits out of the menus and everything would be fine, but looks like I was wrong....
Link to the list of Mods working in X4-Foundations and also Link to the list of Mods working in X-Rebirth
NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.
NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.
-
- Posts: 488
- Joined: Wed, 6. Nov 02, 20:31
When you create a script that works, the SE creates a cached copy of that script which it uses. If you then edit that script and incorporate a fatal error the SE will overwrite your new script with the cached copy, thus the appearance that it has not saved the new script/changes.
In the three lines of code you have written there are a number of errors which are significant and almost certainly would cause major problems to the engine trying to run it.
You need to check:
Can this 'ship' can be docked at that station ? (maybe too big !)
Does the station exist ? (maybe destroyed !)
Does the sector exist ? (maybe running a mod !)
You need to check:
Can the shields go that high ? (get max shield strength first !)
Does the ship exist ? (can't change shields otherwise !)
So, given a few assumtions ie the sector name:
This will either leave the ship in the middle of the sector OR add it to the station, not very pretty but workable.
Not wishing to be condesending either, but you really need to think about object orrientated programming techniques. The shields for example are/can be an object as well as the ship and the station, just like the ship may not fit in the station, the shields may not fit on the ship.
Good Luck, and stick with it 'cos it's very rewarding to see your scripted events taking place in front of you (when it goes right !)
TycHouse
In the three lines of code you have written there are a number of errors which are significant and almost certainly would cause major problems to the engine trying to run it.
Code: Select all
$playership = create ship: type= Mobile Pirate Station owner= Player addto= Terracorp Headquarters(Home of Light) x= 0 y= 0 z= 0
Can this 'ship' can be docked at that station ? (maybe too big !)
Does the station exist ? (maybe destroyed !)
Does the sector exist ? (maybe running a mod !)
Code: Select all
$playership -> set current shield strength to 125
Can the shields go that high ? (get max shield strength first !)
Does the ship exist ? (can't change shields otherwise !)
So, given a few assumtions ie the sector name:
Code: Select all
* assume sector exists
$sector = Home of Light
* only one station sells jumpdrive in Home of Light
$ware = Jumpdrive
$price = get max price of ware Jumpdrive
$station = find station sells: resource $ware with min. jumps: max.price $price, amount= 1, max.jumps= 0, startsector= $sector, trader= null
$playership = create ship: type= Mobile Pirate Station owner= Player addto= $sector x= 0 y= 0 z= 0
if $playership -> exists
$max.shield= get max shield type that can be installed
= $playership -> add 1 units of $max.shield
skip if not $station -> is docking possible of $playership
$playership -> put into environment $station
end
return null
Not wishing to be condesending either, but you really need to think about object orrientated programming techniques. The shields for example are/can be an object as well as the ship and the station, just like the ship may not fit in the station, the shields may not fit on the ship.
Good Luck, and stick with it 'cos it's very rewarding to see your scripted events taking place in front of you (when it goes right !)
TycHouse
AMD FX-8350 Eight-Core 4.0GHz Processor
ASrock Extreme 3 R2.0 Motherboard
8Gb memory
2 x AMD HD7770 Graphics (Crossfire not enabled)
Windows Vista Ultimate 64bit SP2
ASrock Extreme 3 R2.0 Motherboard
8Gb memory
2 x AMD HD7770 Graphics (Crossfire not enabled)
Windows Vista Ultimate 64bit SP2
-
- Posts: 1627
- Joined: Thu, 5. Aug 04, 01:57
Thanks for the reply, much appreciated

This was my first time in the script editor, and I guess it had me fooled, it looked so easy just being able to use the menu commands to create the ship and shields..
What confused me, was when I ran the script, the ship was in terracorp, and it had 8 125mj shields in its shield slots, that is why I couldn't figure out why it wasn't saving..
I will have another go at it tonight using your step by step instructions and see how I go... Thank you for explaining it in an easy to understand way for me


This was my first time in the script editor, and I guess it had me fooled, it looked so easy just being able to use the menu commands to create the ship and shields..
What confused me, was when I ran the script, the ship was in terracorp, and it had 8 125mj shields in its shield slots, that is why I couldn't figure out why it wasn't saving..
I will have another go at it tonight using your step by step instructions and see how I go... Thank you for explaining it in an easy to understand way for me

Link to the list of Mods working in X4-Foundations and also Link to the list of Mods working in X-Rebirth
NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.
NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.
-
- Posts: 2981
- Joined: Mon, 29. Dec 03, 03:29
Yup, any speceific references can be added to a script and run while you're in the game. It will take them because it knows those objects exist.
However, scripts cannot be saved if they have any direct references to universe objects, because what would happen if you tried to load the script in a custom game?
Cheers.
However, scripts cannot be saved if they have any direct references to universe objects, because what would happen if you tried to load the script in a custom game?

Cheers.
"Nature's first green is gold" . . . stay golden.
-
- Posts: 1627
- Joined: Thu, 5. Aug 04, 01:57
Ahhh I get it now..
(checks to see if I got it)
I have to first tell the script to find out if somethig exists in the game it is loading into..
If it does, then it will carry on and load in what I want it to..
If it doesn't then I presume it just doesn't run the rest of the script..
Soo, in my own words to what has been described above.
I can assume that the sector will always be there no matter what game, so I don't have to find that.
I then tell the script to find out if the terracorp station is in that sector, if it is, is it capable of docking the ship I want. etc
Basically, I got to ask the script if I can do something before I try to do it...
Correct??
(checks to see if I got it)
I have to first tell the script to find out if somethig exists in the game it is loading into..
If it does, then it will carry on and load in what I want it to..
If it doesn't then I presume it just doesn't run the rest of the script..
Soo, in my own words to what has been described above.
I can assume that the sector will always be there no matter what game, so I don't have to find that.
I then tell the script to find out if the terracorp station is in that sector, if it is, is it capable of docking the ship I want. etc
Basically, I got to ask the script if I can do something before I try to do it...

Correct??
Link to the list of Mods working in X4-Foundations and also Link to the list of Mods working in X-Rebirth
NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.
NOTE: I play with a modded game, so any reports I make outlining suggestions/problems/bugs/annoyances, are made with mods installed and running.
-
- Posts: 3461
- Joined: Fri, 4. Feb 05, 13:44
NZ-Wanderer wrote:I can assume that the sector will always be there no matter what game, so I don't have to find that.
I then tell the script to find out if the terracorp station is in that sector, if it is, is it capable of docking the ship I want. etc
Basically, I got to ask the script if I can do something before I try to do it...
Correct??
you basicly cant assume a single thing when it comes to scripting
(well you can .. but that also means it can be buggy)
when spawning you can find a random sector or use a fixed sector but always check if the sector actually exists .. spawning ships in an non-existing sector is something you really dont want ..
a simple make sure I've got an existing sector check could/would be ..
Code: Select all
$sector == Home off Light
$ref.sector == [PLAYERSHIP] get sector
*now you can do 2 things .. use the player-sector or .. check if Hol exists else find a random sector
while not $sector exists
*note that it will skip the entire loop if Hol does exist .. cause it will only do this 'while there is no existing sector' ..
$sector -> get random sector startsector; $ref.sector max. jumps; 100
end
and when HoL exists it will use it else it will search on for a random sector ..
G
-
- Posts: 508
- Joined: Sat, 10. Jan 04, 09:07
Any specific reference to an object in a sector will cause the SE to fail to save your script. I had the same problem, and it took me a few tries to figure that out.
I did not check the below code, but it should work for you. Note that it adds it to the sector, not to the station (Terracorp Headquarters).
If you specifically want a 125MJ shield, change the last 2 lines to read:
I did not check the below code, but it should work for you. Note that it adds it to the sector, not to the station (Terracorp Headquarters).
Code: Select all
$sector == Home of Light
$playership = create ship: type= Mobile Pirate Station owner= Player addto= $sector x= 0 y= 0 z= 0
$max.shield= get max shield type that can be installed
= $playership -> add 1 units of $max.shield
Code: Select all
$playership -> add default items to ship
= $sc -> install 1 unit of 125MJ shield
-
- Posts: 2981
- Joined: Mon, 29. Dec 03, 03:29
To be honest, I'm not sure if that will work correctly.
You can't reference the sector by name either.
It may work, because instead of storing 'Home of Light' it's actually storing 'the sector located 1 over and 5 down from the top left of the universe', but this is a bad way to code. It may not work either, I was kind of taking a guess in my last sentence.
What happens if someone loads your script in a custom universe?
You honestly shouldn't reference any object, whether it's a sector, station, ship, or whatever by direct name.
Cheers.
You can't reference the sector by name either.
It may work, because instead of storing 'Home of Light' it's actually storing 'the sector located 1 over and 5 down from the top left of the universe', but this is a bad way to code. It may not work either, I was kind of taking a guess in my last sentence.
What happens if someone loads your script in a custom universe?
You honestly shouldn't reference any object, whether it's a sector, station, ship, or whatever by direct name.
Cheers.
"Nature's first green is gold" . . . stay golden.