Added <system.scripttrigger>

Returns what triggered the current script (NPCInSight, NPCInteract, ScriptBlockWalkOn, ScriptBlockInteract, Notification, PhoneReceive, PhoneCall, StartScript, ScriptCommand, StrengthTrigger, MapScript, ChatCommand).
This commit is contained in:
JappaWakka 2023-08-06 16:17:05 +02:00
parent d9473e5454
commit 78cd53d745
12 changed files with 44 additions and 26 deletions

View File

@ -87,6 +87,10 @@
If Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
Dim oS As OverworldScreen = CType(Core.CurrentScreen, OverworldScreen)
Dim scriptTrigger As String = "ScriptBlockWalkOn"
If Me.clickedToActivate = True Then
scriptTrigger = "ScriptBlockInteracted"
End If
If oS.ActionScript.IsReady = True Or canAttach = True Then
If Me.CorrectRotation() = True Then
If Me.clickedToActivate = True Then
@ -94,9 +98,9 @@
SoundManager.PlaySound("select")
End If
If Me.TriggerID = 2 Then
oS.ActionScript.StartScript(Me.AdditionalValue, GetActivationID())
oS.ActionScript.StartScript(Me.AdditionalValue, GetActivationID(),,, scriptTrigger)
Else
oS.ActionScript.StartScript(Me._scriptID, GetActivationID())
oS.ActionScript.StartScript(Me._scriptID, GetActivationID(),,, scriptTrigger)
ActionScript.TempSpin = True
End If
End If

View File

@ -55,7 +55,7 @@
End If
If ActivateScript <> "" Then
If Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(Me.ActivateScript, 0, False)
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(Me.ActivateScript, 0, False,, "StrengthTrigger")
End If
End If

View File

@ -302,13 +302,13 @@
SoundManager.PlaySound("select")
Select Case Me.ActionValue
Case 0
oScreen.ActionScript.StartScript(Me.AdditionalValue, 1)
oScreen.ActionScript.StartScript(Me.AdditionalValue, 1,,, "NPCInteract")
Case 1
oScreen.ActionScript.StartScript(Me.AdditionalValue, 0)
oScreen.ActionScript.StartScript(Me.AdditionalValue, 0,,, "NPCInteract")
Case 3
oScreen.ActionScript.StartScript(Me.AdditionalValue.Replace("<br>", Environment.NewLine), 2)
oScreen.ActionScript.StartScript(Me.AdditionalValue.Replace("<br>", Environment.NewLine), 2,,, "NPCInteract")
Case Else
oScreen.ActionScript.StartScript(Me.AdditionalValue, 0)
oScreen.ActionScript.StartScript(Me.AdditionalValue, 0,,, "NPCInteract")
End Select
End If
End Sub
@ -438,10 +438,8 @@
End If
End With
Screen.Level.OwnPlayer.Opacity = 0.5F
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(s, 2)
ActionScript.IsInsightScript = True
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(s, 2,,, "NPCInSight")
ActionScript.IsInSightScript = True
End If
End If
End If

View File

@ -199,7 +199,7 @@
If s.Identification = Screen.Identifications.OverworldScreen Then
If testForScript = False Then
CType(s, OverworldScreen).ActionScript.StartScript("version=2" & Environment.NewLine & text & Environment.NewLine & ":end", 2, False)
CType(s, OverworldScreen).ActionScript.StartScript("version=2" & Environment.NewLine & text & Environment.NewLine & ":end", 2, False,, "ChatCommand")
End If
Return text

View File

@ -131,7 +131,7 @@ Public Class NotificationPopup
If Me._positionY <= BackY Then
Me._positionY = BackY
If Me._scriptFile <> "" Then
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(Me._scriptFile, 0, False)
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(Me._scriptFile, 0, False,, "Notification")
End If
Me.IsReady = True
End If

View File

@ -166,14 +166,14 @@ Public Class OverworldScreen
Public Overrides Sub Update()
If GameModeManager.ActiveGameMode.StartScript <> "" AndAlso ActionScript.IsReady AndAlso Not GlobalGameModeScriptStarted Then
ActionScript.reDelay = 0.0F
ActionScript.StartScript(GameModeManager.ActiveGameMode.StartScript, 0)
ActionScript.StartScript(GameModeManager.ActiveGameMode.StartScript, 0,,, "StartScript")
GlobalGameModeScriptStarted = True
End If
'If the MapScript has a value loaded from the MapScript map tag and there is no script running, start that script:
If LevelLoader.MapScript <> "" And ActionScript.IsReady = True Then
ActionScript.reDelay = 0.0F
ActionScript.StartScript(LevelLoader.MapScript, 0)
ActionScript.StartScript(LevelLoader.MapScript, 0,,, "MapScript")
LevelLoader.MapScript = "" 'Reset the MapScript.
End If

View File

@ -1364,7 +1364,7 @@
Player.Temp.PokegearPage = Me.menuIndex
Core.SetScreen(Me.PreScreen)
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript("phone\" & chosenID, 0)
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript("phone\" & chosenID, 0,,, "PhoneCall")
End Sub
Private Sub InitializePhone()
@ -1448,7 +1448,7 @@
Call_Flag = "receiving"
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript("phone\" & chosenID, 0)
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript("phone\" & chosenID, 0,,, "PhoneReceiving")
End If
End Sub
@ -1501,7 +1501,7 @@
Call_Flag = "receiving"
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript("phone\" & chosenID, 0)
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript("phone\" & chosenID, 0,,, "PhoneReceiving")
End If
End Sub

View File

@ -92,15 +92,25 @@ nextScript:
End If
End Get
End Property
Private Shared _scriptTrigger As String = ""
Public Shared Property ScriptTrigger() As String
Get
Return _scriptTrigger
End Get
Set(value As String)
_scriptTrigger = value
End Set
End Property
Public Shared IsInsightScript As Boolean = False
Public Shared IsInSightScript As Boolean = False
''' <summary>
''' Starts a script.
''' </summary>
''' <param name="Input">The input string.</param>
''' <param name="InputType">Type of information; 0: Script path, 1: Text, 2: Direct input.</param>
Public Sub StartScript(ByVal Input As String, ByVal InputType As Integer, Optional ByVal CheckDelay As Boolean = True, Optional ByVal ResetInsight As Boolean = True)
Public Sub StartScript(ByVal Input As String, ByVal InputType As Integer, Optional ByVal CheckDelay As Boolean = True, Optional ByVal ResetInsight As Boolean = True, Optional ScriptTrigger As String = "")
Screen.Level.OwnPlayer.Opacity = 1
If Core.Player.IsRunning = True OrElse Screen.Level.Riding = True Then
Screen.Camera.Speed = 0.04F
@ -114,8 +124,10 @@ nextScript:
Dim l As ScriptLevel = ScriptLevels(ScriptLevelIndex)
ActionScript.ScriptTrigger = ScriptTrigger
If ResetInsight = True Then
IsInsightScript = False
IsInSightScript = False
End If
If reDelay = 0.0F Or CheckDelay = False Then

View File

@ -13,11 +13,11 @@
If Core.CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
Select Case command.ToLower()
Case "start"
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(argument, 0, True, False)
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(argument, 0, True, False, "ScriptCommand")
Case "text"
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(argument, 1, True, False)
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(argument, 1, True, False, "ScriptCommand")
Case "run"
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(argument, 2, True, False)
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(argument, 2, True, False, "ScriptCommand")
End Select
End If

View File

@ -77,6 +77,8 @@
buttonName = KeyBindings.GetKeyName(key)
End If
Return buttonName
Case "scripttrigger"
Return ActionScript.ScriptTrigger
Case "random"
Dim minRange As Integer = 1
Dim maxRange As Integer = 2
@ -130,7 +132,7 @@
Return DefaultNull
Case "isinsightscript"
Return ReturnBoolean(ActionScript.IsInsightScript)
Return ReturnBoolean(ActionScript.IsInSightScript)
Case "lastinput"
Return InputScreen.LastInput
Case "return"

View File

@ -411,7 +411,8 @@ Namespace ScriptVersion2
r(New ScriptCommand("system", "sort", "str", {New ScriptArgument("sortMode", ScriptArgument.ArgumentTypes.Str, {"ascending", "descending"}),
New ScriptArgument("returnIndex", ScriptArgument.ArgumentTypes.Int),
New ScriptArgument("list", ScriptArgument.ArgumentTypes.Arr)}.ToList(), "Sorts the list after sortmode and returns the item at the given index.", ",", True))
r(New ScriptCommand("system", "isinsightscript", "bool", "Returns if the running script was triggred by the inSight function of an NPC.", ",", True))
r(New ScriptCommand("system", "ScriptTrigger", "string", "Returns what triggered the current script (NPCInSight, NPCInteract, ScriptBlockWalkOn, ScriptBlockInteract, Notification, PhoneReceive, PhoneCall, StartScript, ScriptCommand, StrengthTrigger, MapScript, ChatCommand).", ",", True))
r(New ScriptCommand("system", "IsInSightScript", "bool", "Returns if the running script was triggered by the inSight function of an NPC.", ",", True))
r(New ScriptCommand("system", "lastinput", "str", "Returns the last input received from the input screen (@screen.input).", ",", True))
r(New ScriptCommand("system", "return", "str", "Returns the value set with the "":return"" switch.", ",", True))
r(New ScriptCommand("system", "isint", "bool", {New ScriptArgument("expression", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Checks if the expression is an integer (Outdated, use <math.isint> instead).", ",", True))

View File

@ -94,6 +94,7 @@
Public Sub EndScript(ByVal forceEnd As Boolean)
ActionScript.ScriptLevelIndex -= 1
ActionScript.ScriptTrigger = ""
If ActionScript.ScriptLevelIndex = -1 Or forceEnd = True Then
ActionScript.ScriptLevelIndex = -1
Dim oS As OverworldScreen = CType(Core.CurrentScreen, OverworldScreen)