Lua Script Environment Problem

Lua Script Environment Problem

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 9834
Joined: 24 Jan 2006, 21:12
x 112

Lua Script Environment Problem

Postby PicassoCT » 15 Feb 2018, 00:16

Good evening dear ladies and gentil men,

i come to you in great distress. Namely beeing that i seem to have shot the ability of gadgets to retrieve a environment.
https://github.com/PicassoCT/Journeywar/blob/6c4f6221721dec57431702d1c0a409c75b4016bb/LuaRules/Gadgets/jw_ProjectileImpacts.lua#L669
Many of the more complex units in my game rely on this ability and are thuse useless.

It also seems that all the Unitscript tables are missing from the environment.
These are tables such as COB, SFX etc.
My unit_script.lua is very close to the Zero-k one in setup. I shall compare it next to the spring default unitscript.lua.
https://github.com/PicassoCT/Journeywar/blob/develop/LuaRules/Gadgets/unit_script.lua

If you have any advice or direction - i would be gratefull.

Regards and have a nice evening
0 x

gajop
Moderator
Posts: 2877
Joined: 05 Aug 2009, 20:42
x 146

Re: Lua Script Environment Problem

Postby gajop » 15 Feb 2018, 03:56

Are you sure attackerID is not nil?
1 x

User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 9834
Joined: 24 Jan 2006, 21:12
x 112

Re: Lua Script Environment Problem

Postby PicassoCT » 15 Feb 2018, 12:23

I do get a number, it is not the attackerID though.

I investigated further- seems that the arguments with which my UnitDamaged is called, do not include the projectile ID.

And solved it:

Here is what happened, i had old code in my gadgets.lua

which had commented out callins for
gadget:UnitDamaged
gadget:PreUnitDamaged

Code: Select all

--[[ Old
Here be old Code

--]]


The old code had been re-formatted by a formation tool, which added a space betwee the uncomment mark

Code: Select all

-- [[



Reactivating the dead code- let this be a warning to future generations. Delete old code.
0 x


Return to “Lua Scripts”