2012-04-01 02:50:56 -06:00
|
|
|
Console.print = dfhack.print
|
|
|
|
Console.println = dfhack.println
|
|
|
|
Console.printerr = dfhack.printerr
|
|
|
|
|
2011-07-27 19:22:15 -06:00
|
|
|
function err(msg) --make local maybe...
|
|
|
|
print(msg)
|
|
|
|
print(debug.traceback())
|
|
|
|
end
|
|
|
|
function dofile(filename) --safer dofile, with traceback (very usefull)
|
|
|
|
f,perr=loadfile(filename)
|
|
|
|
if f~=nil then
|
|
|
|
return xpcall(f,err)
|
|
|
|
else
|
|
|
|
print(perr)
|
|
|
|
end
|
|
|
|
end
|
2011-08-20 15:15:40 -06:00
|
|
|
function dofile_silent(filename) --safer dofile, with traceback, no file not found error
|
|
|
|
f,perr=loadfile(filename)
|
|
|
|
if f~=nil then
|
|
|
|
return xpcall(f,err)
|
2012-03-31 03:12:16 -06:00
|
|
|
else
|
|
|
|
if(string.sub(perr,1,11)~="cannot open") then --ugly hack
|
|
|
|
print(perr)
|
|
|
|
end
|
2011-08-20 15:15:40 -06:00
|
|
|
end
|
|
|
|
end
|
|
|
|
function loadall(t1) --loads all non interactive plugin parts, so that later they could be used
|
|
|
|
for k,v in pairs(t1) do
|
|
|
|
dofile_silent("dfusion/"..v[1].."/init.lua")
|
|
|
|
end
|
|
|
|
end
|
2011-08-03 08:59:06 -06:00
|
|
|
function mainmenu(t1)
|
2011-09-17 05:59:10 -06:00
|
|
|
--Console.clear()
|
2011-08-03 08:59:06 -06:00
|
|
|
while true do
|
2011-08-19 10:12:25 -06:00
|
|
|
print("No. Name Desc")
|
2011-08-03 08:59:06 -06:00
|
|
|
for k,v in pairs(t1) do
|
2011-08-19 10:12:25 -06:00
|
|
|
print(string.format("%3d %15s %s",k,v[1],v[2]))
|
2011-08-03 08:59:06 -06:00
|
|
|
end
|
|
|
|
local q=Console.lineedit("Select plugin to run (q to quit):")
|
|
|
|
if q=='q' then return end
|
|
|
|
q=tonumber(q)
|
|
|
|
if q~=nil then
|
|
|
|
if q>=1 and q<=#t1 then
|
2012-03-17 07:05:48 -06:00
|
|
|
if t1[q][3]==nil then
|
|
|
|
dofile("dfusion/"..t1[q][1].."/plugin.lua")
|
|
|
|
else
|
|
|
|
t1[q][3]()
|
|
|
|
end
|
2011-08-03 08:59:06 -06:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-07-27 19:22:15 -06:00
|
|
|
end
|
2012-03-18 08:23:31 -06:00
|
|
|
function RunSaved()
|
|
|
|
print("Locating saves...")
|
2012-03-24 17:16:41 -06:00
|
|
|
local str=df.global.world.cur_savegame.save_dir
|
2012-03-18 08:23:31 -06:00
|
|
|
print("Current region:"..str)
|
|
|
|
str="data/save/"..str.."/dfusion/init.lua"
|
|
|
|
print("Trying to run:"..str)
|
|
|
|
dofile_silent(str)
|
|
|
|
end
|
2011-08-03 08:59:06 -06:00
|
|
|
dofile("dfusion/common.lua")
|
2011-12-18 07:58:34 -07:00
|
|
|
dofile("dfusion/utils.lua")
|
2012-03-17 07:05:48 -06:00
|
|
|
dofile("dfusion/offsets_misc.lua")
|
|
|
|
dofile("dfusion/editor.lua")
|
2012-03-24 06:47:51 -06:00
|
|
|
--dofile("dfusion/xml_struct.lua")
|
2011-08-03 08:59:06 -06:00
|
|
|
unlockDF()
|
|
|
|
plugins={}
|
2012-03-24 17:31:58 -06:00
|
|
|
table.insert(plugins,{"simple_embark","A simple embark dwarf count editor"})
|
2012-03-25 02:48:53 -06:00
|
|
|
table.insert(plugins,{"tools","some misc tools"})
|
2012-03-24 17:31:58 -06:00
|
|
|
table.insert(plugins,{"embark","Multi race embark"})
|
2011-08-04 15:22:25 -06:00
|
|
|
table.insert(plugins,{"friendship","Multi race fort enabler"})
|
2012-03-17 16:50:47 -06:00
|
|
|
--[=[table.insert(plugins,{"items","A collection of item hacking tools"})
|
|
|
|
table.insert(plugins,{"offsets","Find all offsets"})
|
|
|
|
|
2011-12-12 11:25:37 -07:00
|
|
|
table.insert(plugins,{"friendship_civ","Multi civ fort enabler"})
|
2012-04-03 17:06:35 -06:00
|
|
|
|
2012-03-17 16:50:47 -06:00
|
|
|
|
2011-08-04 15:44:56 -06:00
|
|
|
table.insert(plugins,{"triggers","a function calling plug (discontinued...)"})
|
|
|
|
table.insert(plugins,{"migrants","multi race imigrations"})
|
2012-03-23 03:07:54 -06:00
|
|
|
--]=]
|
2012-03-24 17:16:41 -06:00
|
|
|
--table.insert(plugins,{"onfunction","run lua on some df function"})
|
|
|
|
--table.insert(plugins,{"editor","edit internals of df",EditDF})
|
2012-03-17 19:02:16 -06:00
|
|
|
table.insert(plugins,{"saves","run current worlds's init.lua",RunSaved})
|
2012-04-03 17:06:35 -06:00
|
|
|
table.insert(plugins,{"adv_tools","some tools for (mainly) advneturer hacking"})
|
2011-08-20 15:15:40 -06:00
|
|
|
loadall(plugins)
|
2011-12-10 17:28:15 -07:00
|
|
|
dofile_silent("dfusion/initcustom.lua")
|
2011-12-12 11:25:37 -07:00
|
|
|
|
2012-04-03 07:17:43 -06:00
|
|
|
local args={...}
|
2012-04-15 04:32:25 -06:00
|
|
|
|
|
|
|
|
|
|
|
local f,err=load(table.concat(args,' '))
|
|
|
|
if f then
|
|
|
|
f()
|
|
|
|
else
|
|
|
|
Console.printerr(err)
|
2012-04-03 07:17:43 -06:00
|
|
|
end
|
2012-04-15 04:32:25 -06:00
|
|
|
|
2011-08-20 15:15:40 -06:00
|
|
|
if not INIT then
|
2011-08-03 08:59:06 -06:00
|
|
|
mainmenu(plugins)
|
2011-08-20 15:15:40 -06:00
|
|
|
end
|
2011-08-03 08:59:06 -06:00
|
|
|
|