def show_windows_error(message, title="Error", buttons=0)
# Create a VBScript command to show a message box with customizable title and buttons
vbscript = <<-VB
Set objShell = CreateObject("WScript.Shell")
result = objShell.Popup("#{message}", 0, "#{title}", #{buttons})
' If "OK" is clicked or any button, game will exit
If result >= 1 Then
WScript.Echo "Button clicked, exiting game..."
End If
VB
# Write the VBScript to a temporary file
file = File.open("temp_error.vbs", "w")
file.write(vbscript)
file.close
# Run the VBScript using the system command
system("cscript //nologo temp_error.vbs")
# Delete the temporary VBScript file after use
File.delete("temp_error.vbs")
# Close the game after the error is acknowledged
SceneManager.exit
end Click to expand...
How to Use:
Paste the Script: Paste the entire script into the Script Editor of your RPG Maker VX Ace project.
Call the Script in an Event:
In an event, use the Script command and call the show_windows_error function.
Example
show_windows_error("Error's mean", "Title", 4)
Testing: When the event is triggered:
A Windows error message will appear with your custom message, title and icon.