Hello!
I tried to add an action in c++. I'm using TFS 0.2.14
So I put this in actions.xml:
And in actions.h at the end I added toolAxe:
And in actions.cpp I added toolaxe in loadFunction:
And then I added a toolAxe function:
But when I try out the action I get this error:
I have no idea why. Even after staring at the code for quite some time! =P
Does somebody have any idea how I can solve this?
Thanks
Edit:
I found out it works if I change the itemid to something else. For some reason items which are used with crosshairs (like the axe) won't work. Does anyone know why?
I tried to add an action in c++. I'm using TFS 0.2.14
So I put this in actions.xml:
Code:
<action itemid="2559" function="toolAxe"/>
And in actions.h at the end I added toolAxe:
Code:
protected:
virtual std::string getScriptEventName();
static ActionFunction highscoreBook;
static ActionFunction increaseItemId;
static ActionFunction decreaseItemId;
static ActionFunction enterMarket;
static ActionFunction toolAxe;
And in actions.cpp I added toolaxe in loadFunction:
Code:
bool Action::loadFunction(const std::string& functionName)
{
std::string tmpFunctionName = asLowerCaseString(functionName);
if(tmpFunctionName == "increaseitemid")
function = increaseItemId;
else if(tmpFunctionName == "decreaseitemid")
function = decreaseItemId;
else if(tmpFunctionName == "highscorebook")
function = highscoreBook;
else if(tmpFunctionName == "market")
function = enterMarket;
else if(tmpFunctionName == "toolaxe")
function = toolAxe;
else
{
std::cout << "[Warning - Action::loadFunction] Function \"" << functionName << "\" does not exist." << std::endl;
return false;
}
m_scripted = false;
return true;
}
And then I added a toolAxe function:
Code:
bool Action::toolAxe(Player* player, Item* item, const PositionEx& posFrom, const PositionEx& posTo, bool extendedUse, uint32_t creatureId)
{
std::cout << "It's worknig!" << std::endl;
return true;
}
But when I try out the action I get this error:
Code:
Lua Script Error: [Action Interface]
(Unknown scriptfile)
attempt to call a nil value
stack traceback:
[C]: ?
I have no idea why. Even after staring at the code for quite some time! =P
Does somebody have any idea how I can solve this?
Thanks
Edit:
I found out it works if I change the itemid to something else. For some reason items which are used with crosshairs (like the axe) won't work. Does anyone know why?
Last edited: