How to save object's skin state, broadcast the skin change?

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

gl0om
Posts: 54
Joined: 30 Mar 2010, 17:39

How to save object's skin state, broadcast the skin change?

Postby gl0om » 14 Jun 2010, 14:14

Is it possible to broadcast event of changing object's skin? I mean clicking on lamp to switch the light on or off. It would be great to broadcast this event to other clients inside room. And also it'd be great to save lamp's state in database whether it turned on or off. And then load lamp's state for new avatars inside the room.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 14 Jun 2010, 17:07

Of course this can't be an out-of-the-box feature, as everyone would need to broadcast something different, but you can do it on your own, by sending a message to the extension, save the state to the db and send an extension response to all the users on the same map, so that they can change the lamp state. Also, you will need to retrieve the current state from the db as soon as the map is rendered, and update the state of its objects accordingly.
Paolo Bax
The SmartFoxServer Team
gl0om
Posts: 54
Joined: 30 Mar 2010, 17:39

Postby gl0om » 14 Jun 2010, 20:29

What should I use as unique ID of our "lamp"? Does "ix" value from map's json data can be used as a key to store in db? I'm afraid that ix value may be changed after editing the map.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 14 Jun 2010, 21:55

D0n't know what ix is. Anyway you can give the lamp an instance name, or use its map coordinates.
Paolo Bax
The SmartFoxServer Team
gl0om
Posts: 54
Joined: 30 Mar 2010, 17:39

Postby gl0om » 15 Jun 2010, 05:53

I don't know what ix is too, but I found it in json object during saving the map. It looks something like {"ix":131,"ii":"lamp2","i":"t54"}
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 16 Jun 2010, 13:17

Oh yes, that's the item position on the map, expressed as a single number instead of the x,y,z coordinates
Paolo Bax
The SmartFoxServer Team
User avatar
svizzari
Posts: 64
Joined: 18 Jun 2010, 11:55

Postby svizzari » 15 Jul 2010, 00:29

Hey Bax -- How is that 'ix' value derived? From the px, py and pz values? How would I go about replicating that value on the client-side?

Thanks
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 15 Jul 2010, 07:23

Code: Select all

ix = px + (py * mapWidth) + (pz * mapWidth * mapHeight)
Paolo Bax
The SmartFoxServer Team
User avatar
svizzari
Posts: 64
Joined: 18 Jun 2010, 11:55

Postby svizzari » 15 Jul 2010, 07:29

Great, thanks for the quick reply

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 10 guests