Difference between revisions of "Creating plugins"
From Bitfighter
Watusimoto (Talk | contribs) |
Watusimoto (Talk | contribs) |
||
Line 9: | Line 9: | ||
TextEntryMenuItem:new("Text here", "start", "Empty", 20, "Enter your text") -- Display Value, starting text, empty string, length, help | TextEntryMenuItem:new("Text here", "start", "Empty", 20, "Enter your text") -- Display Value, starting text, empty string, length, help | ||
− | To create a menu, you must create a function in your script called | + | To create a menu, you must create a function in your script called getArgsMenu(). That should return something like this: |
<source lang="lua"> | <source lang="lua"> | ||
-- Standard plugin method for building a menu to get parameters | -- Standard plugin method for building a menu to get parameters | ||
− | function | + | function getArgsMenu() |
local menuItem1 = CounterMenuItem:new(...) -- Note the use of ':', NOT '.' | local menuItem1 = CounterMenuItem:new(...) -- Note the use of ':', NOT '.' | ||
local menuItem2 = YesNoMenuItem:new(...) | local menuItem2 = YesNoMenuItem:new(...) |
Revision as of 23:08, 27 December 2011
Starting with version 016, it is possible to create editor plugins with Lua. These plugins are currently fairly limited in functionality, but will be expanded in the future. Plugins are basically Lua scripts that generate items (much like a levelgen script does), and inserts them in the editor.
It is possible for the plugin to create a menu to get input from the user. There are currently 4 different menu widgets that can be added to a menu:
CounterMenuItem:new("Angle", 90, 1, 0, 360, "deg.", "Disabled", "Sweep of arc", "Help me!"), -- Name, value, step, min, max, units, minmsg, text, intvalue, ToggleMenuItem:new("Toggleable", {"First", "Second", "Third"}, 1, false, "Pick one!"), -- Name, choices, selected index, wrap, help YesNoMenuItem:new("Hello",2,"Pick one"), -- Name, selected index (1 = no, 2 = yes), help string TextEntryMenuItem:new("Text here", "start", "Empty", 20, "Enter your text") -- Display Value, starting text, empty string, length, help
To create a menu, you must create a function in your script called getArgsMenu(). That should return something like this:
-- Standard plugin method for building a menu to get parameters function getArgsMenu() local menuItem1 = CounterMenuItem:new(...) -- Note the use of ':', NOT '.' local menuItem2 = YesNoMenuItem:new(...) local menuItem3 = TextEntryMenuItem:new(...) return "Menu Title", { menuItem1, menuItem2, menuItem3 } end