Script.SetWatchWeapon + ProjectileCreated
Posted: 29 Jul 2013, 05:21
I found this script Script.SetWatchWeapon(weaponDef.id, true) is something like prerequisite for use of Call-in ProjectileCreated, where i can match the same weaponDef.id.
I did this in init part:
And I plan to use something like this (bugWeaponID is global):
.. but when gadget is loaded, i get this error:
I did this in init part:
Code: Select all
function gadget:Initialize()
for id,weaponDef in pairs(WeaponDefs) do
local wName = weaponDef.name
if (wName == "darkswarm") then
Script.SetWatchWeapon(weaponDef.id, true)
bugWeaponID = weaponDef.id
end
end
end
Code: Select all
function gadget:ProjectileCreated(projectileID, projectileOwnerID, projectileWeaponDefID)
if (bugWeaponID == projectileWeaponDefID) then
spSetUnitWeaponState(projectileOwnerID,2,"range",100)
end
end
Can you pls explain how this work and if this Script is the one i need for use of this call-in described on wiki like:[f=0000000] Error: error = 2, LuaRules/draw.lua, error = 2, LuaRules/gadgets.lua, [string "LuaRules/Gadgets/0fix_bug5.lua"]:56: attempt to call field 'SetWatchWeapon' (a nil value)
ProjectileCreated() --> "proID, proOwnerID, weaponDefID" Only called for weapons with SetWatchWeapon enabled