Example scripts with iup now depend on auxlib.lua

This commit is contained in:
qfox 2008-08-02 22:54:58 +00:00
parent 2784fc9bb4
commit 27b510df3f
3 changed files with 4 additions and 71 deletions

View File

@ -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;"}};

View File

@ -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;

View File

@ -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