Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function gadget:GetInfo()
- return {
- name = "locatecmd",
- desc = "Adds a command button for location initiation.",
- author = "Bilal Itani",
- date = "March 31, 2013",
- license = "GNU GPL, v3.0 or later",
- layer = 0,
- enabled = true -- loaded by default?
- }
- end
- if (gadgetHandler:IsSyncedCode()) then
- --SYNCED
- --local EditUnitCmdDesc = Spring.EditUnitCmdDesc
- --local FindUnitCmdDesc = Spring.FindUnitCmdDesc
- --local GiveOrderToUnit = Spring.GiveOrderToUnit
- --local SetUnitNeutral = Spring.SetUnitNeutral
- --local GetUnitMoveTypeData = Spring.GetUnitMoveTypeData
- --local SetGroundMoveTypeData = Spring.MoveCtrl.SetGroundMoveTypeData
- --local SetGunshipMoveTypeData = Spring.MoveCtrl.SetGunshipMoveTypeData
- local LOCATOR = {
- [UnitDefNames["locator"].id] = true,
- }
- local locatorList = {}
- local CMD_STRT_LOC = 34581
- local locateCmd = {
- id = CMD_STRT_LOC,
- name = "Locate",
- action = "locate",
- type = CMDTYPE.ICON_MAP,
- tooltip = "Commands the locator to locate.",
- params = { 'Stop', 'Locate',}
- }
- --Info for cmd
- function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) --identifies unitID, unitDefID, unitTeam, and builderID of each unit created. Can be used for specified units.
- --callin for when locator is created
- if LOCATOR[unitDefID] then
- --makes callin locator specific
- Spring.InsertUnitCmdDesc(unitID, 500, locateCmd)
- --actually creates the cmd; makes it visible in the locator's cmd buttons
- else
- end
- end
- function gadget:UnitDestroyed(unitID, unitDefID, unitTeam)
- locatorList[unitID] = nil
- end
- function gadget:CommandFallback(unitID, unitDefID, unitTeam, cmdID, cmdParams, cmdOptions, cmdTag)
- --callin when clicking the cmd button, then clicking on the map
- if LOCATOR[unitDefID] then
- Spring.Echo("commandfallback is working so far.")
- -- function Spring.GetMouseState(a, b, c, d, e)
- -- c = true
- Spring.GiveOrderToUnit(unitID, CMD.MOVE , {x,92,z }, {}) --92 for map being tested
- --tells the locator to move to coords x,y,z
- end
- if (not gadgetHandler:IsSyncedCode()) then
- --UNSYNCED
- x,z = Spring.GetMouseState(mousex, mousey)
- --supposed to set cmd.move vars to where the cursor is clicked on the map
- end
- --I can't find any other way to put this part
- --of the commandfallback function into synced code
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment