foot89790 Posted February 19, 2019 Share Posted February 19, 2019 (edited) Scriptname HW:ControlBob extends ObjectReference Actor Property Bob Auto Message Property AAMenu Auto ObjectReference Property XMark01 Auto Event OnActivate(ObjectReference akActionRef) Menu() PathtoReference() EndEvent Function Menu(int aButton = 0) aButton = AAMenu.show() If aButton == 0 ElseIf aButton == 1 Function PathToReference() Bob.PathToReference(XMark01, 0.9) EndFunction EndIf EndFunction So I'm learning how to script, my goal of this script is to use an activator to bring up a menu that gives two options: cancel and leave the menu, and move actor Bob to the xmarker across the room. Right now I'm getting these two errors: (17,2): mismatched input 'Function' expecting ENDIF and (20,1): missing EndOfFile at 'EndIf' Thanks if theres any help Edited February 19, 2019 by foot89790 Link to comment Share on other sites More sharing options...
Reneer Posted February 19, 2019 Share Posted February 19, 2019 Functions cannot be created inside other functions. Move your PathToReference() function (and rename it) outside of your Menu function. Link to comment Share on other sites More sharing options...
foot89790 Posted February 20, 2019 Author Share Posted February 20, 2019 Functions cannot be created inside other functions. Move your PathToReference() function (and rename it) outside of your Menu function.Could you write out an example? I don't know how to keep the pathtoreference function within the if statement while excluding it from the menu function. Link to comment Share on other sites More sharing options...
Reneer Posted February 20, 2019 Share Posted February 20, 2019 (edited) Here you go:Scriptname HW:ControlBob extends ObjectReference Actor Property Bob Auto Message Property AAMenu Auto ObjectReference Property XMark01 Auto Event OnActivate(ObjectReference akActionRef) Menu() EndEvent Function BobPathtoReference() Bob.PathToReference(XMark01, 0.9) EndFunction Function Menu(int aButton = 0) aButton = AAMenu.show() If aButton == 0 ElseIf aButton == 1 BobPathtoReference() EndIf EndFunction Edited February 20, 2019 by Reneer Link to comment Share on other sites More sharing options...
foot89790 Posted February 20, 2019 Author Share Posted February 20, 2019 Thanks! Link to comment Share on other sites More sharing options...
foot89790 Posted February 20, 2019 Author Share Posted February 20, 2019 (edited) Here you go: Huh, weird, it compiles alright but the menu doesn't show up in game, go any ideas? Edit: Nvm, just forgot to autofill properties Edited February 20, 2019 by foot89790 Link to comment Share on other sites More sharing options...
foot89790 Posted February 20, 2019 Author Share Posted February 20, 2019 Okay so I altered it slightly so if the actor (Bob) walks to the xmarker (Xmark01), you can hit the menu button again so he walks back to where he originally was (XMark02). I included the script below. It seems to compile correctly but simply doesn't work in-game, the actor walks to XMark01 but when I hit the button again he just stays where he is and doesn't move. Scriptname HW:ControlBob extends ObjectReference Actor Property Bob Auto Message Property AAMenu Auto ObjectReference Property XMark01 AutoObjectReference Property XMark02 Auto Event OnActivate(ObjectReference akActionRef) Menu()EndEvent Function BobPathtoReference() Bob.PathToReference(XMark01, 0.9)EndFunction Function Menu(int aButton = 0) aButton = AAMenu.show() If aButton == 0 ElseIf aButton == 1 If Bob.GetDistance(Xmark01) < 2 Bob.PathtoReference(XMark02, 0.9) Debug.Trace("Success!") Else Bob.PathtoReference(XMark01, 0.9) EndIf EndIf EndFunction Link to comment Share on other sites More sharing options...
werr92 Posted February 20, 2019 Share Posted February 20, 2019 (edited) Okay so I altered it slightly so if the actor (Bob) walks to the xmarker (Xmark01), you can hit the menu button again so he walks back to where he originally was (XMark02). I included the script below. It seems to compile correctly but simply doesn't work in-game, the actor walks to XMark01 but when I hit the button again he just stays where he is and doesn't move.2 a.u. are nothing for that matter. NPCs hardly ever reach exactly the spot.If Bob.GetDistance(Xmark01) < 2try to change this to:If Bob.GetDistance(Xmark01) < 256p.s. Calling Game to re-evaluate his AI stack here might be a good idea too. Bob.PathtoReference(XMark02, 0.9) Bob.EvaluatePackage() Edited February 20, 2019 by werr92 Link to comment Share on other sites More sharing options...
Recommended Posts