Hi. Here I will post an easy tutorial about how you can add a “locked gate” event easily even without needing to study hard about scripting.
This is valid ONLY for gates. I will add soonly how to do it also for doors
Simply follow those instructions:
Use Editor and create a gate and set the param “is locked” to 1. Set the param “label” with an easy name (I suggest something like “gate_COLOUR” - example “gate_golden”)
save the level and close frogatto
open the level file (example “my_level.cfg”) with a text editor
use the “search” function inside your text editor. You sould find your “character” tag (see the label parameter)
you will see a list of params. After the parameter “label” (for example label=“gate_golden”) add the following lines. you will need some little changes. I will mark WHERE you need to change something
on_child_spawned="if(child.type in [[b]'lock_golden'[/b]],set(vars.locks, vars.spawned_locks + [child]))"
on_collide_object=“if(collide_with.type = ‘key_golden’, [fire_event(‘unlock’), fire_event(vars.locks,‘unlock’), set(collide_with.hitpoints, 0), set(level.player.vars.triggered_events, level.player.vars.triggered_events + [‘nobun01_gate_golden_unlocked’])])”
on_create=“if(‘nobun01_gate_golden_unlocked’ in level.player.vars.triggered_events,fire_event(‘unlock’), spawn(‘lock_golden’,midpoint_x-10,midpoint_y+31,1))”
A - here you will see spaces becouse every parameter will require a line only but the forum is unable to see the entire line. BUt, for better readability I suggest to don’t let those blank lines.
B - you must change ONLY the parameters I bolded. The other things not require any change.
C - ‘key_golden’ -> replace with your key (example ‘key_red’)
D - ‘nobun01_gate_golden_unlocked’ -> this is a var. It can be hard to explain what is it so I will leave a very-easy hint about how to rename it. I suggest to rename it as 'your_level_namegatecolour_unlocked’
where “your_level_name” is the filename of your level (must be unique and without spaces. Use _ instead)
and “colour” is the colour of the gate lock (for example ‘golden’, ‘red’ or ‘green’, …)
E - ‘lock_golden’ -> replace “golden” with the colour of the lock (for example if you must create a “red” lock use ‘lock_red’)
- Save the .cfg file with your editor