Advertisement

Can't set second argument when using SetArgObject

Started by February 15, 2022 09:56 PM
3 comments, last by WitchLord 2 years, 9 months ago

I had a working solution with a single function with the signature ‘string command_processor(string)’, to which I added a second parameter (int), which created the following sequence of SetArg calls:

app.asContext->SetArgObject(0, (void*) &message);

app.asContext->SetArgAddress(1, &format);

Now however I get an error when I execute the script:

---

(0, 0) : ERR : Failed in call to function 'Execute' (Code: asCONTEXT_NOT_PREPARED, -4)

---

When I comment out the ‘SetArgAddress’ line, it works again. I have also used setArgDWord, SetArgByte, etc. (without taking the address, obvs), but with the same result. ‘format’ is a uint8_t type on the C++ side.

Any clues as to what I'm doing wrong here would be most helpful.

I have worked around this issue by adding a second function to the script which passes the string object on, along with the second, integer, parameter set to a specific value.

Advertisement

Well, int is not the same as uint8_t, they are 32 bit and 8 bit respectively, so setting the argument by address is already wrong.

Try using SetArgDWord instead, where you don't have to pass a pointer to the argument.

Interesting that you get asCONTEXT_NOT_PREPARED though - are you saying you are correctly preparing the context before you set the arguments and execute the function?

Yes, I have prepared the context as mentioned. The only thing I changed was to add that second argument to the function, and to try to pass the uint8_t as the value. I have also use SetArgDWord, SetArgByte and others as mentioned, but all with the same result.

Casting the uint8_t to an int or similar made no difference either. It felt as though simply having a second call to a SetArg function was enough to somehow undo the context preparation, or cause some other internal fault.

Can you show the code you have for getting the script function and preparing the context?

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement