Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: PR0T05T33L on April 08, 2017, 11:49:38 PM

Title: Can we rerun a script from the beginning of the game when loading autosave?
Post by: PR0T05T33L on April 08, 2017, 11:49:38 PM
So I have a script that changes the colour of the creeper to orange at the beginning of the game. I tested the finalized map last night and left mid-game. When I opened the map back up, the creeper had turned back to blue.

I know this probably won't happen much, but is there a way to run a script when the player reloads a saved game?
At the very least, how do I get that script to rerun every minute or so? Will it actually work?
Title: Re: Can we rerun a script from the beginning of the game when loading autosave?
Post by: GoodMorning on April 08, 2017, 11:55:06 PM
Running on load is easy:


:awake
#Your code here


Rerunning this kind of thing is annoying to the player if they don't like the custom colours (or are colourblind), so run-on-load is probably the best way for your purposes.
Title: Re: Can we rerun a script from the beginning of the game when loading autosave?
Post by: PR0T05T33L on April 09, 2017, 12:07:53 AM
Does that go above all of the code or under the part that says once?
Title: Re: Can we rerun a script from the beginning of the game when loading autosave?
Post by: GoodMorning on April 09, 2017, 12:23:30 AM
To set the Creeper/AC colouration immediately, and again when the game loads:


$Creeper_Red:54
$Creeper_Green:76
$Creeper_Blue:204
$AC_Red:0
$AC_Green:153
$AC_Blue:255

once
@PaintCreeper
endonce

:awake
@PaintCreeper

:PaintCreeper
<-Creeper_Red <-Creeper_Green <-Creeper_Blue <-AC_Red <-AC_Green <-AC_Blue SetCreeperColors