I saw some posts where people use "self" variable to get the attached items, so my first attempt was :
Scriptname BookScript extends ObjectReferenceevent onRead();doing stuffGame.GetPlayer().removeItem(self, 1)endEvent
But it doesn't work, the book was not removed.
At first, I thought the problem was because we can't remove the item attached to the running script, so I tried to use "addItem", but it didn't work too.
I also tried to use self.GetBaseObject() with no luck.
However, if I use a property instead, and set the attached book manually, everything work well :
Scriptname BookScript extends ObjectReferencebook Property testbook autoevent onRead();doing stuffGame.GetPlayer().removeItem(testbook, 1)endEvent
So, it seem that the "self" object didn't work like I expected, to verify it, I put this code in the script :
Scriptname BookScript extends ObjectReferencebook Property testbook autoevent onRead()debug.notification ("self : " + self.GetBaseObject())debug.notification ("self only : " + self)debug.notification ("property :" + testbook)endEventTested in game and notifications are :self : none
self only : [BookScript
property : [Book
The "self" variable refer to the script itself ([bookscript), and not the attached book ([book), so it's explain why it doesn't work.
Anyway, some people seem to successfully use the self variable to get the attached item, so I think I made a mistake somewhere...
Any help on this ?
