Typelib / contained and exec

Farvardin
27 Sept 2003, 10:06
I've made an action for an object, it's "use sugar on cauldron"


a part of the code is :

use <sugar> {
msg <You put the sugar in the cauldron.>
lose <sugar>
conceal <sugar>
flag on <caul_sugar>
if flag <caul_sugar> and flag <cauld_flames> then do <cook>>
}


But this command is not really natural, so I wanted also to include parts of the TypeLib that can handle containers.


	define object <sugar>
take
prefix <some>
type <TLTobject>
type <TLTcontainable>
properties <onTable; edible; size=0.020; weight=0.5; tooBig=This doesn't fit here.>
action <contained> exec <use sugar on cauldron; normal >


The problem is now when I type "put sugar in cauldron" the sugar disappear from my object list and I get :
"you don't have that", and nothing more happens.

I used a procedure to replace the exec command so now it's ok, but is it normal it doesn't work in the previous code ?

Anonymous
27 Sept 2003, 14:17
Hi

The fact you are getting the 'You don't have that' message leads me to suspect that the problem lies in the way you have set up the sugar and the cauldron objects, but there is not enough code given here to tell.

For example - Have you made the cauldron a container?

If you set the objects up correctly, your 'contained' action ought to work just fine.

Al (MaDbRiT)

Anonymous
27 Sept 2003, 14:26
Whoops! brain failure from me there..

I dislike USE myself, so I'm not sure about this, but I think in order to "use" something, you have to be holding it, or it must be present in the room.

Having just become 'contained' inside a container the object would neither be present in the room nor in the player's posession, so 'You don't have that' actually makes sense in a perverse way (you must have just put it inside something - or the 'contained' action wouldn't be run!).

A bit of a rework is called for, you can use some of typelib's functions to check the availability of contained objects, not just carried and present ones.

Al (MaDbRiT)

Farvardin
27 Sept 2003, 19:39
Yes, I 've made the cauldron a container.
I tried also to take the cauldron before doing the action.

But I understand now : when I do this action, it remove the sugar from my list to put it into the cauldron. Then it tries to execute the action to use sugar and such, but it's no longer in my hands... I should have thought to it. I thought also it would override the "put" action in your lib...
But with a procedure instead it works fine.

Btw I notice now it's strange it works with a procedure, because this procedure is exactly the same code I used when one type "use sugar on cauldron", so it seems do <procedure> will override your library, while a exec <code> won't.