Last active
September 4, 2020 10:17
-
-
Save d-lua-stuff/771505a417353f08c4341af58740d3c7 to your computer and use it in GitHub Desktop.
wrap.lua input file example. See https://board.dualthegame.com/index.php?/topic/20161-lua-tool-script-packagerconfigurator-wraplua/ for more info.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Define a global script object with event handlers | |
script = {} | |
function script.onStart () | |
-- Display some text | |
screen.setCenteredText("script started") | |
-- Create some timers to show that the script is working | |
unit.setTimer("a", 2) -- timer id "a", ticks every 2 seconds | |
unit.setTimer("b", 3) -- timer id "b", ticks every 3 seconds | |
end | |
function script.onStop () | |
screen.setCenteredText("script stopped") | |
end | |
function script.onActionStart (actionName) | |
screen.setCenteredText(actionName .. " key pressed") | |
end | |
function script.onActionStop (actionName) | |
screen.setCenteredText(actionName .. " key released") | |
end | |
function script.onTick (timerId) | |
screen.setCenteredText("timer " .. timerId .. " ticked") | |
end | |
-- Other events that are available by default: | |
-- * onActionLoop(actionName): action key is held | |
-- * onUpdate(): executed once per frame | |
-- * onFlush(): executed 60 times per second, for physics calculations only; setEngineCommand must be called from here | |
-- Slot events are available if slot type is set with the --slot command line option. | |
function script.onMouseDown (x, y) | |
screen.setCenteredText("mouse down: x=" .. x .. " , y=" .. y) | |
end | |
-- Call the start event handler | |
-- Alternatively, initialization code can be placed anywhere in this file. | |
-- The only requirement is that there is a global "script" object with event handlers | |
script.onStart() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment