Uhh still can't delete WSC properly without crashing anything

This commit is contained in:
IQuant 2024-11-12 17:26:42 +03:00
parent f1a0bbf07f
commit c4e6fe2dd4
4 changed files with 82 additions and 9 deletions

View file

@ -1,9 +1,13 @@
local ffi = require("ffi")
local world_ffi = require("noitapatcher.nsew.world_ffi")
local initial_world_state_entity = nil
local module = {}
function module.on_world_initialized()
initial_world_state_entity = GameGetWorldStateEntity()
ewext.save_world_state()
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))
@ -16,4 +20,12 @@ function module.on_local_player_spawn()
end
function module.on_world_update()
if GameGetWorldStateEntity() ~= initial_world_state_entity then
GamePrint("Whoops WSE is different "..GameGetWorldStateEntity().." "..initial_world_state_entity)
-- EntityKill(GameGetWorldStateEntity())
ewext.load_world_state()
end
end
return module