Page 1 of 1

Usecode for a door?

Posted: Sat Mar 01, 2003 2:00 pm
by Karlos
I'm trying to figure out how to create Usecode for simple objects like doors so they open and close. I think I have the general idea; I just need a few specifics. Specifically, how do I find out the frame number of an object whose Usecode function was invoked, and how do i change the displayed frame of that object.

Also, I want to confirm that I have the right idea of how to create the code for the object. I assume it would be something like the following:

horizontal_door 0x1B0
{
if( event == 0 )
{
// Nothing
return;
}
else if( event != 1)
return;
if( [frame is closed door] )
[set frame to open door]
else if( [frame is open door] )
[set frame to closed door]
.
.
.
etc (add code for locked doors, magically-locked doors, and so on)
}



-Karl

Re: Usecode for a door?

Posted: Sat Mar 01, 2003 8:04 pm
by drcode
Yes, that's right. But you can leave out the first test, and just start with:

if (event != 1)
return;

Note that you can store the current frame in a variable, something like:

var doorframe = UI_get_frame(item);

Re: Usecode for a door?

Posted: Sun Mar 02, 2003 3:45 am
by Karlos
When I try this, I get the following error when compiling the usecode:

usecode.uc:35: 'UI_get_frame' not declared

Also, how do I set the current frame of the object? Something like UI_set_frame( item, frame# )?

Finally, is there a list of valid API calls like this anywhere? There a re a number of them that I can use as examples in the usecode for the island patch, but these two at least aren't in there. I understand that the docs aren't done yet, so even a source file that has prototypes for the API calls would be good enough.


-Karl

Re: Usecode for a door?

Posted: Sun Mar 02, 2003 3:58 am
by wjp
The function is UI_get_item_frame (and UI_set_item_frame)

The list of intrinsics is in the exult source in usecode/siintrinsics.h. (You need to prepend UI_ to use it with ucc)

Unfortunately this doesn't say which parameters they take. For that you could take a look in usecode/intrinsics.cc, where some are commented with the calling syntax.

Re: Usecode for a door?

Posted: Sun Mar 02, 2003 4:23 am
by Karlos
Thanks; that will help a lot. It also explains why I wasn't able to find it myself by doing a recursive grep for UI_* in the exult source tree. :-)


-Karl