Updating inventory verbs

The Pixie
Objects have lists associated with them called displayverbs and inventoryverbs. If you change these during a game, the UI should update to reflect the change. This seems tobe fine with the desk top version, but not with the web player. Adding a new verb is fine, but if you try to remove a verb that is currently showing, it stays there, and only gets removed when you go elsewhere.

Is there a way to force this tio update?

Quantus
This is the exact same issue I'm currently dealing with. Is this still an issue with the Web player? Or is there now code to fix this?

As a work around, I have found that you can remove/add the object a certain way, which works, but it will deselect the object in your inventory. The other option is to create two objects and swap them out on the fly, but that also deselects the object. This is only an issue with the web version.

The Pixie
I have just tried this with an on-line game and it works okay for me. Can you give any more details of what you are trying to do? i just did this:
list remove (ball.displayverbs, "Bounce")

Quantus
The Pixie wrote:I have just tried this with an on-line game and it works okay for me. Can you give any more details of what you are trying to do? i just did this:
list remove (ball.displayverbs, "Bounce")


On the web version, I created an object called basketball. I set it to verb take. In the inventory I set a verb called dribble. After you click dribble its supposed to remove the verb and replace it with shoot. Which it does, but only if you drop the ball by typing the command, and use the verb Take to put the ball back in the inventory. It will show shoot instead of dribble. This is just an example, but this same scenario and code works fine on the pc version.

The Pixie
That is pretty much what I did, and it worked okay for me. You can play it here:
http://textadventures.co.uk/games/view/ ... nline-test

Is it dependent on the computer or browser? I amn using Firefox on Win7.

Quantus
Whats the balls verb supposed to change too? In the panes i do not see a change when i click bounce.

It also says 'I dont understand your command' when i click it.

The Pixie
Bounce does not do anything, but it should disappear when you JUMP.

Quantus
I think my problem might be happening because the verb removes itself when you click it. I might need to have two verbs instead of trying to set it up to toggle.

Quantus
Im now getting this error:

Error running script: Cannot modify the contents of this list as it is defined by an inherited type. Clone it before attempting to modify.

jaynabonne
To fix that, simply assign the list attribute to itself before you attempt to modify it (as strange as that might sound). Writing the list attribute makes a copy you can then do things to.

Quantus
jaynabonne wrote:To fix that, simply assign the list attribute to itself before you attempt to modify it (as strange as that might sound). Writing the list attribute makes a copy you can then do things to.


Trying to understand this. Seems like I read something about it before on another thread.

jaynabonne
When you have an object of a type that has a list attribute, all the objects of that type share the same attribute until the attribute gets rewritten on a per-object basis. Until it's been rewritten, the attribute is shared and so is not able to be modified - otherwise, you'd change the attribute for every object sharing it. And when a list gets assigned to an object's attribute, a *copy* of the list is assigned, not the original. (I ran into this once where I assigned a list to an attribute and then added members to my local copy of the list, and it didn't add to the attribute, since the attribute was a copy.)

So, long story short, if you assign an object's list attribute to itself, then it actually assigns a copy of the original type-based list, and then your object has a unique copy of the list it can modify.

The Pixie
You can also add a verb and then remove it for the object in the editor (or remove a verb and put it back). That also sets the list as an attribute on the object, rather than an inherited attribute.

Quantus
The Pixie wrote:You can also add a verb and then remove it for the object in the editor (or remove a verb and put it back). That also sets the list as an attribute on the object, rather than an inherited attribute.


If you could change your example to add the verb 'bounce' when you jump instead, that would be what I need.

Quantus
I basically have it working the way a I want now. I did have to add/remove the inventory verb using 'inventoryverbs' instead of 'displayverbs' at the beginning of the game script. Then, in order to get the verb to 'add' I had to remove the item from the inventory, and run a script after .01 seconds to put it back into the inventory. It works fine this way, and it 'adds' perfectly. It happens so fast there is not any notice of item having been removed and added back to the inventory.

The Pixie
Here it is working as you require:

http://textadventures.co.uk/games/view/ ... nline-test

I could not get it to work using list add, I had to replace the whole list (which would also solve the "Cannot modify the contents of this list as it is defined by an inherited type" error).
ball.displayverbs = Split("Look at,Take,Bounce", ",")

I have updated the thread in the libraries forum to reflect this issue, thanks for bringing it up.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums