All pastes #2060530 Raw Edit

Unlock question answer

public text v1 · immutable
#2060530 ·published 2011-05-15 16:31 UTC
rendered paste body
Create an object and put it in the first room of the game. Its create event looks like this:
global.unlocked=ds_list_create()
Scripts:
//level_unlock(level)
ds_list_add(global.unlocked,argument0)
return true

//level_lock(level)
var ind;
ind = ds_list_find_index(argument0)
if ind = -1 then return false
ds_list_delete(global.unlocked,ind)//I may have remembered the name of this function wrong. Can't get to my help file right now.
return true

//level_is_locked(level)
if ds_list_find_index(argument0)>=0 then return true else return false

Now, in your goal object, add this code to the part where the player wins, at the end.
level_unlock(level)
Finally, go to your goal object in the room editor, and control-rightclick it. There should be something about adding custom code. Go there and type
level=name of the level you want to unlock

On your overworld, have level selection objects check level_is_locked() for their respective rooms before letting players pass.