Page 1 of 1

Openspace items

Posted: 26 Jan 2009, 01:05
by olliepop
Ok, this is a bit off support but it is still quite important.
How on earth would i setup items in openspace?

For example:
user steps on tile with item on it
user clicks tile again
item is added to inventory

how would the item be displayed on the map, and how would clicking on the tile activate the event to add the item to the inventory?

thanks :?

Posted: 26 Jan 2009, 14:27
by Bax
I suppose you also want to make the item disappear from the map, so no one else can collect it.
This is the difficult part, as OpenSpace doesn't have this feature out of the box.
I won't describe how to make an object clickable: check the Ranch example for this (when the avatar is in front of the doors, they become clickable).
As the map can't be modified at runtime, you have to use a trick: get a reference to the clicked item (which is a skin attached to a tile) and call a custom method to change its graphics (or a gotoAndStop an empty frame is enough maybe).
Now the most difficult part: you have to send a custom message to the other connected clients to tell them to make the same object disappear so no one can get it; also, you will have to save this info in the room variables, so that you can do the same when a new user enters the map where the object disappeared.
A possible issue is that two users click on the same object at the same time. You will probably need to validate the action on the server-side.

Posted: 26 Jan 2009, 22:59
by olliepop
thanks for your logic :)
the issue you arose however about two players clicking the same tile is quite a real one.. it could mean an item duplication cheat :s
so yes, i will have to do quite a bit of validation coding there to make sure only one copy of it can be taken.
unless i dont do items on the ground at all.. now thats an idea :idea:

Posted: 27 Jan 2009, 08:31
by nig3d
the only way to be sure that a given item is not taken twice is to write an extension.
There is no way to manage such a thing properly on client side.