Lua can't give order during first instant
Posted: 09 Aug 2007, 02:35
Try the following \LuaUI\Widgets\*.LUA script:
It is supposed to turn "repeat" ON on every unit upon their creation. However, you'll notice that, for the commander, while the command is actually issued (you see the message), it remains "repeat" OFF. For any other unit it works fine.
I guess that lua is not allowed to give order during the first instant of the game. Why? Can be fixed? How do I workaround it?
I'm trying to fix Kernel Panic for 75b2. And amongst other thing, I need the autospam script to work again, and it'd be much nicer if that included the kernel.
Code: Select all
function widget:GetInfo()
return {
name = "Force Repeat ON",
desc = "Turn repeat ON on all units during their creation",
author = "zwzsg",
date = "August 8, 2007",
license = "Free",
layer = 0,
enabled = true -- loaded by default
}
end
function widget:UnitCreated(unitID, unitDefID, unitTeam)
local ud = UnitDefs[unitDefID]
if(unitTeam == Spring.GetMyTeamID()) then
Spring.GiveOrderToUnit(unitID, CMD.REPEAT, { 1 }, {})
Spring.Echo("Repeat order issued on " .. ud.name)
end
end
I guess that lua is not allowed to give order during the first instant of the game. Why? Can be fixed? How do I workaround it?
I'm trying to fix Kernel Panic for 75b2. And amongst other thing, I need the autospam script to work again, and it'd be much nicer if that included the kernel.