Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local CMD_QUEUE_TERRAMARKER = 39802
- -- order of arguments is different than other command funcs for some silly reason, and wrong in the wiki
- -- also options are passed as a bitfield instead of table
- function widget:UnitCommand(unitID, unitDefID, teamID, cmdId, cmdOptions, cmdParams)
- if cmdId == CMD_QUEUE_TERRAMARKER then
- local oldParams = {}
- for i = 1, #cmdParams - 1, 1 do
- oldParams[i] = cmdParams[i]
- end
- local pos = - 1 -- this is the end of the queue and -should- be behind the terra-build order. however, sometimes it isn't
- Spring.GiveOrderToUnit(unitID, CMD.INSERT,{pos, cmdParams[#cmdParams], cmdOptions, unpack(oldParams)}, CMD.OPT_ALT)
- end
- end
- function widget:CommandNotify(cmdId, cmdParams, cmdOptions)
- if currentTerraformSelectedIndex > 1 then
- if cmdId < 0 then
- local unitDefId = -cmdId
- if unitDefId == 37 or unitDefId == 275 then
- local commandPos = {}
- commandPos.x = cmdParams[1]
- commandPos.y = cmdParams[2]
- commandPos.z = cmdParams[3]
- local terraformHowMuch = 0 + currentTerraformSelectedValue
- local unitWidth = 10
- local unitHeight = 10
- local rect = GetTerraRectByParams(commandPos.x, commandPos.z, unitWidth, unitHeight, commandPos.y + terraformHowMuch, 0, 0)
- local selectedUnits = Spring.GetSelectedUnits()
- local myTeamId = Spring.GetMyTeamID()
- local volumeSelection = 0
- local terraformParams = GetTerraParameters(1, rect, selectedUnits, myTeamId, volumeSelection)
- Spring.GiveOrderToUnit(selectedUnits[1], CMD_TERRAFORM_INTERNAL, terraformParams, {"shift"})
- local newParams = {}
- for i = 1, #cmdParams, 1 do
- newParams[i] = cmdParams[i]
- end
- newParams[#cmdParams+1] = cmdId
- Spring.GiveOrderToUnit(selectedUnits[1], CMD_QUEUE_TERRAMARKER, newParams, cmdOptions)
- return true
- end
- end
- end
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment