Difference between revisions of "Removing "Placeatme Objects""

Jump to navigation Jump to search
update of old text
imported>Elder
m
imported>GuidoBot
(update of old text)
Line 2: Line 2:




This is to overcome the issues removing items placed in the game in 3D.
This describes how to remove objects created by the PlaceAtMe command, given that the Disable method is now known to only hide objects in their 3D state. (It does not seem to hide them if they are in your inventory.
The Disable method removes these objects while the player is not in the same Cell but they are saved (and reloaded) when the player moves back, even though you wouldn't know.


In the first example it is assumed that your placer item is just that, i.e. just there to be used as a marker for targetting or such.
 
In the first example it is assumed that your placer item is an inventory item put down, for whatever reason, and then later deleted ''within the same frame''.




Example #1: effect in external script (not on PlaceAtMe object)
Example #1: effect in external script (not on PlaceAtMe object)


scn MyScript
ref placerRef
Begin GameMode ; or other
; destruction - after in inventory
if placerRef
  if GetContainer == player
    placerRef.RemoveMe
  endif
  Return
endif
  ; creation
  ; creation
  set placerRef to player.PlaceAtMe MyPlacer 1 50 0
  set placerRef to player.PlaceAtMe MyPlacer 1 50 0
  ; ...
  ; destruction
  ; ... more code here
  ; destruction - put into player inventory
  placerRef.Activate player
  placerRef.Activate player
  placerRef.RemoveMe        ; safe only for un-scripted items
   
End


If you do Activate followed directly by RemoveMe it will work but any attached script will not be transferred. As stated on the CS Wiki you should ensure a frame click happens. In fact this is not appear to be actually necessary - you can achieve the same effect by having another script do the RemoveMe for you - it's just that the current script has to return.
Note: If you supply a container/actor argument to [b]RemoveMe[/b] it may work but any attached script will be lost. It seems some operations take a frame or two to work, especially those that attach one object to another. (Removing a script from an object could be useful.)


In the following examples the same effect will work for scripted objects.




Line 71: Line 86:


With all these examples you are well advised to experiment to see what works for you. It's possible that longer scripts may need some extra work, especially if you are using stackable items.
With all these examples you are well advised to experiment to see what works for you. It's possible that longer scripts may need some extra work, especially if you are using stackable items.
Ok, what I forgot to mention is the message spam you get when you get when the player picks this item up. To avoid this you can use a ''shadow'' (disabled persistant actor at player location) to pick up the item instead of the player.




Line 86: Line 104:
a) copy/create the base actor model that you wish to employ and/or a persistant reference copy in a hidden room.
a) copy/create the base actor model that you wish to employ and/or a persistant reference copy in a hidden room.


b) set critterRef to MyCritter.CreateFullActorCopy
b) set critterRef to MyCritter.CreateFullActorCopy ; takes several frames


c) critterRef.MoveTo player 50 50 0  (if necessary - may require next frame)
c) critterRef.MoveTo player 50 50 0  ; immediate but only logical position


d) critterRef.DeleteFullActorCopy    (when done)
d) critterRef.DeleteFullActorCopy    ; when done


[[category: Useful_Code]]
[[category: Useful_Code]]
Anonymous user

Navigation menu