Oblis Posted October 2, 2012 Share Posted October 2, 2012 (edited) Hello,I have created a spell that will place an item to the player. I made it this way (and not using additem) in order to give the item a reference.The item is placed properly and it gives me the coordinates at the current point.The following spell script works just fine: ScriptName NPCSummonLocationItemSpellScript ref LocationObject float PosX float PosY float PosZ float PlayerPosX float PlayerPosY float PlayerPosZ float ObjectOnAir Begin ScriptEffectStart set PlayerPosZ to Player.GetPos Z ;Setting a reference to a placed object. set LocationObject to Player.placeatme NPCDecorationLocationTrigger 1,20,0 ;These line will make the item appear always over ground. set PlayerPosZ to Player.GetPos Z set ObjectOnAir to (PlayerPosZ + 50) LocationObject.SetPos Z ObjectOnAir ;These line will get the item current position using the reference i got. set PosX to LocationObject.GetPos X set PosY to LocationObject.GetPos Y set PosZ to LocationObject.GetPos Z ;Message for tracking PrintToConsole "GameModeObject: %0.f, %0.f, %0.f" PosX PosY PosZ end But I want to get the coordinates to other points tooand I want this item to produce the coordinates at (game mode) or when it (moved or dropped).Thats why i created the following script: ScriptName NPCDecorationLocationScript ref Object ref LocationObject float ObjectLocationPosX float ObjectLocationPosY float ObjectLocationPosZ Begin GameMode Set ObjectLocationPosX to LocationObject.GetPos X Set ObjectLocationPosY to LocationObject.GetPos Y Set ObjectLocationPosZ to LocationObject.GetPos Z PrintToConsole "Coordinations: %0.f, %0.f, %0.f" ObjectLocationPosX ObjectLocationPosY ObjectLocationPosZ End but it gives me always 0,0,0 even if the object is staying at the same position as it fell and produced the coordinates.It doesnt work properly. What i have done wrong to the second script?How it can be done? Edited October 2, 2012 by Oblis Link to comment Share on other sites More sharing options...
Maskar Posted October 2, 2012 Share Posted October 2, 2012 I don't really understand what you're doing, but the reference you get from PlaceAtMe is only temporary. It's unlikely you want to use PlaceAtMe for this though. Can't you just check the location of GetSelf with a script on the item? Link to comment Share on other sites More sharing options...
Oblis Posted October 2, 2012 Author Share Posted October 2, 2012 I don't really understand what you're doing, but the reference you get from PlaceAtMe is only temporary. It's unlikely you want to use PlaceAtMe for this though. Can't you just check the location of GetSelf with a script on the item? I make something a misc item working like compass. Where the item is moved the console prints the coordinates. (I dont want to do this on player)With a persistent item everything would be perfect, but when it is added in inv it loses it persistent attibute.That was cool with PlaceAtMe that allowed me to use the item as tesporarly persistent.GetSelf gives bad results (if it worked there would be no problem) Link to comment Share on other sites More sharing options...
Maskar Posted October 2, 2012 Share Posted October 2, 2012 (edited) GetSelf works fine for me, but to create a persistent reference you could simply move the item to a newly created interior cell and make it persistent and give it a name. You can then use that name to move it around or whatever. Edited October 2, 2012 by Maskar Link to comment Share on other sites More sharing options...
Oblis Posted October 2, 2012 Author Share Posted October 2, 2012 I thought that but is possible to make a persistent misc item that it will be unable to put it in inventory even with mistake? Link to comment Share on other sites More sharing options...
DrakeTheDragon Posted October 2, 2012 Share Posted October 2, 2012 (edited) For what it's worth, the trouble with the 2nd script I see is, the "LocationObject" is initialized as an "empty" reference and never set to anything thoughout the script. The position of an empty reference will always remain 0,0,0.In your 1st script you set "LocationObject" to the reference created by PlaceAtMe. In your 2nd script it's never set to anything and remains an empty reference. What kind of script is the 2nd? Is it a Quest script? Is there a quest named "NPCDecorationLocation"?If there is, you can simply rewrite your 1st script to use the reference variable of the quest script instead, like a global variable but cleaner:ScriptName NPCSummonLocationItemSpellScript ;ref LocationObject -- remove! float PosX float PosY float PosZ float PlayerPosX float PlayerPosY float PlayerPosZ float ObjectOnAir Begin ScriptEffectStart set PlayerPosZ to Player.GetPos Z ;Setting a reference to a placed object. set NPCDecorationLocation.LocationObject to Player.placeatme NPCDecorationLocationTrigger 1,20,0 ; -- add the quest name to reference its ref var instead of a local one ;These line will make the item appear always over ground. set PlayerPosZ to Player.GetPos Z set ObjectOnAir to (PlayerPosZ + 50) NPCDecorationLocation.LocationObject.SetPos Z ObjectOnAir ;These line will get the item current position using the reference i got. set PosX to NPCDecorationLocation.LocationObject.GetPos X set PosY to NPCDecorationLocation.LocationObject.GetPos Y set PosZ to NPCDecorationLocation.LocationObject.GetPos Z ;Message for tracking PrintToConsole "GameModeObject: %0.f, %0.f, %0.f" PosX PosY PosZ endNow your quest script will already know what LocationObject is pointing to, as it was its own LocationObject you set instead of a local inaccessible one. This can be done yet cleaner, by not always using NPCDecorationLocation.LocationObject for every call, but by using a local copy inside the script and setting the quest's variable to this one at the end. But I think you can see what I'm getting at. Of course a major drawback of this approach is there can be only 1 global reference to your object. Casting the spell another time will overwrite the quest's reference with the new one. The old one will be lost inaccessible from outside its own script forever. Edit: If you want to prevent your item from being added into an inventory, add an empty OnActivate block to its object script. Or create one for this purpose, if there isn't any already. This makes it impossible to be picked up.Or you could use a NIF file which doesn't have havoc collision. Then it can't be touched either. Scratch that. You "want" to carry it around. My bad. Edited October 2, 2012 by DrakeTheDragon Link to comment Share on other sites More sharing options...
Oblis Posted October 2, 2012 Author Share Posted October 2, 2012 Hello,Thanks for replayI have maneged to make what I was trying to do before I read this. 1. I created a persistent Object (a plate) to an empty TESTcell.2. Made this Object not to be able to be added to inventory by using Begin OnAdd etc.3. Created a spell that will move the item to me (using MoveAt function).4. Using z button I can move it to the location I like.5. Created a spell that will summon a chest to the player with decorations in it (chairs, shelves, beds etc)6. The player selects what he likes and the decoration is placed (using PlaceAtMe) to the location the Object is.7. Using the console SetPos and SetAngle I adjust the item a bit to match my desires. I did this thing with the Object because when I just placed a Decoration in frond of me and moved it around the room, only the mesh was moving. The colision and the activation werent moving around. This is my short story Link to comment Share on other sites More sharing options...
Maskar Posted October 3, 2012 Share Posted October 3, 2012 You have to update objects which have been moved with the MoveTo function. Otherwise it indeed doesn't update the collision. Link to comment Share on other sites More sharing options...
Oblis Posted October 3, 2012 Author Share Posted October 3, 2012 (edited) You have to update objects which have been moved with the MoveTo function. Otherwise it indeed doesn't update the collision. Thats interesting? How shall I update them?Disable-Enable? or there is some specific function?And we speak to do this through the console eh? Also when i summon the chest (I made it persistent too) it will not appear the open icon in the new position.Maybe this need to be updated too. I tried Disable/Enable through script but it doesnt seem to work properly, while through the console it works.After re-enable it is capable to be opened. Finally i'd like to ask if there is in Console or In Script any command that will drop the flying object to the ground (like z in TES Construction Set)Anyone knows? Edited October 3, 2012 by Oblis Link to comment Share on other sites More sharing options...
Maskar Posted October 3, 2012 Share Posted October 3, 2012 (edited) Disable/enable will work if there's some time between the 2. I used the same method in my Basic Personal Hygiene mod to move around markers for bathtubs, etc. In my most recent overhaul mod I used Update3D for moving containers though. This because the moving was done in the script on the container itself. Edited October 3, 2012 by Maskar Link to comment Share on other sites More sharing options...
Recommended Posts