1
0

Added cRoot:GetFurnaceFuelBurnTime() to Lua API.

This commit is contained in:
madmaxoft 2013-11-22 16:50:03 +01:00
parent 14569885e5
commit 281bf8f90b
5 changed files with 67 additions and 3 deletions

View File

@ -49,6 +49,7 @@ function Initialize(Plugin)
PM:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp");
PM:BindCommand("/fill", "debuggers", HandleFill, "- Fills all block entities in current chunk with junk");
PM:BindCommand("/fr", "debuggers", HandleFurnaceRecipe, "- Shows the furnace recipe for the currently held item");
PM:BindCommand("/ff", "debuggers", HandleFurnaceFuel, "- Shows how long the currently held item would burn in a furnace");
-- Enable the following line for BlockArea / Generator interface testing:
-- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED);
@ -907,7 +908,7 @@ end
function HandleFurnaceRecipe(a_Split, a_Player)
local HeldItem = a_Player:GetEquippedItem();
local Out, NumTicks, In = cRoot.GetFurnaceRecipe(HeldItem);
local Out, NumTicks, In = cRoot:GetFurnaceRecipe(HeldItem);
if (Out ~= nil) then
a_Player:SendMessage(
"Furnace turns " .. ItemToFullString(In) ..
@ -924,3 +925,21 @@ end
function HandleFurnaceFuel(a_Split, a_Player)
local HeldItem = a_Player:GetEquippedItem();
local NumTicks = cRoot:GetFurnaceFuelBurnTime(HeldItem);
if (NumTicks > 0) then
a_Player:SendMessage(
ItemToFullString(HeldItem) .. " would power a furnace for " .. NumTicks ..
" ticks (" .. tostring(NumTicks / 20) .. " seconds)."
);
else
a_Player:SendMessage(ItemToString(HeldItem) .. " will not power furnaces.");
end
return true;
end

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 11/22/13 11:58:39.
** Generated automatically by tolua++-1.0.92 on 11/22/13 16:24:50.
*/
#ifndef __cplusplus
@ -19714,6 +19714,36 @@ static int tolua_AllToLua_cRoot_GetCraftingRecipes00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
/* method: GetFurnaceFuelBurnTime of class cRoot */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_GetFurnaceFuelBurnTime00
static int tolua_AllToLua_cRoot_GetFurnaceFuelBurnTime00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"cRoot",0,&tolua_err) ||
(tolua_isvaluenil(tolua_S,2,&tolua_err) || !tolua_isusertype(tolua_S,2,"const cItem",0,&tolua_err)) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
const cItem* a_Fuel = ((const cItem*) tolua_tousertype(tolua_S,2,0));
{
int tolua_ret = (int) cRoot::GetFurnaceFuelBurnTime(*a_Fuel);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'GetFurnaceFuelBurnTime'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: GetWebAdmin of class cRoot */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cRoot_GetWebAdmin00
static int tolua_AllToLua_cRoot_GetWebAdmin00(lua_State* tolua_S)
@ -31093,6 +31123,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"SetPrimaryServerVersion",tolua_AllToLua_cRoot_SetPrimaryServerVersion00);
tolua_function(tolua_S,"GetGroupManager",tolua_AllToLua_cRoot_GetGroupManager00);
tolua_function(tolua_S,"GetCraftingRecipes",tolua_AllToLua_cRoot_GetCraftingRecipes00);
tolua_function(tolua_S,"GetFurnaceFuelBurnTime",tolua_AllToLua_cRoot_GetFurnaceFuelBurnTime00);
tolua_function(tolua_S,"GetWebAdmin",tolua_AllToLua_cRoot_GetWebAdmin00);
tolua_function(tolua_S,"GetPluginManager",tolua_AllToLua_cRoot_GetPluginManager00);
tolua_function(tolua_S,"QueueExecuteConsoleCommand",tolua_AllToLua_cRoot_QueueExecuteConsoleCommand00);

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 11/22/13 11:58:39.
** Generated automatically by tolua++-1.0.92 on 11/22/13 16:24:51.
*/
/* Exported function */

View File

@ -742,3 +742,13 @@ void cRoot::LogChunkStats(cCommandOutputCallback & a_Output)
int cRoot::GetFurnaceFuelBurnTime(const cItem & a_Fuel)
{
cFurnaceRecipe * FR = Get()->GetFurnaceRecipe();
return FR->GetBurnTime(a_Fuel);
}

View File

@ -57,6 +57,10 @@ public:
cGroupManager * GetGroupManager (void) { return m_GroupManager; } // tolua_export
cCraftingRecipes * GetCraftingRecipes(void) { return m_CraftingRecipes; } // tolua_export
cFurnaceRecipe * GetFurnaceRecipe (void) { return m_FurnaceRecipe; } // Exported in ManualBindings.cpp with quite a different signature
/// Returns the number of ticks for how long the item would fuel a furnace. Returns zero if not a fuel
static int GetFurnaceFuelBurnTime(const cItem & a_Fuel); // tolua_export
cWebAdmin * GetWebAdmin (void) { return m_WebAdmin; } // tolua_export
cPluginManager * GetPluginManager (void) { return m_PluginManager; } // tolua_export
cAuthenticator & GetAuthenticator (void) { return m_Authenticator; }