Can we rerun a script from the beginning of the game when loading autosave?

Started by PR0T05T33L, April 08, 2017, 11:49:38 PM

Previous topic - Next topic

PR0T05T33L

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?

GoodMorning

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.
A narrative is a lightly-marked path to another reality.

PR0T05T33L

Does that go above all of the code or under the part that says once?

GoodMorning

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
A narrative is a lightly-marked path to another reality.