mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
Merge pull request #233 from IntQuant/rust-api
Implement rust api to allow writing modules in rust.
This commit is contained in:
commit
5628b78ae2
19 changed files with 9535 additions and 260 deletions
|
@ -9,7 +9,7 @@ local module = {}
|
|||
|
||||
function module.on_world_initialized()
|
||||
initial_world_state_entity = GameGetWorldStateEntity()
|
||||
ewext.save_world_state()
|
||||
ewext.on_world_initialized()
|
||||
local grid_world = world_ffi.get_grid_world()
|
||||
local chunk_map = grid_world.vtable.get_chunk_map(grid_world)
|
||||
grid_world = tonumber(ffi.cast("intptr_t", grid_world))
|
||||
|
@ -35,10 +35,34 @@ function module.on_local_player_spawn()
|
|||
EntitySetTransform(GameGetWorldStateEntity(), 0, 0)
|
||||
end
|
||||
|
||||
local function fw_button(label)
|
||||
return imgui.Button(label, imgui.GetWindowWidth() - 15, 20)
|
||||
end
|
||||
|
||||
local function bench_fn_lua()
|
||||
local start = GameGetRealWorldTimeSinceStarted()
|
||||
for i=1,10000 do
|
||||
local player = EntityGetClosestWithTag(0, 0, "player_unit")
|
||||
EntitySetTransform(player, 0, 0, 0, 1, 1)
|
||||
end
|
||||
local elapsed = GameGetRealWorldTimeSinceStarted() - start
|
||||
GamePrint(elapsed*1000000)
|
||||
end
|
||||
|
||||
function module.on_draw_debug_window(imgui)
|
||||
if imgui.CollapsingHeader("ewext") then
|
||||
if fw_button("test_fn") then
|
||||
ewext.test_fn()
|
||||
end
|
||||
if fw_button("bench") then
|
||||
ewext.bench_fn()
|
||||
bench_fn_lua()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function module.on_world_update()
|
||||
if GameGetWorldStateEntity() ~= initial_world_state_entity then
|
||||
-- -- EntityKill(GameGetWorldStateEntity())
|
||||
-- ewext.load_world_state()
|
||||
oh_another_world_state(GameGetWorldStateEntity())
|
||||
initial_world_state_entity = GameGetWorldStateEntity()
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue