Need help making a button that moves an object to an xmarker

Post » Sat Nov 17, 2012 11:14 am

After following a previous forum post on how to make a button that when pressed will spawn NPC's I'm trying to get the same thing to work now for objects, specifically the TrapFallingRockSm01. The script compiles fine and I have the SpawnPlace property set to the xmarker and the myObject property set to the rock. However when pressing the button in the game nothing happens. I have very little experience with scripting and wondering now if the script needs to be simply written a different way to get it to work.

Scriptname YetiSpikeDeath extends ObjectReferenceimport gameimport debugObjectReference property myObject autoObjectReference property SpawnPlace autoEvent OnActivate(ObjectReference akActionRef)	 SpawnPlace.PlaceAtMe(myObject)EndEvent
User avatar
jeremey wisor
 
Posts: 3458
Joined: Mon Oct 22, 2007 5:30 pm

Post » Sat Nov 17, 2012 5:09 pm

PlaceAtMe takes a form, not an object reference.

If you use MoveTo your script will probably do what you want
User avatar
Glu Glu
 
Posts: 3352
Joined: Sun Apr 01, 2007 5:39 am

Post » Sat Nov 17, 2012 11:31 am

I switched the PlaceAtMe to MoveTo, again it compiles fine, but still does nothing in game =(
User avatar
Gavin Roberts
 
Posts: 3335
Joined: Fri Jun 08, 2007 8:14 pm

Post » Sat Nov 17, 2012 5:15 pm

Have you but a debug message in your OnActivate event code to see if it is firing? To test, I would do this:
Event OnActivate(ObjectReference akActionRef)  Debug.MessageBox("Activated") SpawnPlace.PlaceAtMe(myObject) EndEvent
That will tell you if your event is even firing.

PlaceAtMe is used to create a new instance of something... MoveTo moves an existing object to the new location. What do you actually want?
User avatar
Dawn Porter
 
Posts: 3449
Joined: Sun Jun 18, 2006 11:17 am

Post » Sat Nov 17, 2012 10:34 pm

Essentially what this should do is move the rock from a location out of sight to the player and move it to the xmarker which is at the top of a slope so it would roll down and run over monsters who will later try running up the hill. So using MoveTo should actually be what i want.

I added the messagebox and it is firing, just not moving the rock.


EDIT: If there is a way to write the script to spawn a new rock at the xmarker every time the button is pressed that would work too. I just figured moving the same already existing rock back to the top would be easier.
User avatar
Jade MacSpade
 
Posts: 3432
Joined: Thu Jul 20, 2006 9:53 pm

Post » Sat Nov 17, 2012 8:58 am

Essentially what this should do is move the rock from a location out of sight to the player and move it to the xmarker which is at the top of a slope so it would roll down and run over monsters who will later try running up the hill. So using MoveTo should actually be what i want.

I added the messagebox and it is firing, just not moving the rock.


EDIT: If there is a way to write the script to spawn a new rock at the xmarker every time the button is pressed that would work too. I just figured moving the same already existing rock back to the top would be easier.

All you'd have to do to use your original PlaceAtMe is find the appropriate rocks in the CK and set your property to match whatever those are. (I've never used them, so I haven't looked. But if you already have the rocks placed, I'd just use those as it's done.)

Have you filled the properties in the CK? You need to make sure both the SpawnPlace and myObject properties are filled with your objects. Since you said the event is firing correctly, then all that's left is for the script to actually have the objects it needs to move.
User avatar
Marquis deVille
 
Posts: 3409
Joined: Thu Jul 26, 2007 8:24 am

Post » Sat Nov 17, 2012 5:31 pm

yeah I've quadruple checked that both properties are set correctly to the xmarker and the rock. It still doesn't want to move it whether I use PlaceAtMe or MoveTo.
User avatar
Ilona Neumann
 
Posts: 3308
Joined: Sat Aug 19, 2006 3:30 am

Post » Sat Nov 17, 2012 9:07 am

yeah I've quadruple checked that both properties are set correctly to the xmarker and the rock. It still doesn't want to move it whether I use PlaceAtMe or MoveTo.
How about posting the code again? I use both PlaceAtMe and MoveTo and don't have any issues, so off-hand, I don't see why it should be a problem. How are you filling the properties? It really seems like it has to be an issue with the property as you said the message box was displaying.
User avatar
Killer McCracken
 
Posts: 3456
Joined: Wed Feb 14, 2007 9:57 pm

Post » Sat Nov 17, 2012 10:41 pm

it sounds more like a deeper issue. the first script you posted should not have compiled at all. your MyObject cannot even be recognized as an object that is valid for a placeatme function.

if that script compiled exactly the way you have it posted, you may have something severely broken
User avatar
helliehexx
 
Posts: 3477
Joined: Fri Jun 30, 2006 7:45 pm

Post » Sat Nov 17, 2012 10:41 am

it sounds more like a deeper issue. the first script you posted should not have compiled at all. your MyObject cannot even be recognized as an object that is valid for a placeatme function.

if that script compiled exactly the way you have it posted, you may have something severely broken
Unfortunately, it does compile.
User avatar
Emmi Coolahan
 
Posts: 3335
Joined: Wed Jan 24, 2007 9:14 pm

Post » Sat Nov 17, 2012 11:53 am

really? wow. ok scratch that.

the only other thing i can think of is that simply replacing PlaceAtMe with MoveTo will accomplish nothing. since the script will move the xmarker to the rock, you need to reverse the property roles

Myobject.MoveTo(spawnlocation)
User avatar
Zoe Ratcliffe
 
Posts: 3370
Joined: Mon Feb 19, 2007 12:45 am

Post » Sat Nov 17, 2012 9:23 pm

the only other thing i can think of is that simply replacing PlaceAtMe with MoveTo will accomplish nothing. since the script will move the xmarker to the rock, you need to reverse the property roles

Myobject.MoveTo(spawnlocation)
Oh, good catch!! I even thought that could be the problem and missed it when I checked.
User avatar
Ridhwan Hemsome
 
Posts: 3501
Joined: Sun May 06, 2007 2:13 pm

Post » Sat Nov 17, 2012 3:59 pm

Myobject.MoveTo(spawnlocation)
Thank YOU! That fixed the problem completly, so I guess it was moving the xmarker to the rock instead when it was the other way around :biggrin:
User avatar
Jack Walker
 
Posts: 3457
Joined: Wed Jun 06, 2007 6:25 pm


Return to V - Skyrim