NERPs example goal script

This article is an unfinished work in progress or contains transferred information that needs to be rewritten or reformatted to fit our standards. Please excuse the mess and do not mark for deletion.

This is an example of a simple goal script written in NERPs

TRUE ? SetTutorialFlags 0
TRUE ? SetMessagePermit 1

TRUE ? SetR1 0
GetToolstoresBuilt = 0 ? AddR1 1
GetMinifiguresOnLevel = 0 ? AddR1 1
GetR1 = 2 ? SetLevelFail
GetCrystalsCurrentlyStored > 39 ? SetLevelCompleted

Breaking it down we get:

TRUE ? SetTutorialFlags 0

Disables all game tutorial functions.

TRUE ? SetMessagePermit 1

Enables the game to show messages as needed.

TRUE ? SetR1 0

Set register R1 to the value 0

GetToolStoresBuilt = 0 ? AddR1 1

If there are no toolstores left on the level, add 1 to R1

GetMinifiguresOnLevel = 0 ? AddR1 1

If there are no rock raiders left on the level, add 1 to R1

GetR1 = 2 ? SetLevelFail

If R1 = 2, which means that there are no toolstore and no rock raiders left, tell the game that the mission failed

GetCrystalsCurrentlyStored > 39 ? SetLevelCompleted

If we have more than 39 crystal stored, e.g. 40 crystals, tell the game that we succesfully completed the level


If we now would want to also check for say a power station begin built, we can modify the last part of the script as such:

TRUE ? SetTutorialFlags 0
TRUE ? SetMessagePermit 1

; Check for level fail
TRUE ? SetR1 0
GetToolstoresBuilt = 0 ? AddR1 1
GetMinifiguresOnLevel = 0 ? AddR1 1
GetR1 = 2 ? SetLevelFail

; Check for level success
TRUE ? SetR1 0
GetCrystalsCurrentlyStored > 39 ? AddR1 1
GetPowerStationsBuilt > 0 ? AddR1 1
GetR1 = 2 ? SetLevelCompleted

This technique of using a counter register is handy, just remember to compare the register with the number of objectives in there.