Synced Script GadgetHandler

Synced Script GadgetHandler

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

Moderator: Moderators

Post Reply
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Synced Script GadgetHandler

Post by trepan »

I've ported the widgetHandler LuaUI code so that it can be used in
synced scripts. To make it easier to tell the two types of code apart,
I've used the name "gadgets".

Here is a simple example:
http://trepan.homelinux.net/spring/shar ... allies.lua

To use the gadgetHandler, all you'll have to do is:
include('LuaRules/gadgets.lua')
in LuaRules/main.lua (actually, that will probably be the entire
contents of the file). You will also have to do the same for
LuaRules/draw.lua if you want gadgets used with the unsynced
part of the code.

You can keep the synced and unsynced code in the same gadget
source file by using the gadgetHandler:IsSyncedCode() to separate
them into functional blocks. I'll probably post an example of how this
can be done once I get some more calls tested.

The code currently loads all gadget files in the LuaRules/Gadgets
directory. The is no graphical selector interface for enabling/disabling
them (it would mess with the synced code to do so directly). It is
possible to do it indirectly (/say .luarules ... would work).
Post Reply

Return to “Lua Scripts”