
Untitled
By: a guest on
Jun 12th, 2011 | syntax:
Lua | size: 1.56 KB | hits: 59 | expires: Never
function gadget:GetInfo()
return {
name = "Weapon Command",
desc = "Weapon Toggle",
author = "Von66341",
date = "22/03/2011",
license = "",
layer = -5,
enabled = true -- loaded by default?
}
end
-- Constants
local CMD_SPECIAL = 36525
local specialCmdDesc = {
id = CMD_SPECIAL,
type = CMDTYPE.ICON_MODE,
name = "Special Weapon On/Off",
--action = "Radar",
tooltip = "Special Weapon On/off",
params = {'0','Special Weapon Off','Special Weapon On'},
texture = "UI/buttons/cmd_special.png",
}
if (gadgetHandler:IsSyncedCode()) then
-- SYNCED
function gadget:Initialize()
gadgetHandler:RegisterCMDID(CMD_SPECIAL)
end
function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID)
local ud = UnitDefs[unitDefID]
if ud.customParams.hasspecialbutton then
Spring.InsertUnitCmdDesc(unitID, CMD_SPECIAL, specialCmdDesc)
end
end
function gadget:AllowCommand(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOptions)
if cmdID == CMD_SPECIAL then
local specialCmdDescID = Spring.FindUnitCmdDesc(unitID, CMD_SPECIAL)
specialCmdDesc.params[1] = cmdParams[1]
Spring.EditUnitCmdDesc(unitID, specialCmdDescID, specialCmdDesc)
specialCmdDesc.params[1] = 1
Spring.CallCOBScript(unitID, "Special",0)
--Spring.Echo("Success")
return false
end
--Spring.CallCOBScript(unitID, "QueryWeapon1", 0, 0)
--Spring.CallCOBScript(unitID, "AimFromWeapon1", 0, 0)
--Spring.CallCOBScript(unitID, "AimWeapon1", 0, 0)
--Spring.CallCOBScript(unitID, "FireWeapon1", 0, 0)
return true
end
end