fa icon indicating copy to clipboard operation
fa copied to clipboard

Redundancies to avoid lua errors

Open maudlin27 opened this issue 1 year ago • 0 comments

This fixes two lua errors I received in a desynced replay (was an AI vs AI game I was testing offline hence no replay ID to refer to).

The first was: WARNING: Error running lua script: ...\gamedata\units.nx2\units\xab3301\xab3301_script.lua(52): attempt to call method SetRate' (a nil value) stack traceback: ...\gamedata\units.nx2\units\xab3301\xab3301_script.lua(52): in function CreateVisibleEntity' ...ata\faforever\gamedata\lua.nx2\lua\remoteviewing.lua(57): in function <...ata\faforever\gamedata\lua.nx2\lua\remoteviewing.lua:49>

I've therefore added a check to make sure that the method SetRate isn't called if it doesn't exist (and for completeness have done the same with the following lines calling a separate method SetTargetSpeed)

The second error was: WARNING: Error running lua script: ...ithub\fa\lua\sim\weapons\defaultprojectileweapon.lua(414): Game object has been destroyed stack traceback: [C]: in function `RemoveEconomyEvent' ...ithub\fa\lua\sim\weapons\defaultprojectileweapon.lua(414): in function <...ithub\fa\lua\sim\weapons\defaultprojectileweapon.lua:412>

For this, I added a check if the object in question returned true for IsDestroyed() before going on to call RemoveEconomyEvent.

Re-running the replay with these changes, neither error appeared (and no other 'error running lua script' messages appeared either).

maudlin27 avatar Aug 17 '24 07:08 maudlin27