Arrays scripting tutorial (Page 5 of 5)
Written by Roguey,Something wrong?
We now need to run our script Count.Ships, by pressing r then enter twice on the list of scripts. You should see something like this:Your answer maybe slightly different.. but you probably notice an error with our sum. Because the ships are worth so much, we have over-flowed the variable cost maximum number. So what can we do to fix this? Well... its relatively easy to fix. Instead of adding each credit to cost, lets try dividing the value by 1,000. So our answer is in 1000's (ie. K's).
Now go back into our script Count.Ships and insert a new line at line 9. Now press enter and head to General Commands, then select <RetVar/IF><Expression> When ask for script input, put ship.cost (under Available Variables). Now set <?> to ship.cost (once again under Available Variables). Now move to the 3 dots and press enter. This time we want the / operator (its near mod). Now back to our script, press enter and find <Number> and type in 1000
Now lets update line 13, as our answer will be in k's. So move down to line 13, then press right until you reach the string ' credits'. Press enter on it, then scroll down to <String><. Now type in K's credits. Your script should look like this
Save and run the script again. This is what I got:
So that's 3,039,428k. So 3,039 million or 3 billion credits worth! hmm.. well, I dont think its a good idea to declare with them... yet! Please note, if you change the race on line 3, our message will still say Argon's unless you update it.
<< Previous Page