Added ability to call dfuse as a hotkey.

E.g. calling dfuse "tools.empregnate()" now works.
develop
Warmist 2012-04-03 16:17:43 +03:00
parent 59d1971df1
commit 8e1d26ff97
5 changed files with 28 additions and 7 deletions

@ -8,6 +8,7 @@
#include "luamain.h"
#include "OutFile.h"
#include "functioncall.h"
#include "LuaTools.h"
namespace lua
{

@ -84,7 +84,15 @@ table.insert(plugins,{"saves","run current worlds's init.lua",RunSaved})
loadall(plugins)
dofile_silent("dfusion/initcustom.lua")
local args={...}
for k,v in pairs(args) do
local f,err=load(v)
if f then
f()
else
Console.printerr(err)
end
end
if not INIT then
mainmenu(plugins)
end

@ -8,7 +8,8 @@ if WINDOWS then --windows function defintions
onfunction.AddFunction(0x5af826+offsets.base(),"Hurt",{target="esi",attacker={off=0x74,rtype=DWORD,reg="esp"}})
onfunction.AddFunction(0x3D5886+offsets.base(),"Flip",{building="esi"})
onfunction.AddFunction(0x35E340+offsets.base(),"ItemCreate")--]=]
onfunction.AddFunction(4B34B6+offsets.base(),"ReactionFinish") --esp item. Ecx creature, edx?
--onfunction.AddFunction(0x4B34B6+offsets.base(),"ReactionFinish") --esp item. Ecx creature, edx? 0.34.07
onfunction.AddFunction(0x72aB6+offsets.base(),"Die",{creature="edi"}) --0.34.07
else --linux
--[=[onfunction.AddFunction(0x899befe+offsets.base(),"Move") -- found out by attaching watch...
onfunction.AddFunction(0x850eecd+offsets.base(),"Die",{creature="ebx"}) -- same--]=]

@ -1,8 +1,9 @@
mypos=engine.getmod("functions")
function DeathMsg(values)
local name
name=engine.peek(values[onfunction.hints["Die"].creature],ptt_dfstring)
print(name:getval().." died")
local u=engine.cast(df.unit,values[onfunction.hints["Die"].creature])
print(u.name.first_name.." died")
end
if mypos then
print("Onfunction already installed")

@ -151,8 +151,6 @@ static size_t __stdcall PushValue(size_t ret,uint32_t eax,uint32_t ebx,uint32_t
#endif
{
lua::state st=lua::glua::Get();
st.getglobal("err");
int perr=st.gettop();
st.getglobal("OnFunction");
if(st.is<lua::nil>())
return 0;
@ -175,7 +173,7 @@ static size_t __stdcall PushValue(size_t ret,uint32_t eax,uint32_t ebx,uint32_t
st.setfield("ebp");
st.push(ret);
st.setfield("ret");
st.pcall(1,1,perr);
DFHack::Lua::SafeCall(DFHack::Core::getInstance().getConsole(),st,1,1);
return st.as<uint32_t>();
}
static int Get_PushValue(lua_State *L)
@ -210,6 +208,17 @@ static int Resume_Df(lua_State *L)
DFHack::Core::getInstance().Resume();
return 0;
}
static int Cast(lua_State *L)
{
lua::state st(L);
if(DFHack::Lua::IsDFObject(st,1)!=DFHack::Lua::OBJ_TYPE)
st.error("First argument must be df type!");
if(!st.is<lua::number>(2)) //todo maybe lightuserdata?
st.error("Second argument must be pointer as a number!");
st.getfield("_identity",1);
DFHack::Lua::PushDFObject(st,(DFHack::type_identity*)lua_touserdata(st,-1),(void*)st.as<int>(2));
return 1;
}
const luaL_Reg lua_misc_func[]=
{
{"alloc",lua_malloc},
@ -224,6 +233,7 @@ const luaL_Reg lua_misc_func[]=
{"calldf",Call_Df},
{"suspend",Suspend_Df},
{"resume",Resume_Df},
{"cast",Cast},
{NULL,NULL}
};
void lua::RegisterMisc(lua::state &st)