Simple Button Questions

Simple Button Questions

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

Moderator: Moderators

Post Reply
Voidranaut
Posts: 47
Joined: 20 Dec 2009, 21:16

Simple Button Questions

Post by Voidranaut »

so I have three realy basic questions about the step involved in making custom buttons for the unit interface

1) are custom buttons made with widgets? or gadgets? or a combo of both?

2) how do I make the newly created button show up or get attached to the unit interface?

3) can you make buttons show up durring first person mode?

thank you for your time :)
Voidranaut
Posts: 47
Joined: 20 Dec 2009, 21:16

Re: Simple Button Questions

Post by Voidranaut »

local cmdDescID = Spring.FindUnitCmdDesc(unitID, morphDef.cmd)
if (cmdDescID) then
Spring.EditUnitCmdDesc(unitID, cmdDescID, morphCmdDesc)
else
Spring.InsertUnitCmdDesc(unitID, morphCmdDesc)
end

** from what I can tell this code above is whats responcible for adding the button to a units menue... is that right? or am I all turned around on my lua commands?

and is there anything odd I should know about adding the the units commands array? like is it possible to have it added only to be overidden by one of the orginal commands buttons?
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Simple Button Questions

Post by Forboding Angel »

./me points at "Lua Forum"
SkyStar
Engines Of War Developer
Posts: 23
Joined: 08 Jul 2009, 15:05

Re: Simple Button Questions

Post by SkyStar »

I'd actually like to know this aswell...
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6241
Joined: 29 Apr 2005, 01:14

Re: Simple Button Questions

Post by FLOZi »

1. True buttons, gadgets.
2. See your second post
3. Not true buttons, no. You could fake your own buttons though, bypassing the UnitCmdDesc stuff. Of course in FPS mode you don't have a cursor...
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Simple Button Questions

Post by lurker »

If you're using up to date code you can make real buttons in widgets.
SkyStar
Engines Of War Developer
Posts: 23
Joined: 08 Jul 2009, 15:05

Re: Simple Button Questions

Post by SkyStar »

Any examples you can give us? I can't find another widget that makes buttons, to find out how.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Simple Button Questions

Post by lurker »

Retreat makes buttons, I don't know if there are any simple ones. Maybe mex placer?
The question is whether the layout.lua packed with spring is fully up to date or if you need the one from ca.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Simple Button Questions

Post by Google_Frog »

Here's how I figured out how to add buttons with a widget; I took CarRepairer's retreat widget and deleted things which looked unnecessary until the buttons stopped appearing.

There's probably a better way of adding buttons and a way to do it without CA Layout.
Attachments
ca_layout.lua
(11.54 KiB) Downloaded 117 times
cmd_add_command_minimal.lua
(1.19 KiB) Downloaded 119 times
User avatar
Caydr
Omnidouche
Posts: 7179
Joined: 16 Oct 2004, 19:40

Re: Simple Button Questions

Post by Caydr »

I think someone referred me to this file ages ago but I obviously never found the right one.

Is there a list somewhere of all the default CMDs?

[CMD.STOP]=true, [CMD.GUARD]=true, [CMD.WAIT]=true,
[CMD.REPAIR]=true, [CMD.RECLAIM]=true,
[CMD.AISELECT]=true, [CMD.SELFD]=true, [CMD.AUTOREPAIRLEVEL]=false,
[CMD.MOVE]=true, [CMD.PATROL]=true, [CMD.FIGHT]=true,
[CMD.ATTACK]=true, [CMD.DGUN]=true,

etc.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Simple Button Questions

Post by Google_Frog »

Post Reply

Return to “Lua Scripts”