Jump to content

Need Help with Simple script


SparkyWolf25

Recommended Posts

I'm making a mod that allows players to 'scrap' various junk items in the game (e.g. wrecked cars/trucks, broken terminals, broken furniture etc.) I want to make a script that allows players to approach an object to be salvaged, hit the activate key and be presented with a message box that tells them the tools and skills they need to salvage the item. If the player has the items/skills to salvage the item, I want it to disappear. I looked at some of the scripts for the New Vegas after School Special mod (Which uses scrips similar to what I want to make) and found this:

 

 

scn BalokPickUpSolarPanelSCRIPT

short DoOnce
short Button

begin GameMode
if DoOnce == 1
ShowMessage BalokSolarPanelPickUp
set DoOnce to 2
elseif DoOnce == 2
set Button to GetButtonPressed

if Button >= 0
set DoOnce to 3
if ( Button == 0 )
SetObjectiveCompleted BalokFinishSchoolQuest 20 1
SetObjectiveDisplayed BalokFinishSchoolQuest 25 1
player.additem BalokSolarPanel 1
BalokSolarPanelDisable.disable
BalokElectricalEnableREF.enable
BalokDisableBurialMound.enable
BalokEnableTransferSwitchStaticEnable.enable
elseif ( Button == 1 )
set DoOnce to 0
endif
endif
endif
end

begin OnActivate
if IsActionRef Player && DoOnce == 0
Activate
Set DoOnce to 1
endif
end

 

The Main thing I need to know is how DoOnece fits into all this. Any help would be awesome!

Edited by SparkyWolf25
Link to comment
Share on other sites

When the player activates the object in question the lines underneath "begin onActivate" are executed. This sets DoOnce to 1.

 

Now, when the GameMode block runs, DoOnce has been set to 1, so a message (presumably the menu) is displayed. DoOnce is then set to 2.

 

The next time the GameMode block runs, (since it cannot progress further down the script due to the elseif statement) DoOnce has been set to 2, therefore Button is set to GetButtonPressed (this allows the menu to detect which options the player selects).

 

From there, Button will = -1 because the player has not selected an option. When the player selects the first option Button will be 0. Whenever the player selects any option DoOnce is set to 3.

 

If the player selects the first option DoOnce is not called again. However, if they select the second option DoOnce is reset to zero and the script can restart anew.

 

So essentially DoOnce dictates which stage the script is in.

 

When DoOnce = 0, the player has not yet activated this object.

When DoOnce = 1, the player has activated this object but the menu has not appeared.

When DoOnce = 2, the menu has appeared but the player has not yet selected an option.

Finally, when DoOnce = 3, the player has chosen an option presented by the menu and the menu has closed.

Edited by Jojash
Link to comment
Share on other sites

  • Recently Browsing   0 members

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