Difference between revisions of "Talk:PlaceAtMe - ObjectReference"
imported>Fg109 (answered question) |
imported>Terra Nova2 m |
||
(9 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
== Return Value == | |||
Where do you get the last created ObjectReference returned value ? | Where do you get the last created ObjectReference returned value ? | ||
Line 17: | Line 18: | ||
:<source lang = "papyrus">Horker.Delete()</source> | :<source lang = "papyrus">Horker.Delete()</source> | ||
:In order for a reference to actually be [[Delete_-_ObjectReference|deleted]], it must be a reference created at run-time, disabled, and [[Persistence_(Papyrus)|non-persistent]]. If that's not what you are asking, then I am not understanding your question. --[[User:Fg109|Fg109]] 10:31, 20 May 2012 (EDT) | :In order for a reference to actually be [[Delete_-_ObjectReference|deleted]], it must be a reference created at run-time, disabled, and [[Persistence_(Papyrus)|non-persistent]]. If that's not what you are asking, then I am not understanding your question. --[[User:Fg109|Fg109]] 10:31, 20 May 2012 (EDT) | ||
: | |||
:Thank you very much for the answer, it helped a lot . Just one last precision i would like to know : about '''run-time''', do you mean Skyrim run-time or the object containing the script's runtime, or the event run-time ? | |||
:(Let's say, for instance , I want to create a button that places an actor at the player's position and delete the previously created actor.) --[[User:Programmeurenforce|Programmeurenforce]] 02:29, 21 May 2012 (EDT) | |||
::By '''run-time''', I mean Skyrim run-time. The object has to be created inside the game, not in the Creation Kit. --[[User:Fg109|Fg109]] 16:39, 21 May 2012 (EDT) | |||
:::Thank you again. (And by "The object has to be created", you mean the reference of it, and not the base object, I guess. Not that I know a way to create a new object during skyrim run-time, but...) --[[User:Programmeurenforce|Programmeurenforce]] 06:02, 23 May 2012 (EDT) | |||
This function '''creates copies of the base object''' at run-time. That is what is meant by the object has to be created at run-time in order to be deleted. --[[User:Terra Nova2|Terra Nova2]] ([[User talk:Terra Nova2|talk]]) 2014-12-02T17:59:01 (EST) | |||
== Cast created reference to the script attached to the form sometimes work, sometime won't == | |||
I have a new form MyCustomObject (tested with books and containers) which has a script attached to it MyCustomObjectScript. I try to do the following in order to call a function from the script on the created object: | |||
(myActor.placeAtMe(MyCustomObject) as MyCustomObjectScript) | |||
This sometimes works, sometime it won't and the cast returns None. | |||
If I try to print: | |||
<source lang = "papyrus"> | |||
ObjectReference myRef = myActor.placeAtMe(MyCustomObject) | |||
Debug.Notification("Ref "+myRef) | |||
Debug.Notification("Casted "+myRef as MyCustomObjectScript) | |||
</source> | |||
it sometimes print "Ref [ObectReference" and "Casted None" and sometimes "Ref [MyCustomObjectScript" and "Casted [MyCustomObjectScript" with no apparent logic when which of those situations happens. Any thoughts? [[User:LukeH|LukeH]] ([[User talk:LukeH|talk]]) 04:51, 1 October 2012 (EDT) | |||
== Garbage Collection == | |||
I was under the impression that many types of reference (for example, Explosions) will automatically have their references recycled once they're no longer in use. As such, it's not necessary to manually delete all references created via this function. I don't know if there's good documentation anywhere of how this garbage collection works, though. | |||
-- [[User:Cipscis|Cipscis]] ([[User talk:Cipscis|talk]]) 21:57, 29 October 2012 (EDT) | |||
:I'm not sure about it. If you look at active magic effects for example, by the time OnEffectFinish is triggered the underlying object has been indeed disposed (at least something similar since you can no longer native functions such as UnregisterForUpdate on them for example). However the papyrus-side of this object still exists and you can still call scripted methods and retrieve the member fields' values. So I guess we still need to mark objects for deletion manually. Anyway, in doubt, it's better to do it than feel sorry. Now it would be interesting to ask SmkViper. | |||
:--[[User:Perdev|Perdev]] ([[User talk:Perdev|talk]]) 22:07, 29 October 2012 (EDT) |
Latest revision as of 17:59, 2 December 2014
Return Value[edit source]
Where do you get the last created ObjectReference returned value ?
For example in :
ObjectReference Horker = Game.GetPlayer().PlaceAtMe(Game.GetForm(0x00023ab1))
Do you get it in "Horker" ? Can i use it for Actor based functions ?
For example; if i want to delete the previously created ObjectReference, can i use the IsDead() function then the Delete() function or do i need to get the references from another event ?
(Sorry if my question is not apropriate here , or if it is not clear, feel free to delete it)
--Instead of changing the world, let's change ourselfs 04:39, 19 May 2012 (EDT)
- The reference to the created horker would be stored in the object reference variable "Horker". If you want to delete the created horker, you use
Horker.Delete()
- In order for a reference to actually be deleted, it must be a reference created at run-time, disabled, and non-persistent. If that's not what you are asking, then I am not understanding your question. --Fg109 10:31, 20 May 2012 (EDT)
- Thank you very much for the answer, it helped a lot . Just one last precision i would like to know : about run-time, do you mean Skyrim run-time or the object containing the script's runtime, or the event run-time ?
- (Let's say, for instance , I want to create a button that places an actor at the player's position and delete the previously created actor.) --Programmeurenforce 02:29, 21 May 2012 (EDT)
- By run-time, I mean Skyrim run-time. The object has to be created inside the game, not in the Creation Kit. --Fg109 16:39, 21 May 2012 (EDT)
- Thank you again. (And by "The object has to be created", you mean the reference of it, and not the base object, I guess. Not that I know a way to create a new object during skyrim run-time, but...) --Programmeurenforce 06:02, 23 May 2012 (EDT)
- By run-time, I mean Skyrim run-time. The object has to be created inside the game, not in the Creation Kit. --Fg109 16:39, 21 May 2012 (EDT)
This function creates copies of the base object at run-time. That is what is meant by the object has to be created at run-time in order to be deleted. --Terra Nova2 (talk) 2014-12-02T17:59:01 (EST)
Cast created reference to the script attached to the form sometimes work, sometime won't[edit source]
I have a new form MyCustomObject (tested with books and containers) which has a script attached to it MyCustomObjectScript. I try to do the following in order to call a function from the script on the created object: (myActor.placeAtMe(MyCustomObject) as MyCustomObjectScript) This sometimes works, sometime it won't and the cast returns None. If I try to print:
ObjectReference myRef = myActor.placeAtMe(MyCustomObject)
Debug.Notification("Ref "+myRef)
Debug.Notification("Casted "+myRef as MyCustomObjectScript)
it sometimes print "Ref [ObectReference" and "Casted None" and sometimes "Ref [MyCustomObjectScript" and "Casted [MyCustomObjectScript" with no apparent logic when which of those situations happens. Any thoughts? LukeH (talk) 04:51, 1 October 2012 (EDT)
Garbage Collection[edit source]
I was under the impression that many types of reference (for example, Explosions) will automatically have their references recycled once they're no longer in use. As such, it's not necessary to manually delete all references created via this function. I don't know if there's good documentation anywhere of how this garbage collection works, though.
-- Cipscis (talk) 21:57, 29 October 2012 (EDT)
- I'm not sure about it. If you look at active magic effects for example, by the time OnEffectFinish is triggered the underlying object has been indeed disposed (at least something similar since you can no longer native functions such as UnregisterForUpdate on them for example). However the papyrus-side of this object still exists and you can still call scripted methods and retrieve the member fields' values. So I guess we still need to mark objects for deletion manually. Anyway, in doubt, it's better to do it than feel sorry. Now it would be interesting to ask SmkViper.
- --Perdev (talk) 22:07, 29 October 2012 (EDT)