Jump to content

Help calling a function from a script file


Recommended Posts

For anyone that can help.

 

I am trying to call a function from a script file that i have created. The script file has the following code so far:

 

Scriptname FaultysMenu_Components
MiscObject Property MyComponent Auto const
Bool Property MyComponents Auto const
Actor Property PlayerREF Auto const
FormList Property MyCompList Auto const
Function AddComponents()
If MyComponents == True
Int iIndex = MyCompList.GetSize()
While iIndex
iIndex -= 1
PlayerREF.AddItem(MyCompList.GetAt(iIndex), 100, True)
EndWhile
Else
PlayerRef.AddItem(MyComponent, 100, True)
EndIF
EndFunction
I am trying to access this function from a terminal menu item.
My question is
1. Is the above code viable?
2. What is the required syntax to attach the above function to the terminal menu item?
Link to comment
Share on other sites

The code is viable and will work as expected. To call that function, the easiest way is to make a dummy quest and make that script the quest script. Make sure it extends Quest.

 

Then add the quest property in the terminal's fragment box.

 

Then put this in the script field:

 

 

(FaultysMenuComponentsQuest as FaultysMenuComponentsScript).AddComponents()
Link to comment
Share on other sites

You can create a property for your script instance directly in the calling script.

ScriptName MyTerminal

FaultysMenuComponentsScript Property FaultysMenuComponents Auto Const Mandatory

Function Foo()
	FaultysMenuComponents.AddComponents()
EndFunction

TummaSuklaa advice also works if the script instance you need access to just so happens to be attached to a Quest.

ScriptName MyTerminal
Quest Property FaultysMenuComponentsQuest Auto Const Mandatory


Function Foo()
	(FaultysMenuComponentsQuest as FaultysMenuComponentsScript).AddComponents()
EndFunction
Link to comment
Share on other sites

  • Recently Browsing   0 members

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