MoveTo Script help?

Post » Fri Jan 07, 2011 9:00 am

Hey guys I really hope you can help me with this, scripting isnt my strongest suit....

Im trying to send NPC's to a marker location using the "MoveTo" command in a scripted spell. Just using the code -

Begin Scripteffectstart
Moveto CellMarker1
end

On a targeted spell works fine. However as I want multiple locations I would like a message box to come up with a list of options and then the NPC would be sent to the location you select, this is the part thats causing me some grief.

Heres my code....




Begin Scripteffectstart
Short Button
MessageBox "Send the NPC to which cell?......", "One", "Two", "Three", "Four"

Set button to GetButtonPressed

If ( button == 1 )
Moveto CellMarker1


Elseif ( button == 2)
Moveto CellMarker2


ElseIf ( button == 3)
Moveto CellMarker3

EndIf
End


Nothing happenes. If I set the first button value to -1 then the NPC will go to the location which makes me think that the spell is being triggered before the message box even comes up....

Please Help!
User avatar
Amanda Leis
 
Posts: 3518
Joined: Sun Dec 24, 2006 1:57 am

Post » Fri Jan 07, 2011 4:59 am

ok you have a few thing wrong, the reason that is was not working is the set button to getbutton pressed and the different button options have to be under begin gamemode
also just so you know the buttons start at 0
last thing, you need to create a reference for the person it is affecting, do ref self, before you put the begin, and then under gamemode put set self to getself
User avatar
xxLindsAffec
 
Posts: 3604
Joined: Sun Jan 14, 2007 10:39 pm

Post » Fri Jan 07, 2011 4:27 am

Hey thanks for the quick reply! Its greatly appriciated :)

I did what you said (I think) but it still doesnt work, this is my new code after the advice you gave me:






Scriptname 00MOVENPC
Ref Self

Begin Scripteffectstart
MessageBox "Send the NPC to which cell?......", "One", "Two", "Three", "Four"
Set Self to GetSelf
eND

Begin GameMode
Short Button
Set button to GetButtonPressed

If ( button == 0 )
Self.Moveto CellMarker1


eLSEIf ( button ==1)
Self.Moveto CellMarker2


eLSEIf ( button == 2)
Moveto CellMarker3

EndIf
End



Sorry if im being silly but im really stuck with this!
User avatar
Amy Cooper
 
Posts: 3400
Joined: Thu Feb 01, 2007 2:38 am

Post » Fri Jan 07, 2011 4:48 am

Hey thanks for the quick reply! Its greatly appriciated :)

I did what you said (I think) but it still doesnt work, this is my new code after the advice you gave me:






Scriptname 00MOVENPC
Ref Self

Begin Scripteffectstart
MessageBox "Send the NPC to which cell?......", "One", "Two", "Three", "Four"
eND

Begin GameMode
Set Self to GetSelf
Short Button
Set button to GetButtonPressed

If ( button == 0 )
Self.Moveto CellMarker1


eLSEIf ( button ==1)
Self.Moveto CellMarker2


eLSEIf ( button == 2)
Moveto CellMarker3

EndIf
End



Sorry if im being silly but im really stuck with this!


Correction in red. Also, never ever start a script name with a number. When you do, the game engine thinks it's supposed to look for a FormID and that can cause all sorts of problems. Change the 00 to AA or something easy to find.
User avatar
Tai Scott
 
Posts: 3446
Joined: Sat Jan 20, 2007 6:58 pm

Post » Fri Jan 07, 2011 11:46 am

Hey Vyper thanks for your reply, unfourtunalty the script does still not work, the spell hits the NPC and nothing happens. I made the correction and changed the scriptname to no avail. The script is set as a magic effect script and is attached to a spell. Each "CellMarker" is an X marker with "CellMarker1" set as its reference. I cant figure out whats going wrong, :S
User avatar
Mari martnez Martinez
 
Posts: 3500
Joined: Sat Aug 11, 2007 9:39 am

Post » Fri Jan 07, 2011 6:02 am

Scriptname  SilverfeetzMOVENPCscrRef Self	; not sure is neededShort ButtonBegin ScripteffectstartMessageBox "Send the NPC to which cell?......", "One", "Two", "Three"Set Self to GetSelfeNDBegin ScriptEffectUpdateSet Button to GetButtonPressedIf (button == 0)	Self.Moveto CellMarker1eLSEIf (button == 1)	Self.Moveto CellMarker2eLSEIf (button == 2)	Self.Moveto CellMarker3EndIfEnd; duration of the spell must be 1 sec or more

EDIT : http://cs.elderscrolls.com/constwiki/index.php/If#Spaces_and_Tabs - if you write code not properly spaced it will never run
User avatar
Jade
 
Posts: 3520
Joined: Mon Jul 10, 2006 6:42 am

Post » Fri Jan 07, 2011 10:03 am

THANK YOU Utumno! It works perfectly, its funny I tried using the scripteffectupdate block this morning but it didnt work, never occured to me that the duration might be effecting it!

Really a big thank you to everyone that helped me with this, really appriciate it guys cheers :D
User avatar
Amy Smith
 
Posts: 3339
Joined: Mon Feb 05, 2007 10:04 pm

Post » Fri Jan 07, 2011 4:33 am

Really glad I helped :)
Try disabling the self thing btw - not sure is needed - just curious
bye
User avatar
Motionsharp
 
Posts: 3437
Joined: Sun Aug 06, 2006 1:33 am

Post » Fri Jan 07, 2011 11:52 am

Really glad I helped :)
Try disabling the self thing btw - not sure is needed - just curious
bye

the self thing is how I learned it, because with some function you can't just put it and the game will infer on what you are talking about
User avatar
Czar Kahchi
 
Posts: 3306
Joined: Mon Jul 30, 2007 11:56 am


Return to IV - Oblivion