Jump to content

[LE] Best practice for scripts


Recommended Posts

You want a button that when pressed starts a quest. You want that button to restart that quest at a later point but only after that quest has completed.

 

Correct?

 

If yes:

Locate any base object activator that you wish to use as your button.

If the base object has an attached script, then create a duplicate and remove the script from the duplicate.

If the base object does not have an attached script, you can use it as is.

Place the button where you want it in the game world.

Attach your script to the placed instance.

As long as your script works this will be sufficient.

 

Example script which could be used to get the results that you have indicated.

If used, change script name, property variable names and be sure to fill the properties.

 

 

ScriptName EnterAMeaningfullNameHere Extends ObjectReference

Quest Property TheQuestIWantToStart Auto
String Property MessageToShow Auto

Event OnActivate(ObjectReference akActivator)
  If akActivator == Game.GetPlayer()
    ;the player activated, see if we can start the quest
    If TheQuestIWantToStart.IsStopped()
      TheQuestIWantToStart.Start()
    Else
      ;not ready, show a message to the player
      Debug.MessageBox(MessageToShow)
    EndIf
  EndIf
EndEvent

 

 

Link to comment
Share on other sites

You want a button that when pressed starts a quest. You want that button to restart that quest at a later point but only after that quest has completed.

 

Correct?

 

If yes:

Locate any base object activator that you wish to use as your button.

If the base object has an attached script, then create a duplicate and remove the script from the duplicate.

If the base object does not have an attached script, you can use it as is.

Place the button where you want it in the game world.

Attach your script to the placed instance.

As long as your script works this will be sufficient.

 

Example script which could be used to get the results that you have indicated.

If used, change script name, property variable names and be sure to fill the properties.

 

 

ScriptName EnterAMeaningfullNameHere Extends ObjectReference

Quest Property TheQuestIWantToStart Auto
String Property MessageToShow Auto

Event OnActivate(ObjectReference akActivator)
  If akActivator == Game.GetPlayer()
    ;the player activated, see if we can start the quest
    If TheQuestIWantToStart.IsStopped()
      TheQuestIWantToStart.Start()
    Else
      ;not ready, show a message to the player
      Debug.MessageBox(MessageToShow)
    EndIf
  EndIf
EndEvent

 

 

Yeah pretty much. To be honest I already I have the button working it just occured to me after there could be a better way of doing it.

 

Cheers!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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