Jump to content

Getting parts of an NPL to run once only


aidenpons
 Share

Recommended Posts

I want to know how to get parts of an .npl to run once and once only. Because when you just put TRUE ? blah blah blah it will run once every 0.04 seconds (approximately). Of course the simple thing would be to have something like

 

GetR7 != 9 :Blah

 

Blah: {

TRUE ? stuff you put here that wants to run once

TRUE ? SetR7 9

}

 

...but then when you restart the level, I don't think it'll run as R7 will still be 9.

 

I could use the 'GetObjectiveShowing' stuff, but a) which thingy do I actually use, and b) what happens if someone forgets the crystal count and looks at the objective?

 

Is there anything I can do?

Link to comment
Share on other sites

Game scripts always run in a loop. If you call a custom function from the main function, it will always repeat everytime the condition for it is true.

Post your entire script and I'll tell you how to make it not loop.

EDIT: I think you have a complete misunderstanding of how the scripts work. Just post yours and I'll run the entire thing through.

Link to comment
Share on other sites

Just post yours and I'll run the entire thing through.

 

Basically I'm trying to get timers to reset themselves at the beginning of the game and afterwards when I tell them to.

 

TRUE ? SetMessagePermit 0
TRUE ? SetTutorialFlags 3
TRUE ? SetR1 0
TRUE ? SetR2 0

GetR7 != 9 :Start

Start: {
TRUE ? SetTimer1 0
TRUE ? SetTimer2 0
TRUE ? SetTimer3 0
TRUE ? SetR7 9
}

GetToolStoresBuilt = 0 ? AddR1 1
GetMiniFiguresOnLevel = 0 ? AddR1 1
GetR1 = 2 ? SetLevelFail

GetOxygenLevel < 1 ? SetLevelFail
GetTimer1 < 2 ? :FirstMessage

FirstMessage: {
TRUE ? SetMessagePermit 1
TRUE ? SetMessage 1 1
TRUE ? SetMessagePermit 0
}

GetTutorialBlockIsGround 2 TRUE ? :SecondMessage

SecondMessage: {
TRUE ? SetMessagePermit 1
TRUE ? SetMessage 2 1
TRUE ? SetCameraGotoTutorial 1
TRUE ? AllowCameraMovement
}

GetUnitAtBlock 5 TRUE ? :MoreMonsters

MoreMonsters: {
GetTimer3 > 120 ? SetRockMonsterAtTutorial 6
GetTimer3 > 120 ? SetTimer3 0
}

GetUnitAtBlock 3 TRUE ? :MonstersUnite

MonstersUnite: {
GetTimer2 > 120 ? SetRockMonsterAtTutorial 4
GetTimer2 > 120 ? SetTimer2 0
}

 

The stuff in the 'Start' section is the stuff I want the game to run once and once only.

Link to comment
Share on other sites

I can already see you didn't put an end condition to :Start:, so it just runs through the rest of the script as if the entire thing is :Start: and never stops. Hell, the script probably breaks multiple times as you put more functions in which never terminate. I'll rewrite it and get back to you.

EDIT: Why'd you use {}? This isn't C. NERPS has its own conventions.

Link to comment
Share on other sites

Hell, the script probably breaks multiple times as you put more functions in which never terminate

Yep, sounds about right.

Link to comment
Share on other sites

//Intial Game Conditions - R1 and R2 are reserved and shouldn't be reset?

TRUE ? SetMessagePermit 0
TRUE ? SetTutorialFlags 3
//TRUE ? SetR1 0
//TRUE ? SetR2 0

GetToolStoresBuilt = 0 ? AddR1 1
GetMiniFiguresOnLevel = 0 ? AddR1 1
GetR1 = 2 ? SetLevelFail

//All variables *should* reset automatically, so this is pretty much redundant except to trigger one time script

GetR7 != 9 :Start

//One time trigger sets

Start:
TRUE ? SetTimer1 0
TRUE ? SetTimer2 0
TRUE ? SetTimer3 0
TRUE ? SetR7 9
Start:

GetOxygenLevel < 1 ? SetLevelFail
GetTimer1 < 2 ? :FirstMessage

FirstMessage:
TRUE ? SetMessagePermit 1
TRUE ? SetMessage 1 1
TRUE ? SetMessagePermit 0
FirstMessage:

GetTutorialBlockIsGround 2 TRUE ? :SecondMessage

SecondMessage:
TRUE ? SetMessagePermit 1
TRUE ? SetMessage 2 1
TRUE ? SetCameraGotoTutorial 1
TRUE ? AllowCameraMovement
SecondMessage:

GetUnitAtBlock 5 TRUE ? :MoreMonsters

MoreMonsters:
GetTimer3 > 120 ? SetRockMonsterAtTutorial 6
GetTimer3 > 120 ? SetTimer3 0
MoreMonsters:

GetUnitAtBlock 3 TRUE ? :MonstersUnite

MonstersUnite:
GetTimer2 > 120 ? SetRockMonsterAtTutorial 4
GetTimer2 > 120 ? SetTimer2 0
MonstersUnite:

Try that, might not work since I haven't scripted in years.

EDIT: If it doesn't work, set the TRUE conditions in :Start: to require R7 to be anything which isn't 9.

Edited by McJobless
Link to comment
Share on other sites

Try that, might not work since I haven't scripted in years.

It doesn't seem to. I added the line

TRUE ? AddPoweredCrystals GetTimer1
to it, but the crystal count doesn't go up.

 

So everything in RR does reset? To what? Hmm...

Link to comment
Share on other sites

TRUE ? AddPoweredCrystals GetTimer1

Wha...what is that line? Why are you using a function? You need to place an X value (a number) of Crystals you want to add. GetTimer isn't going to work (and last I checked, Timer0+1 were both reserved for internal game functions).

 

So everything in RR does reset? To what? Hmm...

0. Otherwise weird things would happen everytime you load the same level twice, and that would be a major bug.
Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.