Re: Gameplay concept : Objective based skirmish
Posted: 17 Jun 2011, 21:36
K I believe I know what I was doing wrong
Spring.SetActiveCommand(index,1,left,right,alt,ctrl,meta,shift)
doesn't execute a command or so , it just says , the next active Command is said command. But I don't get it then, who actually executes the command ? I suppose in the case of move and attack it's an onMouseClick() or onMouseRelease(), but what about state commands like Cloak ? Who executes those commands , and how do I intercept the call there ? Any info you can give me on this ?
Bleh I don''t get it agian this was my latest attempt
K I believe I know what I was doing wrong
Spring.SetActiveCommand(index,1,left,right,alt,ctrl,meta,shift)
doesn't execute a command or so , it just says , the next active Command is said command. But I don't get it then, who actually executes the command ? I suppose in the case of move and attack it's an onMouseClick() or onMouseRelease(), but what about state commands like Cloak ? Who executes those commands , and how do I intercept the call there ? Any info you can give me on this ?
Bleh I don''t get it agian this was my latest attempt
The idea was to use the unitCmdDone method to find the new text of the cmd and then put it on the chilibutton. However it failed miserably this is my output of the echo statements
in one frame change my active command is bye bye , oh and the unit command activated is said to be 70 ... WTF I asked for command 95 !
Spring.SetActiveCommand(index,1,left,right,alt,ctrl,meta,shift)
doesn't execute a command or so , it just says , the next active Command is said command. But I don't get it then, who actually executes the command ? I suppose in the case of move and attack it's an onMouseClick() or onMouseRelease(), but what about state commands like Cloak ? Who executes those commands , and how do I intercept the call there ? Any info you can give me on this ?
Bleh I don''t get it agian this was my latest attempt
K I believe I know what I was doing wrong
Spring.SetActiveCommand(index,1,left,right,alt,ctrl,meta,shift)
doesn't execute a command or so , it just says , the next active Command is said command. But I don't get it then, who actually executes the command ? I suppose in the case of move and attack it's an onMouseClick() or onMouseRelease(), but what about state commands like Cloak ? Who executes those commands , and how do I intercept the call there ? Any info you can give me on this ?
Bleh I don''t get it agian this was my latest attempt
Code: Select all
function ClickFunc(button)
local _,_,left,_,right = Spring.GetMouseState()
local alt,ctrl,meta,shift = Spring.GetModKeyState()
local index = Spring.GetCmdDescIndex(button.cmdid)
if (left) then
Spring.Echo("active command set to ", button.cmdid)
Spring.SetActiveCommand(index,1,left,right,alt,ctrl,meta,shift)
end
if (right) then
Spring.Echo("active command set to ", button.cmdid)
Spring.SetActiveCommand(index,3,left,right,alt,ctrl,meta,shift)
end
end
function widget:UnitCmdDone(unitID, unitDefID, unitTeam, cmdID, cmdTag)
Spring.Echo("unit command is done",unitID, unitDefID, unitTeam, cmdID, cmdTag)
--see if cmd is a state command
local idx, cmd_id, cmd_type, cmd_name = spGetActiveCommand()
Spring.Echo("active command",idx, cmd_id, cmd_type, cmd_name)
if (not cmd_id) then return end
Spring.Echo("active command found")
local cmdDesc = spGetActiveCmdDesc( idx )
local isState = (cmdDesc.type == CMDTYPE.ICON_MODE and #cmdDesc.params > 1)
Spring.Echo("isState=", isState)
-- if state then update state text on button in main window, step one will be finding the right button
if isState then
local buttons = window0.children
local buttonToUpdate
for i=1, #buttons do
if(buttons[i].cmdid == cmdID)then
Spring.Echo("Update button found")
buttonToUpdate = buttons[i]
break;
end
end
buttonToUpdate.caption = cmdDesc.params[cmdDesc.params[1]+2]
window0:RemoveChild(buttonToUpdate)
window0:AddChild(buttonToUpdate)
end
end
Code: Select all
[f=0000156] active command set to , 95
[f=0000157] unit command is done, 1255, 2, 0, 70, 1
[f=0000157] active command, 0, nil, nil, nil