CommandFallback & factories

CommandFallback & factories

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

CommandFallback & factories

Post by zwzsg »

Is it just me, or is CommandFallback never reached for custom orders given to factories?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: CommandFallback & factories

Post by Argh »

It's not just you. I documented that in P.U.R.E.'s source, but it's in a section dealing with the Advance Base, so it's probably obscure.

An example of a custom Command for a Factory:

Code: Select all

function gadget:AllowCommand(u, ud, team, cmd, param, opts)
	if (cmd ~= CMD_TRANSFORM_ADVANCEBASE) then	
    		return true -- command was not used
	else
		if CanTransformIntoBase[ud] then
			--Spring.RemoveUnitCmdDesc(u, TransformAdvanceBase)
			local cmdID = Spring.FindUnitCmdDesc(u, CMD_TRANSFORM_ADVANCEBASE)
			Spring.EditUnitCmdDesc(u,cmdID,{disabled = true, tooltip = "Transformation started.",})
			Spring.CallCOBScript(u, "TransformAdvanceBase", 0)
			return false
		end
	end
	return true -- if all else fails
end
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: CommandFallback & factories

Post by zwzsg »

Ok, thanks.

Indeed I noticed AllowCommand is still called, but executing the order as soon as it's queued seemed a dirty workaround for me.

Is it a bug, or is there some logical explanation why factories can't have CommandFallback?

And if a bug, is it going to be fixed? :P

I mean, I can understand factories work a bit differently, with move & fight orders that don't make them move but remain in queue and are passed to child, and aren't lost when build orders are given, etc...
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: CommandFallback & factories

Post by Argh »

You can get around the timing via various means. I used a COB script, since what I wanted to happen when users hit that command was fairly complex- weapons shut down, things move, etc. and I wanted the operation to take a precise amount of time.

Not saying that's perfect, mind you, just that I really didn't find it hard to build a workaround, once I knew what the problem was.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: CommandFallback & factories

Post by KDR_11k »

Doesn't a custom order to a factory get added to the waypoint queue instead of the build queue?
Post Reply

Return to “Lua Scripts”