Page 1 of 1

Help understanding si_path_run_usecode

Posted: Wed Nov 21, 2007 2:06 pm
by Donfrow
As I keep fiddling around with more and more usecode I keep running into things I don't quite understand. The current one being the breakdown of si_path_run_usecode.

My understanding is it will path the avatar/npc to the location given and execute the function that is given.

However, I don't quite understand a couple of the values in the intrinsic.

UI_si_path_run_usecode(actor npc, int pos[], int event, object obj, function fun, bool flag)

What is an event ID and the object obj?

I've been trying to make the avatar walk up to a chimney when it's double clicked on using this intrinsic, by getting the location of it when it is clicked on, and having the avatar approach it and say something like "This is a chimney".

If my function to use when the avatar reaches the destination is called AvatarSpeak, I would start to fill in the instrinsic thusly:

UI_si_path_run_usecode(AVATAR, [loc[1], loc[2], loc[3]], ???, ???, AvatarSpeak, true)

Which, whether or not the avatar reaches the position or not would still run AvatarSpeak (due to the flag being True).

However, I'm not sure what I'm supposed to put in where the ??? are.

Is the object obj supposed to be the item that was double clicked (in this example the chimney) or something else entirely?

Thanks

Re: Help understanding si_path_run_usecode

Posted: Wed Nov 21, 2007 2:30 pm
by Malignant Manor
Event is the usual DOUBLECLICK, SCRIPTED, etc. It shouldn't really matter the number if you don't specify one in the function you refer to.

Basically from what I understand, object obj is where you specify what the item is in a script that says

Script item
{
}


Quote from similar function above it:

Exult will can usecode function 'fun', with 'obj' as 'item' and 'event' as the event ID.

Re: Help understanding si_path_run_usecode

Posted: Wed Nov 21, 2007 2:45 pm
by marzo
Take this as an example:

Code: Select all

UI_si_path_run_usecode(IOLO, loc, DOUBLECLICK, DUPRE, DrinkBeer, true)
Suppose that the DrinkBeer function includes the following code:

Code: Select all

DrinkBeer object#() ()
{
    if (event == DOUBLECLICK)
        item.say("Burp!");
}
Then, the UI_si_path_run_usecode call above will make Iolo try to walk to the location loc, and it will call the 'DrinkBeer' with event equal to DOUBLECLICK, so that Dupre will say "Burp!".

And by the way: since loc is already an array, you don't have to pass it as [loc[1], loc[2], loc[3]].

Re: Help understanding si_path_run_usecode

Posted: Wed Nov 21, 2007 2:46 pm
by marzo
Exult will can usecode function [...]
Oops... that should have been "call". I will correct the documentation...

Re: Help understanding si_path_run_usecode

Posted: Wed Nov 21, 2007 3:44 pm
by Donfrow
Ah ha. Makes sense now, I think :P

Up until now I've just been using it to path but now I got it to actually call my function when the avatar gets there. My Avatar can now go down a chimney (as much as you can using these graphics)!

Thanks for the help, yet again.

By the way, did you get rid of the note about si_path_run_usecode being un-interruptible and replace it with the note about calling the avatar freeze?

Re: Help understanding si_path_run_usecode

Posted: Wed Nov 21, 2007 5:18 pm
by marzo
Yes. It is already in the Exult CVS and in my website.

Re: Help understanding si_path_run_usecode

Posted: Wed Nov 21, 2007 6:01 pm
by Donfrow
Alright, at least I know I didn't imagine it.

Fatal: Not able to open ./cache/production/data_global.php