vivanto Posted June 14, 2010 Share Posted June 14, 2010 Hi!I have a problem with scripting behavior. Last paragraph sums my question, rest is just situational explanation. In one of my - yet - experimental mods, I am trying to get the position of a dynamically placed object in the world that on it's creation is only accessible by its own script. Namely, I made a smoke (marker) grenade. On "explosion" I used a replacement object, that places an identical looking grenade with a working script (think it is an activator, or misc item, dosen't really matter). I need to get an xmarker to the exact same position of it. The problem is, that if I use getSelf and pass its own reference to a quest script for processing, then the grenade's own script stops working. Actually, it stops working for whatever reason if I use any reference based commands, like moveTo. The main idea was to .moveTo the xmarker to the grenade position via its own script, or a quest script, its irrelevant, since from that point on, I would be working with the xmarker as a persistent reference anyways with said quest script. As a workaround, I recorded and passed the grenade's position with ".getPos", used ".moveTo player" on the marker and adjusted its coordinates with ".setPos" to the earlier recorded ".getPos". The problem with this method is, that open worldspaces are made up by smaller cells. If the player is near the border of 2 such open world cells, and throws the grenade in border cell A, while he is standing in border cell B, then this completely screws up and the xmarker will be someplace else. I also tried using getDistance and getHeadingAngle and offsetting the player placement, but they gave false values as well. My assumption is, that reference calls can be only made on persistent references properly. So in short, is there any reliable workaround to record and move a persistent reference to a non-persistent reference position? Link to comment Share on other sites More sharing options...
Cipscis Posted June 23, 2010 Share Posted June 23, 2010 GetSelf returns 0 when called on a reference saved within the savegame (i.e. one that starts with "FF", like those created via PlaceAtMe), and calling reference functions on such a "null reference" will cause your script to halt. If you need to access a reference that you've created via PlaceAtMe, you can get its RefID by using the return value of PlaceAtMe. In order to make it globally available, you'll need to assign it to a variable in a quest script, or in an object script on a persistent reference with an EditorRefID, because global variables can't store RefIDs. Cipscis Link to comment Share on other sites More sharing options...
Recommended Posts