Added script files and cmake install script for them

develop
Warmist 2011-07-28 04:22:15 +03:00
parent 6c2a822494
commit 5f729ffc0f
5 changed files with 125 additions and 0 deletions

@ -11,6 +11,7 @@ if(LUA51_FOUND)
) )
DFHACK_PLUGIN(dfusion ${DFUSION_CPPS_ALL}) DFHACK_PLUGIN(dfusion ${DFUSION_CPPS_ALL})
target_link_libraries(dfusion ${LUA_LIBRARIES}) target_link_libraries(dfusion ${LUA_LIBRARIES})
install(DIRECTORY luafiles/ DESTINATION ${DFHACK_DATA_DESTINATION}/dfusion)
else(LUA51_FOUND) else(LUA51_FOUND)
MESSAGE(STATUS "Required libraries (lua51) not found - dfusion plugin can't be built.") MESSAGE(STATUS "Required libraries (lua51) not found - dfusion plugin can't be built.")
endif(LUA51_FOUND) endif(LUA51_FOUND)

@ -0,0 +1,61 @@
offsets=offsets or {}
offsets._toff={}
offsets.get = function (name)
return offsets._toff[name]
end
offsets.getEx = function (name)
return offsets._toff[name]+Process.getBase()
end
offsets.load = function ()
local f=io.open("dfusion/offsets.txt")
local line=f:read()
while line~=nil do
--print(line)
local sppliter=string.find(line,":")
offsets._toff[string.sub(line,1,sppliter-2)]=tonumber(string.sub(line,sppliter+2))
line=f:read()
end
end
offsets.load()
function unlockDF()
local ranges=Process.getMemRanges()
for k,v in pairs(ranges) do
--for k2,v2 in pairs(v) do
-- print(string.format("%d %s->%s",k,tostring(k2),tostring(v2)))
--end
--local num
--num=0
--if(v["read"])then num=num+1 end
--if(v["write"])then num=num+10 end
--if(v["execute"]) then num=num+100 end
--print(string.format("%d %x->%x %s %d",k,v["start"],v["end"],v.name,num))
local pos=string.find(v.name,".text")
if pos~=nil then
v["write"]=true
Process.setPermisions(v,v)
end
end
end
function lockDF()
local ranges=Process.getMemRanges()
for k,v in pairs(ranges) do
--for k2,v2 in pairs(v) do
-- print(string.format("%d %s->%s",k,tostring(k2),tostring(v2)))
--end
--local num
--num=0
--if(v["read"])then num=num+1 end
--if(v["write"])then num=num+10 end
--if(v["execute"]) then num=num+100 end
--print(string.format("%d %x->%x %s %d",k,v["start"],v["end"],v.name,num))
local pos=string.find(v.name,".text")
if pos~=nil then
v["write"]=false
Process.setPermisions(v,v)
end
end
end
-- engine bindings
engine=engine or {}
engine.peekd=Process.readDWord
engine.poked=Process.writeDWord

@ -0,0 +1,33 @@
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
dofile("dfusion/common.lua")
print("Unlocking Df .text section...")
unlockDF()
print("Done unlock")
lockDF()
dofile("dfusion/simple_embark/plugin.lua")
print("hello world")
Console.print("Hello world in console!\n")
--name=Console.lineedit("Enter name:")
--Console.print("Your name is:"..name)
function OnTick() -- floods the console
r=Console.get_rows()
c=Console.get_columns()
Console.clear()
Console.gotoxy(math.random(1,r),math.random(1,2))
Console.color(math.random(0,15))
Console.print("*")
end
OnTick=nil

@ -0,0 +1,15 @@
AdvCreatureVec : 0x12c44ac
CreatureGloss : 0x1308040
CreaturePtr : 0xaf2430
CreatureVec : 0x12c44ac
CurrentRace : 0x10f0c28
Items : 0x12c4550
Legends : 0x12c451c
Materials : 0x1307f50
PlayerLegend : 0x145bfec
SiteData : 0x1307778
StartDwarfs : 0x518332
WordVec : 0x1308254
WorldData : 0x1306148
Xpointer : 0x7347f0
vtableLegends : 0x6e7594

@ -0,0 +1,15 @@
function simple_embark(num)
stoff=offsets.getEx('StartDwarfs')
print("Starting dwarves found:"..engine.peekd(stoff))
engine.poked(stoff,num)
end
if not(FILE) then
print("Type in new ammount:")
repeat
ans=tonumber(io.read())
if ans==nil or not(ans<=15000 and ans>0) then
print("incorrect choice")
end
until ans~=nil and (ans<=15000 and ans>0)
simple_embark(ans)
end