Jump to content

Fallout 4 Script help Confused on activate function


Recommended Posts

Here is what I got for a new fallout 4 script. Trying to make it so when player activates a container it shows a menu and they can then select a container from the menu options. K, With Reneer help on original post learned out my mistake on activate function need to change to objectreference from activator. Now I am looking at this.




With help from Reneer on my original post. Ok, I had a lot wrong thanks to Reneer tho this is final code that did compile in case it helps someone else. Thank you Reneer.


End Product script now. Has to placed on Door.


Scriptname aaadREFIGMASTERSCRIPT extends ObjectReference


Message Property aaadContaineroptionsMessage Auto


Message Property aaadtest Auto


Message Property aaadtest2 Auto


Message Property aaadtest3 Auto


ObjectReference Property aaadPSC_ProvisionedMetalBox_Activator Auto


ObjectReference Property aaadFood_Activator Auto


ObjectReference Property aaadFoodDryAlt_Activator Auto


Event OnActivate (ObjectReference akActionRef)

if akActionRef == Game.GetPlayer()

PlayGamebryoAnimation("open")

PlayAnimation("open")

MainMessage(akActionRef)

endif

EndEvent


Function MainMessage(ObjectReference akActionRef)


Int iCount = 99999

Int iButton = aaadContaineroptionsMessage.Show()


If iButton == 0 ; Master Food Chest

aaadtest.Show()

aaadPSC_ProvisionedMetalBox_Activator.Activate(Game.getPlayer())

Utility.Wait( 0.5 )

While ( Utility.IsInMenuMode() )

Utility.WaitMenuMode( 0.5 )

EndWhile

endif

If iButton == 1 ; Dry Foods Chest

aaadtest2.Show()

aaadFood_Activator.Activate(Game.getPlayer())

Utility.Wait( 0.5 )

While ( Utility.IsInMenuMode() )

Utility.WaitMenuMode( 0.5 )

EndWhile

endif

If iButton == 2 ; Perishable Foods Chest

aaadtest3.Show()

aaadFoodDryAlt_Activator.Activate(Game.getPlayer())

Utility.Wait ( 0.5 )

While ( Utility.IsInMenuMode() )

Utility.WaitMenuMode( 1.0 )

EndWhile

endif

If iButton == 3 ; Exit

Utility.Wait( 0.5 )

While ( Utility.IsInMenuMode() )

Utility.WaitMenuMode( 0.5 )

EndWhile

endif

PlayGamebryoAnimation( "close" )

PlayAnimation("close")

Endfunction



Edited by draco1122
Link to comment
Share on other sites

Ok I've got a working method for you. The only problem is the container that brings up this menu will have its activation blocked - meaning the container's contents can't be accessed, but the script will still fire so that the main menu comes up. This is the only way I could think of as otherwise the container will prevent other containers from opening. I also had to change the script for optimization. For each message an additional button needs to added if you want the player to return back to the main menu. If not, you can just adjust the checks in the aaad functions.

Edit: You need a forth button for Main Message for exiting the menu.

Scriptname aaadREFIGMASTERSCRIPT extends ObjectReference

Message Property aaadContaineroptionsMessage Auto
 
Message Property aaadtest Auto
 
Message Property aaadtest2 Auto
 
Message Property aaadtest3 Auto
 
ObjectReference Property aaadPSC_ProvisionedMetalBox_Activator Auto
 
ObjectReference Property aaadFood_Activator Auto
 
ObjectReference Property aaadFoodDryAlt_Activator Auto

Actor Player

Event OnInit()

Player = Game.GetPlayer()
BlockActivation()

EndEvent
 
Event OnActivate (ObjectReference akActionRef)
if akActionRef == Player
    MainMessage()
endif
EndEvent
 
Function MainMessage()
 
Int iCount = 99999
Int iButton = aaadContaineroptionsMessage.Show()
 
If iButton == 0 ; Master Food Chest
    aaadtestfunc()
elseif iButton == 1 ; Dry Foods Chest
    aaadtesttwo()
elseif iButton == 2 ; Perishable Foods Chest
    aaadtestthree()
elseif iButton == 3 ; Exit
    return
endif
Endfunction

Function aaadtestfunc()
    Int button = aaadtest.Show()
    if button == 0 ; Open this container?
        aaadPSC_ProvisionedMetalBox_Activator.Activate(Player)
    elseif button == 1 ; return?
        MainMessage()
    elseif button == 2 ; close?
        return
    endif
EndFunction

Function aaadtesttwo()
    Int button = aaadtest2.Show()
    if button == 0 ; Open this container?
        aaadFood_Activator.Activate(Player)
    elseif button == 1 ; return?
        MainMessage()
    elseif button == 2 ; close?
        return
    endif
EndFunction

Function aaadtestthree()
    Int button = aaadtest3.Show()
    if button == 0 ; Open this container?
        aaadFoodDryAlt_Activator.Activate(Player)
    elseif button == 1 ; return?
        MainMessage()
    elseif button == 2 ; close?
        return
    endif
EndFunction
Edited by Lisselli
Link to comment
Share on other sites

  • Recently Browsing   0 members

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