This quest example covers switches and blocks. The complete quest file can be found in the RCE via "Ctrl+P: QquestExample2".
Logic[]
- Rocks block path.
- Activate switch to destroy them.
Pseudocode[]
Variable[]
- haveDestroyedRock = false
Events[]
activateSwitch (linked with "toggle" trigger of NPC Lever)
set haveDestroyedRock = true
_
getSwitchState (linked with "getState" attribute of NPC Lever)
if haveDestroyedRock == false
return false (not activated)
if haveDestroyedRock == true
return true (activated)
_
canSeeRock (linked with "viewedIf" attribute of NPC Rock)
if haveDestroyedRock == false
return true (visible)
if haveDestroyedRock == true
return false (not visible)
Maps[]
- Spawn block that are visible until the player activates the switch.
- Spawn the switch
Real Code[]
Variable[]
[VAR.haveDestroyedRock]:false
Events[]
activateSwitch(key:number){
s.set(key,VAR.haveDestroyedRock,true);
}
getSwitchState(key:number){
return s.get(key,VAR.haveDestroyedRock);
}
canSeeRock(key:number){
return !s.get(key,VAR.haveDestroyedRock);
}
Map[]
//Tiled project as a q1 and q2 spots on layer SPOT
m.spawnBlock(mapUid,spots.q1,EVENT.canSeeRock);
m.spawnToggle(mapUid,spots.q2,EVENT.getSwitchState,EVENT.activateSwitch);
Walkthrough from Quest Template[]
To create a new quest in the Raining Chain Editor:
- Create new quest. (Ctrl+Shift+P RCE:New Project)
- Add ids to the enums.
- Copy-paste the variable in n.newVariable().
- Copy-paste the events in EVENT_CLASS.
- Add the q1 and q2 spots in the .tmx file then "Update Spots". Make sure the q2 lever tile is positioned inbetween tiles as specified in Map Creation Guide.
- Copy-paste the npc spawning logic in the map onLoad().
- Test the quest. (Ctrl+Shift+P RCE:Test Project)