simple_embark/plugin.lua sanitized

develop
Warmist 2012-08-30 20:41:10 +03:00
parent 6b7594dbd7
commit 90021b4e5e
3 changed files with 15 additions and 14 deletions

@ -1,11 +1,7 @@
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)
return safecall(f)
else
print(perr)
end
@ -13,7 +9,7 @@ end
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)
return safecall(f)
else
if(string.sub(perr,1,11)~="cannot open") then --ugly hack
print(perr)
@ -26,7 +22,6 @@ function loadall(t1) --loads all non interactive plugin parts, so that later the
end
end
function mainmenu(t1)
while true do
print("No. Name Desc")
for k,v in pairs(t1) do
@ -58,7 +53,7 @@ dofile("dfusion/common.lua")
dofile("dfusion/utils.lua")
dofile("dfusion/offsets_misc.lua")
dofile("dfusion/editor.lua")
--dofile("dfusion/xml_struct.lua")
unlockDF()
plugins={}
table.insert(plugins,{"simple_embark","A simple embark dwarf count editor"})

@ -1,10 +1,18 @@
function simple_embark(num)
stoff=VersionInfo.getAddress('start_dwarf_count')
print("Starting dwarves found:"..engine.peekd(stoff))
engine.poked(stoff,num)
local stoff=dfhack.internal.getAddress('start_dwarf_count')
print("Starting dwarves found:"..df.reinterpret_cast('int32_t', stoff).value)
local tmp_val=df.new('int32_t')
local size,pos=tmp_val:sizeof()
tmp_val.value=num
local ret=dfhack.internal.patchMemory(stoff,tmp_val,size)
if ret then
print("Success!")
else
qerror("Failed to patch in number")
end
end
if not(FILE) then
print("Type in new ammount:")
print("Type in new ammount (more than 6, less than 15000):")
repeat
ans=tonumber(io.read())
if ans==nil or not(ans<=15000 and ans>0) then

@ -10,5 +10,3 @@ Similar to dfusion but not interactive. To be used with hotkeys (later will have
Also dfuse/dfusion runs an init script located at 'save directory/dfusion/init.lua'. And 'initcustom.lua' if it exists
More info http://dwarffortresswiki.org/index.php/Utility:DFusion
a