diff --git a/documentation/lua/luabot_front.lua b/documentation/lua/luabot_front.lua index 717a7c08..87e236df 100644 --- a/documentation/lua/luabot_front.lua +++ b/documentation/lua/luabot_front.lua @@ -1,40 +1,11 @@ -- BeeBee, LuaBot Frontend v1.07 -- qFox, 2 August 2008 --- we need iup, so include it here -local iuplua_open = package.loadlib("iuplua51.dll", "iuplua_open"); -iuplua_open(); -local iupcontrolslua_open = package.loadlib("iupluacontrols51.dll", "iupcontrolslua_open"); -iupcontrolslua_open(); +-- we need iup, so include it here (also takes care of cleaning up dialog when script exits) +require 'auxlib.lua'; local botVersion = 1; -- check this version when saving/loading. this will change whenever the botsave-file changes. --- callback function to clean up our mess -function emu.OnClose.iuplua() - --iup.Message ("IupMessage", "OnClose!"); - if(emu and emu.OnCloseIup ~= nil) then - emu.OnCloseIup(); - end - iup.Close(); -end - -local handles = {}; -- this table should hold the handle to all dialogs created in lua -local dialogs = 0; -- should be incremented PRIOR to creating a new dialog --- called by the onclose event -function emu.OnCloseIup() - if (handles) then -- just in case the user was "smart" enough to clear this - local i = 1; - while (handles[i] ~= nil) do -- cycle through all handles, false handles are skipped, nil denotes the end - if (handles[i] and handles[i].destroy) then -- check for the existence of what we need - -- close this dialog - handles[i]:destroy(); - handles[i] = nil; - end; - i = i + 1; - end; - end; -end; - function createTextareaTab(reftable, tmptable, token, tab, fun, val) -- specific one, at that :) reftable[token] = iup.multiline{title="Contents",expand="YES", border="YES" }; -- ,value=val}; tmptable[token] = iup.vbox{iup.label{title="function "..fun.."()\n local result = no;"},reftable[token],iup.label{title=" return result;\nend;"}}; diff --git a/documentation/lua/smb1_iup.lua b/documentation/lua/smb1_iup.lua index 9a341cad..bf483f29 100644 --- a/documentation/lua/smb1_iup.lua +++ b/documentation/lua/smb1_iup.lua @@ -7,38 +7,8 @@ -- It also displays the found hitboxes in a output window with iup -- Includes a toggle to automatically kill all enemies within 50px range of mario :p --- we need iup, so include it here -local iuplua_open = package.loadlib("iuplua51.dll", "iuplua_open"); -iuplua_open(); -local iupcontrolslua_open = package.loadlib("iupluacontrols51.dll", "iupcontrolslua_open"); -iupcontrolslua_open(); - --- callback function to clean up our mess -function emu.OnClose.iuplua() - gui.popup("OnClose!"); - if(emu and emu.OnCloseIup ~= nil) then - emu.OnCloseIup(); - end - iup.Close(); -end - -local handles = {}; -- this table should hold the handle to all dialogs created in lua -local dialogs = 0; -- should be incremented PRIOR to creating a new dialog --- called by the onclose event -function emu.OnCloseIup() - if (handles) then -- just in case the user was "smart" enough to clear this - local i = 1; - while (handles[i] ~= nil) do -- cycle through all handles, false handles are skipped, nil denotes the end - if (handles[i] and handles[i].destroy) then -- check for the existence of what we need - -- close this dialog - handles[i]:destroy(); - handles[i] = nil; - end; - i = i + 1; - end; - end; -end; - +-- Include our help script to load iup and take care of exit +require("auxlib.lua"); local running = true; local restrainingorder = false; diff --git a/documentation/lua/tetris.lua b/documentation/lua/tetris.lua index 640bde3a..49b4af5c 100644 --- a/documentation/lua/tetris.lua +++ b/documentation/lua/tetris.lua @@ -2,14 +2,6 @@ -- Tetris (U) [!].rom -- qFox -local function realcount(t) -- accurately count the number of elements of a table, even if they contain nil values. not fast, but accurate. - local n = 0; - for i,_ in pairs(t) do - n = n + 1; - end; - return n; -end; - local function getPiece(n) -- returns table with information about this piece -- every piece consists of 4 blocks -- so piece will contain the information about these blocks