GameMonkey Script

GameMonkey Script Forums
It is currently Wed Nov 14, 2018 11:48 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun May 16, 2010 10:51 am 
Offline

Joined: Fri Jul 24, 2009 1:09 pm
Posts: 27
Hey.

I'm trying to return a table from C++ containing x and y coordinates as integers, but I'm getting this error:
Quote:
getdot failed.

unknown(0) :

callstack..

0: __unknown


Here is my C++ GM function:
Code:
int GM_CDECL get_event_object_position(gmThread* a_thread)
{
    GM_CHECK_NUM_PARAMS(1);
    GM_CHECK_STRING_PARAM(event_object_id, 0);

    Event_Object* event_object(Level_Manager::Get().Get_Current_Level()->Event_Object_At(event_object_id));

    if(event_object)
    {
        PointI pos(event_object->Get_Position());

        gmTableObject* table(a_thread->PushNewTable());
        table->Set(&GM_Machine::Get(), "x", gmVariable(pos.x));
        table->Set(&GM_Machine::Get(), "y", gmVariable(pos.y));
    }
    else
    {
        LOG(std::string("Warning: Could not find an event object with the id of \"") +
            event_object_id + "\"" + " in get_event_object_position.");
    }

    return GM_OK;
}


Here is my GM script:
Code:
global on_level_triggered = function(event_object_id)
{
       //set_event_object_animation(event_object_id, `fountain`);
       play_event_object_animation(event_object_id, `fountain`);
       this_pos = table(get_event_object_position(event_object_id));
       
       play_positional_sound(`Audio\\running_water.wav`, 10, 0, this_pos.x, this_pos.y);
};


Anyone know why this is happening? I can't find much help through searching for this topic.

Cheers.


Top
 Profile  
Reply with quote  
PostPosted: Sun May 16, 2010 10:55 am 
Offline

Joined: Fri Jul 24, 2009 1:09 pm
Posts: 27
Ok I've fixed this. It turns out I didn't have to construct a table object in the GM script.

I've now got a new problem though, in that I can't do this:
Code:
print_log(this_pos.x.String());


without getting this error:
Quote:
attempt to call non function type


print_log is just a C++ GM function that takes a string as the parameter.

Cheers.


Top
 Profile  
Reply with quote  
PostPosted: Sun May 16, 2010 2:24 pm 
Offline

Joined: Mon Dec 15, 2003 1:38 pm
Posts: 707
Not too many ideas from looking at just that last bit of code.
Try testing each part of the statement in question to narrow down the problem.
eg. print_log("hello")
eg. check validity and type for this_pos, this_pos.x
Are the extra type bindings registered? String() from an int/float is not part of the core files.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group