Papyrus Trouble With PlaceAtMe

Post » Wed Jun 20, 2012 3:29 am

Anyone have any ideas why this isn't working and doesn't simply spawn MagicBox?

Scriptname PR001MBMagicEffect extends activemagiceffect{Accesses the magic box.}ObjectReference property MagicBox autoEvent OnEffectStart(Actor target, Actor caster)ObjectReference newBox = Game.GetPlayer().PlaceAtMe(MagicBox)EndEvent

Reference has been set and works if I use:
Scriptname PR001MBMagicEffect extends activemagiceffect{Accesses the magic box.}ObjectReference property MagicBox autoEvent OnEffectStart(Actor target, Actor caster)MagicBox.MoveTo(Game.GetPlayer())EndEvent

Thanks for any and all help. :smile:
User avatar
lauraa
 
Posts: 3362
Joined: Tue Aug 22, 2006 2:20 pm

Post » Wed Jun 20, 2012 3:05 pm

This:
ObjectReference newBox = Game.GetPlayer().PlaceAtMe(MagicBox)


Looks like you are defining a variable with a function. What is that supposed to do?
Wouldn't you just want to do:


game.Getplayer().PlaceAtMe(MagicBox)


Oh, I see now that the wiki says the syntax is how you wrote it. I don't quite get why though. Certainly seems odd.

See place actor at me works like this:

MarkerProperty.PlaceActorAtMe(VarActor)

So place at me should work like that too.

Oh but now I see another Problem:
PlaceAtMe needs a Form ID, not an Object reference. So you need to set your property to form and select the base Id of the "Magic Box".
User avatar
Jaki Birch
 
Posts: 3379
Joined: Fri Jan 26, 2007 3:16 am

Post » Wed Jun 20, 2012 5:14 am

Change your property to the base object of MagicBox, not an instance of it.
User avatar
Allison C
 
Posts: 3369
Joined: Mon Dec 18, 2006 11:02 am

Post » Wed Jun 20, 2012 3:19 pm

Thanks for the help. The reason for declaring the variable is so that later the modder can handle the form if needed (so you can have the object move to the player, then later you might want to disable it so then that instance of the variable is there to be messed around with, but yeah, been following the wiki as close as I can while still learning Papyrus :tongue:). Anyway I tried changing:
ObjectReference property MagicBox auto
To:
Form property MagicBox auto
So that this is the new script:
Scriptname PR001MBMagicEffect extends activemagiceffect{Accesses the magic box.}Form property MagicBox autoEvent OnEffectStart(Actor target, Actor caster)Game.GetPlayer().PlaceAtMe(MagicBox)EndEvent

But I can't select the base ID of the object and I can't find anything on the wiki on what the property type is that will accept the Base ID in the property selection screen.
Game.GetPlayer().PlaceAtMe(PR001MBMagicBox)
Doesn't work and is kicked back with:
variable PR001MBMagicBox is undefined

Thanks again for all the help. :smile:
User avatar
JR Cash
 
Posts: 3441
Joined: Tue Oct 02, 2007 12:59 pm

Post » Wed Jun 20, 2012 1:43 pm

Yeah there's a http://www.gamesas.com/topic/1357862-setting-a-form-as-a-property-works-ok/ in CK when you try to set a Form Property.
The easiest way is to make the property name identical to the EditorID. The Auto-fill in the CK should work OK then (touch wood)

BTW, anything you spawn with PlaceAtMe will remain in game (and savegames) until you tidy it up.
So either keep the ObjectReference newbox as you had in your orig script if you will only have one in existence at a time.
Or add a script to MagicBox itself that calls the Delete() when it's served its purpose.

Edit: Just read your edit, PR001MBMagicBox is the name of your base Form and auto-fill is not working?
User avatar
Marine x
 
Posts: 3327
Joined: Thu Mar 29, 2007 4:54 am

Post » Wed Jun 20, 2012 4:11 am

Auto-fill wasn't finding the container. But I actually simply set the type to container instead of form after reading in that post about miscingrediant and I could select it. :P

I'll keep that in mind as I remember PlaceAtMe having the same issues in Oblivion and was actually just about to go see if a Delete() existed. :P

Thankyou so much for the help, much appreciated. :)
User avatar
Hannah Whitlock
 
Posts: 3485
Joined: Sat Oct 07, 2006 12:21 am

Post » Wed Jun 20, 2012 5:52 am

Syntax


ObjectReference Function PlaceAtMe(Form akFormToPlace, int aiCount = 1,
bool abForcePersist = false, bool abInitiallyDisabled = false) native

Parameters
  • akFormToPlace: The base form to create references of.
    • Note: the akFormToPlace can be things such as MiscItem, Actor, ActorBase, etcetera, but it cannot be an ObjectReference
You can also use:
Game.GetPlayer().PlaceAtMe(MagicBox.GetBaseObject()) but this will create a new instance, won't move the MagicBox if that's what you intend. I agree is strange it allows Actor, not just ActorBase (at last according to wiki) in which case I asume it moves it, but haven't done that myself.
User avatar
Lou
 
Posts: 3518
Joined: Wed Aug 23, 2006 6:56 pm


Return to V - Skyrim