Jump to content

Creating a Menu With Options that Trigger Scripts?


Recommended Posts

I have created a menu that pops up when an object is Activated. When activated, the menu comes up with two options. I want to have it so that selecting one option will perform a collection of actions, while the other will close the menu. (Since they close the menu by default, I only need to figure out the one that will perform a collection of actions.)

Here's my menu script:

Scriptname WTStartMessageScript extends ObjectReference

Message Property WTStartMessage1 Auto

Event OnActivate(ObjectReference akActionRef)
	Utility.wait(1)
	WTStartMessage1.show()

EndEvent

I want to make it so that one of the options will do the following:

  • Move the player to a marker in another cell (Using player.moveto(?))
  • Add and equip items on the player (using player.additem and player.equipitem(?)
  • And finally trigger the SPECIAL menu to pop-up (?)

 

Problem is, I'm having trouble figuring out how to put this all together in the script or scripts. I'm imagining something like this(below) is how it works, but I know it doesn't work, so how do I do this correctly? Thanks for helping me out.

Scriptname WTStartMessageScript extends ObjectReference

Message Property WTStartMessage1 Auto
//Autofills the "Property" int for the message.

Event OnActivate(ObjectReference akActionRef)//When the door is activated
	Utility.wait(1)//Wait a moment
	WTStartMessage1.show()//Show message

//((When button 1 is selected))
Player.moveto //(Marker)
Player.additem //(item)
Player.equipitem //(item)
Game.ShowSPECIALMenu()

EndEvent
Link to comment
Share on other sites

UPDATE
Managed to get the script organized a bit and got the SPECIAL menu to come up when the option is selected. My script currently looks like this:

Scriptname WTStartMessageScript extends ObjectReference

Message Property WTStartMessage1 Auto
//Autofills the Message Property.

Event OnActivate(ObjectReference akActionRef) //When the door is activated
	Utility.wait(1) //Wait a moment
	Menu() //Perform function Menu below
EndEvent

Function Menu()
	Int iButton = WTStartMessage1.Show() //Show menu/message
	If iButton == 0 //If the first option is selected
	Game.ShowSPECIALMenu() //Show SPECIAL menu

Endif
EndFunction

I still need to figure out how to move the player and add/equip items.

Edited by legobrick100
Link to comment
Share on other sites

To add a FormList full of items and equip them if they are armor:

ObjectReference	Property pPlayerREF Auto Const Mandatory
FormList Property pSKK_FSSPlayerEquipment Auto Const Mandatory

iIndex = 0
While (iIndex  < pSKK_FSSPlayerEquipment.GetSize())
   pPlayerREF.AddItem(pSKK_FSSPlayerEquipment(iIndex), 1, abSilent = true)
   If (pSKK_FSSPlayerEquipment.GetAt(iIndex) is Armor)
      (pPlayerREF as Actor).EquipItem(pSKK_FSSPlayerEquipment.GetAt(iIndex), abSilent = true)
   EndIf	
   iIndex +=1
EndWhile

To move the player give it an objectreference in the world

ObjectReference ThisTarget ;assign this from a property of something in the world

If (ThisTarget is WorkshopScript) || (ThisTarget is WorkbenchScript) ;dont appear on top of object
   pPlayerREF.MoveTo(ThisTarget, -128.0 * Math.Sin(ThisTarget.GetAngleZ()), -128.0 * Math.Cos(ThisTarget.GetAngleZ()), 0, true)	
Else ;its a marker
   pPlayerREF.MoveTo(ThisTarget)
EndIf
Link to comment
Share on other sites

 

To add a FormList full of items and equip them if they are armor:

ObjectReference	Property pPlayerREF Auto Const Mandatory
FormList Property pSKK_FSSPlayerEquipment Auto Const Mandatory

iIndex = 0
While (iIndex  < pSKK_FSSPlayerEquipment.GetSize())
   pPlayerREF.AddItem(pSKK_FSSPlayerEquipment(iIndex), 1, abSilent = true)
   If (pSKK_FSSPlayerEquipment.GetAt(iIndex) is Armor)
      (pPlayerREF as Actor).EquipItem(pSKK_FSSPlayerEquipment.GetAt(iIndex), abSilent = true)
   EndIf	
   iIndex +=1
EndWhile

To move the player give it an objectreference in the world

ObjectReference ThisTarget ;assign this from a property of something in the world

If (ThisTarget is WorkshopScript) || (ThisTarget is WorkbenchScript) ;dont appear on top of object
   pPlayerREF.MoveTo(ThisTarget, -128.0 * Math.Sin(ThisTarget.GetAngleZ()), -128.0 * Math.Cos(ThisTarget.GetAngleZ()), 0, true)	
Else ;its a marker
   pPlayerREF.MoveTo(ThisTarget)
EndIf

Surely there's a simpler way to do this? From what I could find from other sources, performing the actions themselves are much less complicated.

Link to comment
Share on other sites

They are cuts from my published scripts. Pick the bits you like, ignore the bits you don't.

After playing around with your scripts, I managed to get the moveto and additem functions to work, but equipitem returns an error: "EquipItem is not a function or does not exist".

Scriptname WTStartMessageScript extends ObjectReference

Message Property WTStartMessage1 Auto
ObjectReference    Property pPlayerREF Auto
ObjectReference      Property WTPlayerMove Auto
ObjectReference    Property Pipboy Auto

Event OnActivate(ObjectReference akActionRef)
    Utility.wait(1)
    Menu()
EndEvent

Function Menu()
    Int iButton = WTStartMessage1.Show()
    If iButton == 0
    pPlayerREF.MoveTo(WTPlayerMove)
    Utility.wait(1)
    Game.ShowSPECIALMenu()
    Game.GetPlayer().ChangeAnimArchetype()
    pPlayerREF.AddItem(Pipboy, 1, true)
    pPlayerREF.EquipItem(Pipboy, true)
EndIf
EndFunction
Link to comment
Share on other sites

 

You've got pPlayerREF as an ObjectReference and EquipItem is an Actor function. You can get around this like so:

    (pPlayerREF as Actor).EquipItem(Pipboy, true)

Oh, thank you. That makes sense, I don't know why I didn't see that. It compiled successfully, though I'm having trouble now getting the Pipboy property to autofill. What am I doing wrong there?

 

EDIT: Got it to autofill. The Pipboy was an Armor Property, not an ObjectReference Property.

Edited by legobrick100
Link to comment
Share on other sites

One final thing came up: I'm trying to figure out how to use enableplayercontrols correctly. I managed to reset the AnimationArchtype (to disable the FastWalk limiter), but I can't figure out how to use EnablePlayerControls to allow the player to fight, sneak, use VATs, etc. Any help there?

Link to comment
Share on other sites

One final thing came up: I'm trying to figure out how to use enableplayercontrols correctly. I managed to reset the AnimationArchtype (to disable the FastWalk limiter), but I can't figure out how to use EnablePlayerControls to allow the player to fight, sneak, use VATs, etc. Any help there?

 

I'm not sure I follow. How did player controls get disabled in the first place?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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