Replaced script steps thing with @script.delay

@Script.Delay(ScriptPath,DelayType,DelayValue)
Executes a script file after something happened (like having moved a certain amount of steps)

@Script.ClearDelay(ScriptPath,DelayType,DelayValue)
Clears the register created with @script.delay, preventing the script from being executed.

<script.delay(ReturnType)>
Returns a different thing depending on what you write for ReturnType:
"type" - returns what kind of trigger the script delay uses (only "steps" atm)
"script" - returns the script that will be executed after the delay ended
"value" - returns when the trigger ends, like how many steps are left for example
This commit is contained in:
JappaWakka 2023-10-30 13:28:30 +01:00
parent dae406f887
commit c0101a122a
8 changed files with 103 additions and 40 deletions

View File

@ -32738,6 +32738,7 @@
<Compile Include="World\ActionScript\V2\ScriptConstructs\DoRadio.vb" />
<Compile Include="World\ActionScript\V2\ScriptConstructs\DoRegister.vb" />
<Compile Include="World\ActionScript\V2\ScriptConstructs\DoRival.vb" />
<Compile Include="World\ActionScript\V2\ScriptConstructs\DoScript.vb" />
<Compile Include="World\ActionScript\V2\ScriptConstructs\DoStorage.vb" />
<Compile Include="World\ActionScript\V2\ScriptConstructs\DoSystem.vb" />
<Compile Include="World\ActionScript\V2\ScriptLibrary.vb" />

View File

@ -151,12 +151,12 @@
End Set
End Property
Public Property ScriptSteps() As Integer
Public Property ScriptDelaySteps() As Integer
Get
Return _scriptSteps
Return _ScriptDelaySteps
End Get
Set(value As Integer)
_scriptSteps = value
_ScriptDelaySteps = value
End Set
End Property
@ -408,7 +408,7 @@
Private _lastSavePlace As String = "yourroom.dat"
Private _lastSavePlacePosition As String = "1,0.1,3"
Private _repelSteps As Integer = 0
Private _scriptSteps As Integer = 0
Private _ScriptDelaySteps As Integer = 0
Private _saveCreated As String = "Pre 0.21"
Private _daycareSteps As Integer = 0
Private _poisonSteps As Integer = 0
@ -859,8 +859,8 @@
End If
Case "repelsteps"
RepelSteps = CInt(Value)
Case "scriptsteps"
ScriptSteps = CInt(Value)
Case "scriptdelaysteps"
ScriptDelaySteps = CInt(Value)
Case "lastsaveplace"
LastSavePlace = Value
Case "lastsaveplaceposition"
@ -1359,7 +1359,7 @@
"LastRestPlacePosition|" & LastRestPlacePosition & Environment.NewLine &
"DiagonalMovement|" & DiagonalMovement.ToNumberString() & Environment.NewLine &
"RepelSteps|" & RepelSteps.ToString() & Environment.NewLine &
"ScriptSteps|" & ScriptSteps.ToString() & Environment.NewLine &
"ScriptDelaySteps|" & ScriptDelaySteps.ToString() & Environment.NewLine &
"LastSavePlace|" & LastSavePlace & Environment.NewLine &
"LastSavePlacePosition|" & LastSavePlacePosition & Environment.NewLine &
"Difficulty|" & DifficultyMode.ToString() & Environment.NewLine &
@ -1887,28 +1887,33 @@
End Sub
Private Sub StepEventCheckScript(ByVal stepAmount As Integer)
If ScriptSteps > 0 Then
ScriptSteps -= stepAmount
If ScriptDelaySteps > 0 Then
ScriptDelaySteps -= stepAmount
If ScriptSteps <= 0 Then
If ScriptDelaySteps <= 0 Then
If CurrentScreen.Identification = Screen.Identifications.OverworldScreen Then
If CanFireStepEvent() = True Then
Dim registerContent() As Object = ActionScript.GetRegisterValue("SCRIPTSTEPS")
If ActionScript.IsRegistered("SCRIPTDELAY") = True Then
Dim registerContent() As Object = ActionScript.GetRegisterValue("SCRIPTDELAY")
If registerContent(0) Is Nothing Or registerContent(1) Is Nothing Then
Logger.Log(Logger.LogTypes.Warning, "ScriptComparer.vb: No valid script has been set to be executed.")
ActionScript.UnregisterID("SCRIPTSTEPS", "str")
ActionScript.UnregisterID("SCRIPTSTEPS")
Exit Sub
If registerContent(0) Is Nothing Or registerContent(1) Is Nothing Then
Logger.Log(Logger.LogTypes.Warning, "ScriptComparer.vb: No valid script has been set to be executed.")
ActionScript.UnregisterID("SCRIPTDELAY", "str")
ActionScript.UnregisterID("SCRIPTDELAY")
Exit Sub
End If
Dim DelayType As String = CStr(registerContent(0)).GetSplit(0, ";")
If DelayType.ToLower = "steps" Then
Dim DelayValue As String = CStr(registerContent(0)).GetSplit(1, ";")
CType(CurrentScreen, OverworldScreen).ActionScript.StartScript(DelayValue, 0, False)
ActionScript.UnregisterID("SCRIPTDELAY", "str")
ActionScript.UnregisterID("SCRIPTDELAY")
End If
End If
Dim lValue As String = CStr(registerContent(0))
CType(CurrentScreen, OverworldScreen).ActionScript.StartScript(lValue, 0, False)
ActionScript.UnregisterID("SCRIPTSTEPS", "str")
ActionScript.UnregisterID("SCRIPTSTEPS")
Else
ScriptSteps = 1
ScriptDelaySteps = 1
End If
End If
End If

View File

@ -376,18 +376,6 @@
Dim newOpacity As Single = sng(argument.Replace("~", Screen.Level.OwnPlayer.Opacity.ToString().Replace(".", GameController.DecSeparator)))
Screen.Level.OwnPlayer.Opacity = newOpacity
IsReady = True
Case "setscriptsteps"
If argument.Contains(",") = True Then
Dim args() As String = argument.Split(CChar(","))
Core.Player.ScriptSteps = CInt(args(0))
ActionScript.RegisterID("SCRIPTSTEPS", "str", args(1))
End If
IsReady = True
Case "clearscriptsteps"
ActionScript.UnregisterID("SCRIPTSTEPS", "str")
ActionScript.UnregisterID("SCRIPTSTEPS")
Core.Player.ScriptSteps = 0
IsReady = True
Case Else
IsReady = True
End Select

View File

@ -18,6 +18,26 @@
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(argument, 1, True, False, "ScriptCommand")
Case "run"
CType(Core.CurrentScreen, OverworldScreen).ActionScript.StartScript(argument, 2, True, False, "ScriptCommand")
Case "delay"
If argument.Contains(",") = True Then
ActionScript.UnregisterID("SCRIPTDELAY", "str")
ActionScript.UnregisterID("SCRIPTDELAY")
Core.Player.ScriptDelaySteps = 0
Dim args() As String = argument.Split(CChar(","))
Select Case args(1).ToLower
Case "steps"
Core.Player.ScriptDelaySteps = CInt(args(2))
End Select
ActionScript.RegisterID("SCRIPTDELAY", "str", CStr(args(1) & ";" & args(0)))
End If
IsReady = True
Case "cleardelay"
ActionScript.UnregisterID("SCRIPTDELAY", "str")
ActionScript.UnregisterID("SCRIPTDELAY")
Core.Player.ScriptDelaySteps = 0
IsReady = True
End Select
End If

View File

@ -307,6 +307,8 @@ Namespace ScriptVersion2
Return DoFileSystem(subClass)
Case "screen"
Return DoScreen(subClass)
Case "script"
Return DoScript(subClass)
End Select
Return DefaultNull
End Function

View File

@ -127,8 +127,6 @@
ReturnBoolean(Core.Player.IsGameJoltSave = True AndAlso GameJolt.LogInScreen.UserBanned(GameJoltSave.GameJoltID) = False)
End If
Return ReturnBoolean(Core.Player.IsGameJoltSave)
Case "scriptsteps"
Return Core.Player.ScriptSteps
End Select
Return DEFAULTNULL
End Function

View File

@ -0,0 +1,47 @@
Namespace ScriptVersion2
Partial Class ScriptComparer
' --------------------------------------------------------------------------------------------------------------------------
' Contains the <script> constructs.
' --------------------------------------------------------------------------------------------------------------------------
Private Shared Function DoScript(ByVal subClass As String) As Object
Dim command As String = GetSubClassArgumentPair(subClass).Command
Dim argument As String = GetSubClassArgumentPair(subClass).Argument
Select Case command.ToLower()
Case "delay"
If ActionScript.IsRegistered("SCRIPTDELAY") = True Then
Dim registerContent() As Object = ActionScript.GetRegisterValue("SCRIPTDELAY")
If registerContent(0) Is Nothing Or registerContent(1) Is Nothing Then
Logger.Log(Logger.LogTypes.Warning, "ScriptComparer.vb: No valid script has been set to be executed.")
ActionScript.UnregisterID("SCRIPTDELAY", "str")
ActionScript.UnregisterID("SCRIPTDELAY")
Return DefaultNull
End If
Select Case argument.ToLower
Case "type"
Return CStr(registerContent(0)).GetSplit(0, ";")
Case "script"
Return CStr(registerContent(0)).GetSplit(1, ";")
Case "value"
Dim DelayType As String = CStr(registerContent(0)).GetSplit(0, ";")
Select Case DelayType
Case "steps"
Return Core.Player.ScriptDelaySteps
End Select
End Select
End If
End Select
Return DefaultNull
End Function
End Class
End Namespace

View File

@ -359,6 +359,11 @@ Namespace ScriptVersion2
r(New ScriptCommand("script", "start", {New ScriptArgument("scriptFile", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Starts a script with the given filename (without file extension)."))
r(New ScriptCommand("script", "text", {New ScriptArgument("text", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Starts a script with a simple text to display."))
r(New ScriptCommand("script", "run", {New ScriptArgument("scriptContent", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Runs script content. New lines are represented with ""^""."))
r(New ScriptCommand("script", "delay", {New ScriptArgument("scriptPath", ScriptArgument.ArgumentTypes.Str), New ScriptArgument("delayType", ScriptArgument.ArgumentTypes.Str, {"steps"}), New ScriptArgument("delayValue", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Executes a script file after something happened (like having moved a certain amount of steps)."))
r(New ScriptCommand("script", "delay", "Clears the register created with @script.delay, preventing the script from being executed."))
' Constructs:
r(New ScriptCommand("script", "delay", "str,int", {New ScriptArgument("type", ScriptArgument.ArgumentTypes.Str, {"type", "script", "value"})}.ToList(), "Returns the ""type"", ""scriptpath"" or ""value"" of what will trigger the script, like the number of steps.", ",", True))
End Sub
Private Shared Sub DoRegister()
@ -518,8 +523,6 @@ Namespace ScriptVersion2
r(New ScriptCommand("player", "setrivalname", {New ScriptArgument("name", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Sets the rival's name."))
r(New ScriptCommand("player", "setrivalskin", {New ScriptArgument("skin", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Sets the rival's skin."))
r(New ScriptCommand("player", "setopacity", {New ScriptArgument("opacity", ScriptArgument.ArgumentTypes.Sng)}.ToList(), "Sets the player entity's opacity."))
r(New ScriptCommand("player", "setscriptsteps", {New ScriptArgument("stepAmount", ScriptArgument.ArgumentTypes.Int), New ScriptArgument("scriptPath", ScriptArgument.ArgumentTypes.Str)}.ToList(), "Executes a script file after having moved the given amount of steps."))
r(New ScriptCommand("player", "clearscriptsteps", "Clears the register created with @player.setscriptsteps, preventing the script from being executed."))
' Constructs:
r(New ScriptCommand("player", "position", "sngarr", {New ScriptArgument("coordinate", ScriptArgument.ArgumentTypes.StrArr, {"x", "y", "z"}, True, "")}.ToList(), "Returns the position of the player. The normal coordinate combination is ""X,Y,Z"".", ",", True))
@ -545,7 +548,6 @@ Namespace ScriptVersion2
r(New ScriptCommand("player", "gamejoltid", "str", "Returns the player's GameJolt ID.", ",", True))
r(New ScriptCommand("player", "haspokedex", "bool", "Returns if the player received the Pokédex.", ",", True))
r(New ScriptCommand("player", "haspokegear", "bool", "Returns if the player received the Pokégear.", ",", True))
r(New ScriptCommand("player", "scriptsteps", "int", "Returns the amount of steps before the script as defined by @player.setscriptsteps is executed.", ",", True))
End Sub
Private Shared Sub DoNPC()