Skip to content

Commit

Permalink
add warp example
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed Mar 20, 2021
1 parent 562cc58 commit 47f4375
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
19 changes: 19 additions & 0 deletions examples/death_warp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
meta.name = 'Death warp'
meta.version = 'WIP'
meta.description = 'Automatic instant restart on death.'
meta.author = 'Dregu'

-- actually instant restart on death
set_callback(function()
if state.screen ~= 12 then
return
end
local hp = 0
for i, player in ipairs(players) do
hp = hp + player.health
end
if hp == 0 then
state.quest_flags = set_flag(state.quest_flags, 1)
warp(state.world_start, state.level_start, state.theme_start)
end
end, ON.FRAME)
10 changes: 5 additions & 5 deletions src/injected/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,11 @@ void render_narnia()
if (ImGui::DragScalar("Level##WarpLevel", ImGuiDataType_U8, &g_level, 0.1f, &u8_one, &u8_four)) {}
render_themes();
ImGui::PopItemWidth();
if (ImGui::Button("Instant warp##InstantWarp"))
{
warp(g_world, g_level, g_to + 1);
}
ImGui::SameLine();
if (ImGui::Button("Warp door##SpawnWarpDoor"))
{
int spawned = spawn_door(g_x, g_y, g_world, g_level, g_to + 1);
Expand All @@ -1759,11 +1764,6 @@ void render_narnia()
{
spawn_backdoor(g_x, g_y);
}
ImGui::SameLine();
if (ImGui::Button("Warp##InstantWarp"))
{
warp(g_world, g_level, g_to + 1);
}
ImGui::Text("Instant warp to level:");
std::vector<uint32_t> doortypes;
doortypes.push_back(to_id("ENT_TYPE_FLOOR_DOOR_EXIT"));
Expand Down

0 comments on commit 47f4375

Please sign in to comment.