Help understanding si_path_run_usecode

NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Forum rules
NOTICE: This forum is archived as read only.
Please use the Github Discussions at https://github.com/exult/exult/discussions
Locked
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Help understanding si_path_run_usecode

Post 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
Malignant Manor
Site Admin
Posts: 985
Joined: Thu May 14, 2020 1:34 pm

Re: Help understanding si_path_run_usecode

Post 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.
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Help understanding si_path_run_usecode

Post 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]].
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Help understanding si_path_run_usecode

Post by marzo »

Exult will can usecode function [...]
Oops... that should have been "call". I will correct the documentation...
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Help understanding si_path_run_usecode

Post 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?
marzo
Site Admin
Posts: 1925
Joined: Thu May 14, 2020 1:34 pm

Re: Help understanding si_path_run_usecode

Post by marzo »

Yes. It is already in the Exult CVS and in my website.
------
Marzo Sette Torres Junior
aka Geometrodynamic Dragon
[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
Donfrow
Posts: 308
Joined: Thu May 14, 2020 1:34 pm

Re: Help understanding si_path_run_usecode

Post by Donfrow »

Alright, at least I know I didn't imagine it.
Locked