Command blocks: Execute()
parent
be5299350a
commit
1ad6469a18
|
@ -14,6 +14,7 @@
|
||||||
#include "../WebAdmin.h"
|
#include "../WebAdmin.h"
|
||||||
#include "../ClientHandle.h"
|
#include "../ClientHandle.h"
|
||||||
#include "../BlockEntities/ChestEntity.h"
|
#include "../BlockEntities/ChestEntity.h"
|
||||||
|
#include "../BlockEntities/CommandBlockEntity.h"
|
||||||
#include "../BlockEntities/DispenserEntity.h"
|
#include "../BlockEntities/DispenserEntity.h"
|
||||||
#include "../BlockEntities/DropperEntity.h"
|
#include "../BlockEntities/DropperEntity.h"
|
||||||
#include "../BlockEntities/FurnaceEntity.h"
|
#include "../BlockEntities/FurnaceEntity.h"
|
||||||
|
@ -2273,6 +2274,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
|
||||||
tolua_function(tolua_S, "DoWithEntityByID", tolua_DoWithID< cWorld, cEntity, &cWorld::DoWithEntityByID>);
|
tolua_function(tolua_S, "DoWithEntityByID", tolua_DoWithID< cWorld, cEntity, &cWorld::DoWithEntityByID>);
|
||||||
tolua_function(tolua_S, "DoWithFurnaceAt", tolua_DoWithXYZ<cWorld, cFurnaceEntity, &cWorld::DoWithFurnaceAt>);
|
tolua_function(tolua_S, "DoWithFurnaceAt", tolua_DoWithXYZ<cWorld, cFurnaceEntity, &cWorld::DoWithFurnaceAt>);
|
||||||
tolua_function(tolua_S, "DoWithNoteBlockAt", tolua_DoWithXYZ<cWorld, cNoteEntity, &cWorld::DoWithNoteBlockAt>);
|
tolua_function(tolua_S, "DoWithNoteBlockAt", tolua_DoWithXYZ<cWorld, cNoteEntity, &cWorld::DoWithNoteBlockAt>);
|
||||||
|
tolua_function(tolua_S, "DoWithCommandBlockAt", tolua_DoWithXYZ<cWorld, cCommandBlockEntity, &cWorld::DoWithCommandBlockAt>);
|
||||||
tolua_function(tolua_S, "DoWithPlayer", tolua_DoWith< cWorld, cPlayer, &cWorld::DoWithPlayer>);
|
tolua_function(tolua_S, "DoWithPlayer", tolua_DoWith< cWorld, cPlayer, &cWorld::DoWithPlayer>);
|
||||||
tolua_function(tolua_S, "FindAndDoWithPlayer", tolua_DoWith< cWorld, cPlayer, &cWorld::FindAndDoWithPlayer>);
|
tolua_function(tolua_S, "FindAndDoWithPlayer", tolua_DoWith< cWorld, cPlayer, &cWorld::FindAndDoWithPlayer>);
|
||||||
tolua_function(tolua_S, "ForEachBlockEntityInChunk", tolua_ForEachInChunk<cWorld, cBlockEntity, &cWorld::ForEachBlockEntityInChunk>);
|
tolua_function(tolua_S, "ForEachBlockEntityInChunk", tolua_ForEachInChunk<cWorld, cBlockEntity, &cWorld::ForEachBlockEntityInChunk>);
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
#include "CommandBlockEntity.h"
|
#include "CommandBlockEntity.h"
|
||||||
#include "../Entities/Player.h"
|
#include "../Entities/Player.h"
|
||||||
|
|
||||||
|
#include "CommandOutput.h"
|
||||||
|
#include "Root.h"
|
||||||
|
#include "Server.h" // ExecuteConsoleCommand()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +49,8 @@ void cCommandBlockEntity::UsedBy(cPlayer * a_Player)
|
||||||
cWindow * Window = GetWindow();
|
cWindow * Window = GetWindow();
|
||||||
if (Window == NULL)
|
if (Window == NULL)
|
||||||
{
|
{
|
||||||
//OpenWindow(new cDropSpenserWindow(m_PosX, m_PosY, m_PosZ, this)); FIXME
|
// TODO 2014-01-18 xdot: Open the appropriate window.
|
||||||
|
// OpenWindow(new cCommandBlockWindow(m_PosX, m_PosY, m_PosZ, this));
|
||||||
Window = GetWindow();
|
Window = GetWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +69,7 @@ void cCommandBlockEntity::UsedBy(cPlayer * a_Player)
|
||||||
|
|
||||||
void cCommandBlockEntity::SetCommand(const AString & a_Cmd)
|
void cCommandBlockEntity::SetCommand(const AString & a_Cmd)
|
||||||
{
|
{
|
||||||
m_Command = a_Cmd;LOGD("Hrey %s", a_Cmd.c_str());
|
m_Command = a_Cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -190,11 +195,28 @@ void cCommandBlockEntity::SaveToJson(Json::Value & a_Value)
|
||||||
|
|
||||||
void cCommandBlockEntity::Execute()
|
void cCommandBlockEntity::Execute()
|
||||||
{
|
{
|
||||||
// TODO: Parse arguments and dispatch command
|
class CommandBlockOutCb :
|
||||||
|
public cCommandOutputCallback
|
||||||
|
{
|
||||||
|
cCommandBlockEntity* m_CmdBlock;
|
||||||
|
|
||||||
LOGD("Command: %s", m_Command.c_str());
|
public:
|
||||||
|
CommandBlockOutCb(cCommandBlockEntity* a_CmdBlock) : m_CmdBlock(a_CmdBlock) {}
|
||||||
|
|
||||||
m_LastOutput = "";
|
virtual void Out(const AString & a_Text)
|
||||||
|
{
|
||||||
|
ASSERT(m_CmdBlock != NULL);
|
||||||
|
|
||||||
|
// Overwrite field
|
||||||
|
m_CmdBlock->SetLastOutput(a_Text);
|
||||||
|
}
|
||||||
|
} CmdBlockOutCb(this);
|
||||||
|
|
||||||
|
cServer* Server = cRoot::Get()->GetServer();
|
||||||
|
|
||||||
|
Server->ExecuteConsoleCommand(m_Command, CmdBlockOutCb);
|
||||||
|
|
||||||
|
// TODO 2014-01-18 xdot: Update the signal strength.
|
||||||
m_Result = 0;
|
m_Result = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -469,7 +469,7 @@ public:
|
||||||
bool DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBlockCallback & a_Callback); // Exported in ManualBindings.cpp
|
bool DoWithNoteBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cNoteBlockCallback & a_Callback); // Exported in ManualBindings.cpp
|
||||||
|
|
||||||
/// Calls the callback for the command block at the specified coords; returns false if there's no command block at those coords or callback returns true, returns true if found
|
/// Calls the callback for the command block at the specified coords; returns false if there's no command block at those coords or callback returns true, returns true if found
|
||||||
bool DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCommandBlockCallback & a_Callback); // TODO: Export
|
bool DoWithCommandBlockAt(int a_BlockX, int a_BlockY, int a_BlockZ, cCommandBlockCallback & a_Callback); // Exported in ManualBindings.cpp
|
||||||
|
|
||||||
/// Retrieves the test on the sign at the specified coords; returns false if there's no sign at those coords, true if found
|
/// Retrieves the test on the sign at the specified coords; returns false if there's no sign at those coords, true if found
|
||||||
bool GetSignLines (int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); // Exported in ManualBindings.cpp
|
bool GetSignLines (int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4); // Exported in ManualBindings.cpp
|
||||||
|
|
|
@ -948,7 +948,7 @@ void cWSSAnvil::LoadCommandBlockFromNBT(cBlockEntityList & a_BlockEntities, cons
|
||||||
CmdBlock->SetLastOutput(a_NBT.GetString(currentLine));
|
CmdBlock->SetLastOutput(a_NBT.GetString(currentLine));
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: TrackOutput
|
// TODO 2014-01-18 xdot: Figure out what TrackOutput is and parse it.
|
||||||
|
|
||||||
a_BlockEntities.push_back(CmdBlock.release());
|
a_BlockEntities.push_back(CmdBlock.release());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue