mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
Leaderboards for karls
This commit is contained in:
parent
f279c1c4fa
commit
9827a43ec0
3 changed files with 43 additions and 17 deletions
|
@ -433,6 +433,13 @@ function player_fns.peer_get_player_data(peer_id, dont_spawn_new)
|
||||||
return ctx.players[peer_id]
|
return ctx.players[peer_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function player_fns.nickname_of_peer(peer_id)
|
||||||
|
if ctx.players[peer_id] ~= nil then
|
||||||
|
return ctx.players[peer_id].name
|
||||||
|
end
|
||||||
|
return "???"
|
||||||
|
end
|
||||||
|
|
||||||
function player_fns.get_player_data_by_local_entity_id(entity)
|
function player_fns.get_player_data_by_local_entity_id(entity)
|
||||||
return ctx.player_data_by_local_entity[entity]
|
return ctx.player_data_by_local_entity[entity]
|
||||||
end
|
end
|
||||||
|
|
|
@ -64,19 +64,6 @@ local function show_game_effects()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local bring_cam = false
|
|
||||||
local bring_cam_back = nil
|
|
||||||
function module.on_world_update()
|
|
||||||
if bring_cam then
|
|
||||||
local cx, cy = GameGetCameraPos()
|
|
||||||
-- GameSetCameraPos(0, 8600 - 20)
|
|
||||||
GameSetCameraPos(-200, 1390)
|
|
||||||
bring_cam = false
|
|
||||||
GameSetCameraPos(cx, cy)
|
|
||||||
bring_cam_back = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function module.on_world_update_post()
|
function module.on_world_update_post()
|
||||||
if imgui.Begin("EW Debug stuff") then
|
if imgui.Begin("EW Debug stuff") then
|
||||||
if imgui.CollapsingHeader("General") then
|
if imgui.CollapsingHeader("General") then
|
||||||
|
@ -110,6 +97,9 @@ function module.on_world_update_post()
|
||||||
tp_button("Tree", -1901.962, -1405.003)
|
tp_button("Tree", -1901.962, -1405.003)
|
||||||
tp_button("Essence - Laser", 16000, -1800.003)
|
tp_button("Essence - Laser", 16000, -1800.003)
|
||||||
tp_button("Essence - Eater", 12620.563, -141.003)
|
tp_button("Essence - Eater", 12620.563, -141.003)
|
||||||
|
tp_button("Karl", 3200, 2400)
|
||||||
|
end
|
||||||
|
if imgui.CollapsingHeader("HM Teleports") then
|
||||||
tp_button("Mines HM", -200, 1390)
|
tp_button("Mines HM", -200, 1390)
|
||||||
tp_button("Coal pits HM", -300, 2900)
|
tp_button("Coal pits HM", -300, 2900)
|
||||||
tp_button("Snowy HM", -300, 5000)
|
tp_button("Snowy HM", -300, 5000)
|
||||||
|
@ -117,10 +107,6 @@ function module.on_world_update_post()
|
||||||
tp_button("Jungle HM", -300, 8550)
|
tp_button("Jungle HM", -300, 8550)
|
||||||
tp_button("Vault HM", -300, 10600)
|
tp_button("Vault HM", -300, 10600)
|
||||||
tp_button("Lab HM", 2200, 13150)
|
tp_button("Lab HM", 2200, 13150)
|
||||||
|
|
||||||
if fw_button("test_load") then
|
|
||||||
bring_cam = true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if imgui.CollapsingHeader("Game effects") then
|
if imgui.CollapsingHeader("Game effects") then
|
||||||
show_game_effects()
|
show_game_effects()
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
local rpc = net.new_rpc_namespace()
|
local rpc = net.new_rpc_namespace()
|
||||||
|
|
||||||
|
local best_times = rpc:create_var("best_times")
|
||||||
|
|
||||||
local karl = {}
|
local karl = {}
|
||||||
|
|
||||||
local my_karl
|
local my_karl
|
||||||
|
|
||||||
|
local gui = GuiCreate()
|
||||||
|
|
||||||
function rpc.kill_karl()
|
function rpc.kill_karl()
|
||||||
for _, entity in ipairs(EntityGetWithTag("racing_cart")) do
|
for _, entity in ipairs(EntityGetWithTag("racing_cart")) do
|
||||||
local com = EntityGetFirstComponentIncludingDisabled(entity, "VariableStorageComponent", "ew_karl")
|
local com = EntityGetFirstComponentIncludingDisabled(entity, "VariableStorageComponent", "ew_karl")
|
||||||
|
@ -44,6 +48,20 @@ function rpc.send_karl(x, y, vx, vy, t, jet)
|
||||||
ComponentSetValue2(vel, "mVelocity", vx, vy)
|
ComponentSetValue2(vel, "mVelocity", vx, vy)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function draw_leaderboards_gui()
|
||||||
|
GuiStartFrame(gui)
|
||||||
|
GuiZSet(gui, 11)
|
||||||
|
|
||||||
|
local _w, h = GuiGetScreenDimensions(gui)
|
||||||
|
local text_x = 10
|
||||||
|
local text_y = h / 5
|
||||||
|
GuiText(gui, text_x, text_y - 10, "Lap times")
|
||||||
|
for peer_id, peer_time in pairs(best_times.values) do
|
||||||
|
GuiText(gui, text_x, text_y, string.format("%-16s %.02fs", player_fns.nickname_of_peer(peer_id), peer_time/60))
|
||||||
|
text_y = text_y + 10
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function karl.on_world_update()
|
function karl.on_world_update()
|
||||||
if my_karl == nil or not EntityGetIsAlive(my_karl) then
|
if my_karl == nil or not EntityGetIsAlive(my_karl) then
|
||||||
if my_karl ~= nil and not EntityGetIsAlive(my_karl) then
|
if my_karl ~= nil and not EntityGetIsAlive(my_karl) then
|
||||||
|
@ -65,7 +83,22 @@ function karl.on_world_update()
|
||||||
local vx, vy = ComponentGetValue2(vel, "mVelocity")
|
local vx, vy = ComponentGetValue2(vel, "mVelocity")
|
||||||
local jet = ComponentGetIsEnabled(EntityGetFirstComponentIncludingDisabled(my_karl, "SpriteParticleEmitterComponent"))
|
local jet = ComponentGetIsEnabled(EntityGetFirstComponentIncludingDisabled(my_karl, "SpriteParticleEmitterComponent"))
|
||||||
rpc.send_karl(x, y, vx, vy, t, jet)
|
rpc.send_karl(x, y, vx, vy, t, jet)
|
||||||
|
|
||||||
|
local stopwatch_best = EntityGetClosestWithTag(x, y, "stopwatch_best_lap")
|
||||||
|
local com = EntityGetFirstComponentIncludingDisabled(stopwatch_best, "VariableStorageComponent")
|
||||||
|
if com ~= nil then
|
||||||
|
local best_time = ComponentGetValue2(com, "value_int")
|
||||||
|
best_times.set(best_time)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Center of the race track
|
||||||
|
local center_x, center_y = 3200, 2312
|
||||||
|
local x, y, w, h = GameGetCameraBounds()
|
||||||
|
if x < center_x and center_x < x + w and y < center_y and center_y < y+h then
|
||||||
|
draw_leaderboards_gui()
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return karl
|
return karl
|
Loading…
Add table
Add a link
Reference in a new issue