Chili:Tutorial Command and Build Commands

From Spring
Revision as of 18:50, 26 June 2011 by Sunspot (talk | contribs)
Jump to navigationJump to search

Commands and Build bar

Preparation

We are stepping it up a notch. We can all agree that the stock GUI for commands and building isn't really all that great. Good thing is we can improve on this. Following is not a perfect sollution since it doesn't handle pagination, but it will get you a long way getting you started for advanced stuff. For this tutorial you will only need one lua script but it will have quite a bit of content.

 
- LuaUI\widgets\gui_chili_commandwindow.lua

File header

You open up with the regular info and imports that you are going to use thru the script.

[code][pre] function widget:GetInfo() return { name = "command list window", desc = "ChiliUi window that contains all the commands a unit has", author = "Sunspot", date = "2011-06-15", license = "GNU GPL v2", layer = math.huge, enabled = true, handler = true, } end -- INCLUDES VFS.Include("LuaRules/Gadgets/Includes/utilities.lua")

-- CONSTANTS local MAXBUTTONSONROW = 4 local COMMANDSTOEXCLUDE = {"TimeWait","DeathWait","SquadWait","GatherWait","Load units"} local Chili local Button local Window local Image local Control

-- MEMBERS local x local y local commandWindow local stateCommandWindow local buildCommandWindow local updateRequired = true

-- CONTROLS local spGetActiveCommand = Spring.GetActiveCommand local spGetActiveCmdDesc = Spring.GetActiveCmdDesc local spGetSelectedUnits = Spring.GetSelectedUnits local spSendCommands = Spring.SendCommands [/pre][/code]

You'll notice a lot of variables and controls. They will all get a place during the further script design and explained in detail.