[23:52:34] <[S44]FLOZi> Automatons
[23:52:54] <[S44]FLOZi> you call GiveOrderToUnit inside CommandFallback
[23:53:03] <[S44]FLOZi> check infolog and see if oyu get an error message about recursion
Controlling when gameframe initiates
Moderator: Moderators
- Automatics
- Posts: 15
- Joined: 04 Aug 2011, 08:37
Re: Controlling when gameframe initiates
I don't think I see anything about recursion, but I don't even think the lua script reports an error. Infolog here: http://pastebin.com/0gH43efz
(Parsing errors are from missing files, sorry if they're annoying)
(Parsing errors are from missing files, sorry if they're annoying)
Re: Controlling when gameframe initiates
[f=0000000] Error: Failed to load: location.lua ([string "LuaRules/Gadgets/location.lua"]:52: 'end' expected (to close 'function' at line 47) near '<eof>')

After such error the gadget should not run (since it did not load) yet there is messages "[f=0000890] The locator is told to distance check for mineral deposits." Is there two versions of gadget?
There is also other gadget's error, not sure whats with them.

After such error the gadget should not run (since it did not load) yet there is messages "[f=0000890] The locator is told to distance check for mineral deposits." Is there two versions of gadget?
There is also other gadget's error, not sure whats with them.
- Automatics
- Posts: 15
- Joined: 04 Aug 2011, 08:37
Re: Controlling when gameframe initiates
No, that's disabled by default anyway. I pulled it out, but it wasn't really doing much. I'm assuming the issue is that the locator isn't getting the move command for some reason, but I don't understand why. Did I just put the move command in the wrong function or something?
- Automatics
- Posts: 15
- Joined: 04 Aug 2011, 08:37
Re: Controlling when gameframe initiates
Sorry for double posting/bumping so far, but I never fixed the issue.
I went around fixing errors, so the infolog should be easier to navigate.
Anyway, so the locator doesn't move to the coordinates I set for it to move to when it goes into proximity. It's still the same issue, so if this explanation is too vague, then it should be explained through the rest of this thread.
Infolog: http://pastebin.com/zQuywUFU
Code: http://pastebin.com/a8TeAkam
The stuff at the end of the infolog is just echo tests in gameframe.
Help is appreciated.
I went around fixing errors, so the infolog should be easier to navigate.

Anyway, so the locator doesn't move to the coordinates I set for it to move to when it goes into proximity. It's still the same issue, so if this explanation is too vague, then it should be explained through the rest of this thread.
Infolog: http://pastebin.com/zQuywUFU
Code: http://pastebin.com/a8TeAkam
The stuff at the end of the infolog is just echo tests in gameframe.
Help is appreciated.

Re: Controlling when gameframe initiates
copypaseted in mod to test:
Click "Locate" button, left-click ground - unit moves there.
When the unit comes near the mineral coordinates it says "The Locator is within range of a mineral deposit!"
But then it does not close in on the excact part of the mineral deposit because this part is outside any function and never called:
If delete that there and move it to here:
then the locator, if on his locate-travel he gets near a mineral depot will change course towards it.
In fact now the locator feels so attracted towards the minera depot that is impossible to move him away.
That is because reason:
The lolcator must be freed from the for unitID in pairs(activeLocators) do loop which is calling SetUnitMoveGoal all the time!
There actually is a activeLocators[unitID] = nil which should free him but does not
work because two reasons:
1) http://pastebin.com/6NbjeEhW Line 79 the else belongs to the wrong if.
After fixing it, any non-locate command (example: move) should "free" the lolcator from his obession with the mineral deposit.
But only in theory because
2) CommandFallback() is appearently only called for custom commands.
Not for engine ones like move.
Sorry, my mistake. But could have noticed it if you put there an Echo (cmdID) that it always prints your cmdID 34581
So for stopping the lolcator, CommandFallback can not be used like this. But AllowCommand can:
Note:
if cmdID ~= CMD_STRT_LOC
or
if cmdID ~= CMD.MOVE
would not work because the gadget gives order itself, too.
(Note the output of the Spring.Echo (CMD[cmdID]) )
gadget with above fixes:
http://pastebin.com/EWi5wyAH
Actually it is all somewhat fumbeldumbel but good luck.
Click "Locate" button, left-click ground - unit moves there.
When the unit comes near the mineral coordinates it says "The Locator is within range of a mineral deposit!"
But then it does not close in on the excact part of the mineral deposit because this part is outside any function and never called:
Code: Select all
if depositLocated == true then
Spring.SetUnitMoveGoal(unitID, metalx, metaly, metalz)
else
end
Code: Select all
if math.abs(metalx - locatorPosX)<=200 and math.abs(metalz - locatorPosZ)<=200 then
Spring.Echo("The Locator is within range of a mineral deposit!")
depositLocated = true
Spring.SetUnitMoveGoal(unitID, metalx, metaly, metalz)
In fact now the locator feels so attracted towards the minera depot that is impossible to move him away.

That is because reason:
The lolcator must be freed from the for unitID in pairs(activeLocators) do loop which is calling SetUnitMoveGoal all the time!
There actually is a activeLocators[unitID] = nil which should free him but does not
work because two reasons:
1) http://pastebin.com/6NbjeEhW Line 79 the else belongs to the wrong if.
After fixing it, any non-locate command (example: move) should "free" the lolcator from his obession with the mineral deposit.
But only in theory because
2) CommandFallback() is appearently only called for custom commands.
Not for engine ones like move.
Sorry, my mistake. But could have noticed it if you put there an Echo (cmdID) that it always prints your cmdID 34581
So for stopping the lolcator, CommandFallback can not be used like this. But AllowCommand can:
Code: Select all
function gadget:AllowCommand(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOptions)
Spring.Echo (CMD[cmdID])
if cmdID == CMD.STOP then --lolcator giving STOP command and is not active anymore
Spring.Echo ("a stop command in AllowCommand")
activeLocators[unitID] = nil
end
return true
end
if cmdID ~= CMD_STRT_LOC
or
if cmdID ~= CMD.MOVE
would not work because the gadget gives order itself, too.
(Note the output of the Spring.Echo (CMD[cmdID]) )
gadget with above fixes:
http://pastebin.com/EWi5wyAH
Actually it is all somewhat fumbeldumbel but good luck.