Hi
A very basic question that has had me stumped all day. First up, I'm not a c++ person, just plain C, so all the object oriented stuff is beyond me. I do have Angelscript working with my game engine, and I can call scripts from the host, and call C functions from the scripts - all working fine.
I now have a need to pass a std::string type from the host program to the script.
The script is written like this
// This function is called when a object is clicked
void as_guiHandleButtonPress(string &in objectID)
//------------------------------------------------------------
{
sys_printConStr(objectID, "");
if (objectID == "buttonStartGame")
{
currentMode = MODE_GAME;
}}
I can create the function mapping ok - I get a valid ID back ( this from my logfile )
scriptFunctions [ void as_guiHandleButtonPress(string &in) ] has ID [ 44977616 ]
I think my problem is here - I can't work out how to pass the string as a parameter:
if (scriptFunctions[i].param1 == true)
{
string testParam;
strcpy(testParam.c_str(), funcParam); // Convert from char to string type
io_logToFile("Parameter to pass to script [ %s ]", testParam.c_str());
// Has the right string "buttonStartGame"
context->SetArgObject(0, &testParam);
}
This is my output
Parameter to pass to script [ buttonStartGame ]
[ ] [ ]
Any advice would be welcomed.
Thanks.