SphereCommunity
How to reference the spawn item - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: How to reference the spawn item (/Thread-How-to-reference-the-spawn-item)



How to reference the spawn item - Gil Amarth - 11-25-2014 06:38 PM

Is it possible to reference the spawn items through his spawned items?

For example, if I have a item spawn generator (a spawngem with t_spawn_item), which spawns some reagents.
Can I know the uid of the spawner through the reagents?

I have tried with foritems, but if the spawn gem is too far away, it is a bit expensive in resources for the server. There is a better way?

Thanks in advance.


RE: How to reference the spawn item - darksun84 - 11-25-2014 11:39 PM

While characters do have the spawnitem property, items don't have it.

So an alternative to foritems, could be to use lastnewitem property of the server object, a tag and the @timer trigger of t_spawn_item.
Code:
[TYPEDEF t_spawn_item]
ON=@Timer
ref1 = <serv.lastnewitem>
ref1.tag.spawnSource = <uid> //hold the uid of the spawner

Maybe this alternative is a risky one, i don't know if <serv.lastnewitem> is reliable when a lot of item will be created in a live server !

Best way will be to ask to put spawnitem property for items too Tongue

Edit : I notice that if the spawnable item is stackable, assigning a tag in this way will cause an error (because it got stacked, so the uid will be changed i think)


RE: How to reference the spawn item - Gil Amarth - 11-26-2014 01:45 AM

If some dev can put a spawnitem property for items, I would eternally gratefull to him. xD

I will try your solution, darksun84, is a bit risky for my taste. But if something goes wrong, I have only to remove this tag from all items of the world.

The stack problem dont bother me, because I only need the tag for collecting herbs, removing the tag when you pick them, so no problem for this side.