Jump to content

Recommended Posts

Posted (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 by foot89790
Posted
  On 2/19/2019 at 11:20 PM, Reneer said:

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.

Posted (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 by Reneer
Posted (edited)
  On 2/20/2019 at 1:46 AM, Reneer said:

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 by foot89790
Posted
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 Auto
ObjectReference 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

 

 

Posted (edited)
  On 2/20/2019 at 3:04 AM, foot89790 said:

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) < 2
try to change this to:

If Bob.GetDistance(Xmark01) < 256

p.s. Calling Game to re-evaluate his AI stack here might be a good idea too.

Bob.PathtoReference(XMark02, 0.9)
Bob.EvaluatePackage()
Edited by werr92
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...