Help me understand how to use PRID

#1VividAxisPosted 2/22/2012 5:39:29 PM
From: file:///C:/Users/ATD/Desktop/SavedWeb/Skyrim%20Console.htm
prid <RefId>
Pick reference by ID
Select an existing copy of an object/creature/NPC using its reference FormID (the one associated with that particular placed object). All subsequent targeted commands will use this object as the target. This is the same as clicking on the object in the console, but can be used even if the object is invisible or in a different area. Shorthand for PickReferenceID


I don't understand how I can use this command to benefit my scripting. Say I re-design a house by adding crafting equipment and I want to script the placements of the new objects so I can easily give it to friends and people online. How will PRID help me do this? Can I get use PRID to get the id of an object that I have just created? How do you clear the PRID so the rest of the commands in a script are not using it's reference id?

I tried scripting a house layout by moving a piece of cheese to each location where I wanted a new object to be, then creating the object like this (I knew D8AF0 was my cheese object):

D8AF0.SetPos X 512.56
D8AF0.SetPos Y -760
D8AF0.SetPos Z -287.65
D8AF0.SetAngle X 0
D8AF0.SetAngle Y 0
D8AF0.SetAngle Z 0
D8AF0.PlaceAtMe BAD0D #Enchanting Table
D8AF0.SetPos X 50
D8AF0.SetPos Y -720
D8AF0.SetPos Z -287.65
D8AF0.SetAngle X 0
D8AF0.SetAngle Y 0
D8AF0.SetAngle Z 180
D8AF0.PlaceAtMe BAD0C #Alchemy Table
...
etc.

But that doesn't work because the cheese doesn't refresh it's position until the script has completed. So I had to make several scripts where each creates and object and moves the cheese to the next place like:

Script 1
# move the cheese
D8AF0.SetPos X 512.56
D8AF0.SetPos Y -760
D8AF0.SetPos Z -287.65
D8AF0.SetAngle X 0
D8AF0.SetAngle Y 0
D8AF0.SetAngle Z 0

Script 2
# add the new object
D8AF0.PlaceAtMe BAD0D #Enchanting Table
# move the cheese
D8AF0.SetPos X 50
D8AF0.SetPos Y -720
D8AF0.SetPos Z -287.65
D8AF0.SetAngle X 0
D8AF0.SetAngle Y 0
D8AF0.SetAngle Z 180

Script 3
# add the new object
D8AF0.PlaceAtMe BAD0C #Alchemy Table
# move the cheese
D8AF0.SetPos X -85
D8AF0.SetPos Y -718.55
D8AF0.SetPos Z -287.65
D8AF0.SetAngle X 0
D8AF0.SetAngle Y 0
D8AF0.SetAngle Z 180

That works. But is there a way I can use PRID to combine all of my placement scripts into one and not use the default object (cheese) like I do? Maybe something like:

PlaceAtMe BAD0D #Enchanting Table
PRID (somehow get the enchanting table id)
SetPos X 512.56
SetPos Y -760
SetPos Z -287.65
SetAngle X 0
SetAngle Y 0
SetAngle Z 0
PlaceAtMe BAD0C #Alchemy Table
PRID (somehow get the alchemy table id)
SetPos X 50
SetPos Y -720
SetPos Z -287.65
SetAngle X 0
SetAngle Y 0
SetAngle Z 180
PRID (somehow clear the prid so the rest of my script doesn't use it as a reference)

My only goal in this is to be able to easily script object creation and placement. Thanks for any help you can give me.
---
"It's crack in a can, so you can can some crackers." - Pure_LionHeart
#2blowsephPosted 2/22/2012 5:59:08 PM(edited)
You cannot use PRID in a script that will work for multiple people because each item is given a unique reference ID when it is spawned in the game, and it is different for every single player since no 2 players will ever have the same exact amount of items created in their game at any one time.

You would have to somehow make a script that ran that would determine what the refid is for the item you're wanting to target on first, then prid whatever number that ends up being for that person.

You could break it down into 2 scripts though. One script to spawn the item, after which the player would have to manually target the item, then run the second script on it after it has been targeted.
---
http://i41.tinypic.com/rsvioo.jpg
#3MortalDangerPosted 2/22/2012 6:07:01 PM
blowseph, you know so much. :D
---
http://steamcard.com/do/nxe/MortalDanger.png
#4VividAxis(Topic Creator)Posted 2/22/2012 6:14:53 PM
There's no way we can get the id of an object that was just created?

Since Player always has the same id could I PRID the Player and then move the Player where I want an object to be then create it? Something like:

PRID Player
SetPos X 512.56
SetPos Y -760
SetPos Z -287.65
PlaceAtMe BAD0D #Enchanting Table
SetPos X 50
SetPos Y -720
SetPos Z -287.65
PlaceAtMe BAD0C #Alchemy Table

Even than I would still have the problem of how can I force an object to refresh while inside a script?
---
"It's crack in a can, so you can can some crackers." - Pure_LionHeart
#5blowsephPosted 2/22/2012 8:14:15 PM(edited)
^ that could work. Use setpos and setangle on the player so that the player is in a precise location so that when you spawn the item normally it's in the correct location and at the correct angle without having to actually do anything to the object itself. Doing that, I don't believe you would even need to do any sort of refreshing or anything to the object because it would already be placed as it should be. Although with this you may need to add in turning on tcl/noclip if there are items you need to spawn that won't be right at floor level. This is of course assuming that setpos and setangle even works on the player character (or even any non-object in general) as I've never actually tried it.

From: MortalDanger | Posted: 2/22/2012 8:07:01 PM
blowseph, you know so much. :D


There's also a lot I don't :D
---
http://i41.tinypic.com/rsvioo.jpg
#6VividAxis(Topic Creator)Posted 2/22/2012 10:51:47 PM
I tried this and it didn't work:
PRID Player
SetPos X 42587.28
SetPos Y 3491.04
SetPos Z -4382.04
SetAngle X 0
SetAngle Y 0
SetAngle Z 0
SetScale 1
PlaceAtMe BAD0D #Enchanting Table
SetPos X 42492.21
SetPos Y 3866.38
SetPos Z -4434.25
SetAngle X 0
SetAngle Y 0
SetAngle Z 0
SetScale 1
PlaceAtMe BAD0C #Alchemy Table

And I tried this and it didn't work:
Player.SetPos X 42587.28
Player.SetPos Y 3491.04
Player.SetPos Z -4382.04
Player.SetAngle X 0
Player.SetAngle Y 0
Player.SetAngle Z 0
Player.SetScale 1
Player.PlaceAtMe BAD0D #Enchanting Table
Player.SetPos X 42492.21
Player.SetPos Y 3866.38
Player.SetPos Z -4434.25
Player.SetAngle X 0
Player.SetAngle Y 0
Player.SetAngle Z 0
Player.SetScale 1
Player.PlaceAtMe BAD0C #Alchemy Table

I tried them without the SetScale command first, then I added it thinking it may refresh the Player. It doesn't. When I ran the script at the top with the PRID nothing at all happened. When I ran the second script with the Player. at the beginning of each command, both objects were placed where my character was standing before running the script (which wasn't either of the positions I scripted). After the script finished and I closed the Console the Player was finally refreshed and moved to the last position in the script. I tried it without TCL then with.

If I can't get an object to refresh while a script is running and if I can't get an id of an object I have just created then I will have to continue creating a script for each object, which isn't so bad I guess. I just make everything then script all of the coordinates and save that in chunks as separate scripts, using numbers at the end of the filename. When I run them I press the up arrow to recall the last Console command and change the last digit. It's no so bad, but I wanted to be able to make it very simple for anyone to execute them. One-step complete house redesigns that don't involve installing a mod would be prime.
---
"It's crack in a can, so you can can some crackers." - Pure_LionHeart
#7blowsephPosted 2/23/2012 12:02:18 AM(edited)
This really seems like a huge pain in the ass at the end of which it may not even work correctly. What exactly is the end result you're trying to accomplish? If you're trying to make it so a person can create an item in a house at a fixed location, it may be easier to use the CK to alter or add more of the the furnishing "packages" you can buy from the jarl's lackey... so to place an item they just buy it from the guy and it appears in the house. It would require installing a mod, yes. But putting a single file in the data folder isn't all that complicated for someone to do... not any harder than putting a batch file in the folder to run the script.
---
http://i41.tinypic.com/rsvioo.jpg