-- name: \\#26D100\\Set Checkpoints\\#26D100\\ -- description: Set checkpoint by Holding 1 -- this is great to use on your custom romhack to prevent softlock! just throw this code in your main.lua in your romhack mod folder --GLOBAL VARIABLES startlocationstored = true mariosstartx = 0 mariosstarty = 0 mariosstartz = 0 removelastmarker = false local function hud_icon_behavior(obj) obj.oFaceAngleYaw = obj.oFaceAngleYaw + 0x100 -- Rotate slowly if removelastmarker then obj_mark_for_deletion(obj) end end function hud_icon__behavior_init(obj) obj.oFlags = OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE obj.oGraphYOffset = 35 cur_obj_scale(2.0) network_init_object(obj, true, nil) end -- Function to spawn the HUD icon object function spawn_hud_icon_object(m) local obj = spawn_sync_object( id_bhvHudIconObject, E_MODEL_EXCLAMATION_POINT, m.pos.x, m.pos.y, m.pos.z, nil) end id_bhvHudIconObject = hook_behavior(nil, OBJ_LIST_DEFAULT, true, hud_icon__behavior_init, hud_icon_behavior) function mario_update(m) if (m.controller.buttonDown & L_TRIG) ~= 0 then if (m.controller.buttonPressed & Y_BUTTON) ~= 0 then m.pos.x = mariosstartx m.pos.y = mariosstarty m.pos.z = mariosstartz -- sets marios location to the checkpoint end if (m.controller.buttonPressed & U_JPAD) ~= 0 then -- Gets marios Location when the level starts, then sets startlocationstored false spawn_hud_icon_object(m) mariosstartx = m.pos.x mariosstarty = m.pos.y mariosstartz = m.pos.z startlocationstored = false removelastmarker = true else removelastmarker = false end end if startlocationstored then -- Gets marios Location when the level starts, then sets startlocationstored false mariosstartx = m.pos.x mariosstarty = m.pos.y mariosstartz = m.pos.z startlocationstored = false end end function on_load() -- called by the hook HOOK_ON_LEVEL_INIT when a level is loaded startlocationstored = true -- reset boolean to true when a new level loads end function directions(msg) djui_chat_message_create("While Hold L Use Up button to set Checkpoins and Y button to travel") return true end --HOOKS hook_event(HOOK_ON_LEVEL_INIT, on_load) hook_event(HOOK_MARIO_UPDATE, mario_update) hook_event(HOOK_ON_PLAYER_CONNECTED, directions)