Example scripts with iup now depend on auxlib.lua
This commit is contained in:
parent
2784fc9bb4
commit
27b510df3f
|
@ -1,40 +1,11 @@
|
||||||
-- BeeBee, LuaBot Frontend v1.07
|
-- BeeBee, LuaBot Frontend v1.07
|
||||||
-- qFox, 2 August 2008
|
-- qFox, 2 August 2008
|
||||||
|
|
||||||
-- we need iup, so include it here
|
-- we need iup, so include it here (also takes care of cleaning up dialog when script exits)
|
||||||
local iuplua_open = package.loadlib("iuplua51.dll", "iuplua_open");
|
require 'auxlib.lua';
|
||||||
iuplua_open();
|
|
||||||
local iupcontrolslua_open = package.loadlib("iupluacontrols51.dll", "iupcontrolslua_open");
|
|
||||||
iupcontrolslua_open();
|
|
||||||
|
|
||||||
local botVersion = 1; -- check this version when saving/loading. this will change whenever the botsave-file changes.
|
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 :)
|
function createTextareaTab(reftable, tmptable, token, tab, fun, val) -- specific one, at that :)
|
||||||
reftable[token] = iup.multiline{title="Contents",expand="YES", border="YES" }; -- ,value=val};
|
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;"}};
|
tmptable[token] = iup.vbox{iup.label{title="function "..fun.."()\n local result = no;"},reftable[token],iup.label{title=" return result;\nend;"}};
|
||||||
|
|
|
@ -7,38 +7,8 @@
|
||||||
-- It also displays the found hitboxes in a output window with iup
|
-- 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
|
-- Includes a toggle to automatically kill all enemies within 50px range of mario :p
|
||||||
|
|
||||||
-- we need iup, so include it here
|
-- Include our help script to load iup and take care of exit
|
||||||
local iuplua_open = package.loadlib("iuplua51.dll", "iuplua_open");
|
require("auxlib.lua");
|
||||||
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;
|
|
||||||
|
|
||||||
|
|
||||||
local running = true;
|
local running = true;
|
||||||
local restrainingorder = false;
|
local restrainingorder = false;
|
||||||
|
|
|
@ -2,14 +2,6 @@
|
||||||
-- Tetris (U) [!].rom
|
-- Tetris (U) [!].rom
|
||||||
-- qFox
|
-- 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
|
local function getPiece(n) -- returns table with information about this piece
|
||||||
-- every piece consists of 4 blocks
|
-- every piece consists of 4 blocks
|
||||||
-- so piece will contain the information about these blocks
|
-- so piece will contain the information about these blocks
|
||||||
|
|
Loading…
Reference in New Issue