[looking for] Script to collect/destroy unwanted satellites
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
[looking for] Script to collect/destroy unwanted satellites
Exactly what it says: I' trying to find, or get some tips on how to make, a script to destroy, or send a ship to collect all satellites with a certain name. I've tried to script it myself, but never managed to get it to work correctly. There's far too many to do one at a time, but I'm not sure how to get loops to work correctly with the script editor.
Hmm, those still don't eliminate the need to select each satellite one by one to collect them. So, by a scriping method, I've tried adding all my satellites to an array (which works), but from there, I cannot for the life of me figure out a way to reference each object in the array to match it's name against a template. The "Find <var> in <array>" doesn't seem to work the way I expected it to. I guess I'm just used to a different language, but basically I want to do something like;
for(var/ship/satellite/Sat in player.ships)
>if(Sat.name=="Your Advanced Satellite")
>>Del(Sat)
>>Player.credits+=13476 //value of Adv.satellite
>else
>>continue
Or, make a list of all the satellites I own, check if they are named "Your Advanced Satellite", and if they are, destroy them and pay for them as if I sold them.
How would I go about doing that in the script editor?
for(var/ship/satellite/Sat in player.ships)
>if(Sat.name=="Your Advanced Satellite")
>>Del(Sat)
>>Player.credits+=13476 //value of Adv.satellite
>else
>>continue
Or, make a list of all the satellites I own, check if they are named "Your Advanced Satellite", and if they are, destroy them and pay for them as if I sold them.
How would I go about doing that in the script editor?
- X2-Illuminatus
- Moderator (Deutsch)
- Posts: 24965
- Joined: Sun, 2. Apr 06, 16:38
Braekyn wrote:for(var/ship/satellite/Sat in player.ships)
>if(Sat.name=="Your Advanced Satellite")
>>Del(Sat)
>>Player.credits+=13476 //value of Adv.satellite
>else
>>continue
This way:Braekyn wrote:How would I go about doing that in the script editor?
Code: Select all
001 $satellite.arr = get ship array: of race Player class/type=Advanced Satellite
002 $size.satellite.arr = size of array $satellite.arr
003 while $size.satellite.arr
004 |dec $size.satellite.arr =
005 |$satellite = $satellite.arr[$size.satellite.arr]
006 |$satellite.name = $satellite -> get name
007 |if $satellite.name == 'Your Advanced Satellite'
008 ||$satellite ->destruct: show no explosion=[TRUE]
009 ||add money to player: 13476
010 |end
011 @ |= wait 1 ms
012 end
013 return null
Some general notes: In the Script Editor there are only while-loops. To reference an object within an array you have to get that object from the array first. The "Find <var> in <array>" command just gives you the information, whether a certain value is stored within that array. That means, if the array contains ships, you can check, if a certain ship is stored in that array. Again, to reference an object and check its properties you would have to get that object from the array first.
Of course the name check (lines 6, 7 and 10) could be removed from my example above, if you want to destroy all of your advanced satellites.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten
Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)
Neuauflage der fünf X-Romane als Taschenbuch
The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!
Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)
Neuauflage der fünf X-Romane als Taschenbuch
The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!