MontyTRC89 / TombEngine

A new custom Tomb Raider engine based on TR5 engine
MIT License
69 stars 18 forks source link

validity of a movable object after loading #1255

Open davidmarr opened 1 year ago

davidmarr commented 1 year ago

If one destroys a moveable object via the Moveable:Destroy() method, the Moveable:GetValid() method will return false. If one saves the game and load it, the Moveable:GetValid() method will return true. For testing, I created a lua DestroyMoveable function called from a volume

https://github.com/MontyTRC89/TombEngine/assets/116632612/ec617c4b-e527-43c6-a149-af6ed427ca0b

---- FILE: \bug.lua
local x, y = PercentToScreen(50, 80)
local phrases = DisplayString('Checkpoint!', x, y, Color(50, 250, 250), false)
phrases:SetFlags({ TEN.Strings.DisplayStringOption.BLINK, TEN.Strings.DisplayStringOption.CENTER })

if not IsStringDisplaying(phrases) then
    ShowString(phrases)
end

local obj = TEN.Objects.GetMoveableByName("animating2_13")

LevelFuncs.OnLoad = function() end
LevelFuncs.OnSave = function() end
LevelFuncs.OnStart = function() end
LevelFuncs.OnControlPhase = function()
    if IsStringDisplaying(phrases) then
        phrases:SetKey("moveable state: " .. tostring(obj:GetValid()))
    end
end
LevelFuncs.OnEnd  = function() end

LevelFuncs.DestroyMoveable = function(arg)
       TEN.Objects.GetMoveableByName(arg):Destroy()
end
Adngel commented 7 months ago

I think the issue is in the lua code.

it's loading the obj during the script compilation time.

As I understand, the flow is going like this:

So, I'll check the issue reported here, but at first sight, I think it's an issue related to the used lua script, I think it should get the data of the moveable, during OnStart and OnLoad.