3 years ago

Here is a tutorial on how to show windows message boxes through a script call in XP/VX/VXAce


If you simply want to show a message on it, then you can use this in a script call:
text = "WHY ARE YOU HERE."

msgbox(sprintf(text))

This will show the windows message like this:

screenshot_2022-11-13_230020.png

But if you want a more custom windows message box with a title that isn't your game's name, then you should use this:

message = "I am a ghost contacting you from the ghost world"

window_name = "Ghost Mail"

icon = 0

mb = Win32API.new("user32","MessageBox",['i','p','p','i'],'i')

mb.call(0, message, window_name, icon)

(If you want to display Unicode characters in your messagebox, make sure to replace "MessageBox" with "MessageBoxW" and add this before the mb.call line:

message.encode!("UTF-16LE")

window_name.encode!("UTF-16LE")

message.force_encoding("UTF-16LE")

window_name.force_encoding("UTF-16LE")

This way you won't have strange symbols on the message box when writing with other types of characters.)

Which will show up in your game like this:

screenshot_2022-11-13_231108.png

The icon stands for the icon the windows message should show. The icons it can show are these ones:

screenshot_2022-11-13_230712.png

Since it's set to zero, it won't show any of the above icons.

However, if you do want to show one, then here are the numbers for each one:

x symbol: 16

warning symbol: 48

lowercase I: 64

question mark: 32

Here is what the message looks like after the icon was set to 48:

ghost.png

If your text is too long then you can use \n to put the text after it on the next line:

message = "I am a ghost contacting you from the ghost world\nHello"

screenshot_2022-11-13_232815.png

If you run out of space on the script call line, you can also do this:

message = "I am a ghost contacting you from the ghost world\n" + "Hello"

However, if you want to use "Yes" and "No" instead of "OK",
then you can set it like this:

window_name = "Ghost Mail"

message = "Do you think I am pretty?"

a = Win32API.new('user32', 'MessageBox', %w(p p p i), 'i')

@r, @rs = a.call(0, message, window_name, 4)

The @r is for Yes and the @rs is for No. The 4 makes the windows message box a choice window.

screenshot_2022-11-13_234033.png

If you want something to happen after you click yes or no, you can just put this in a conditional branch:

screenshot_2022-11-13_234348.png

The message box wont return yes as a string like "Yes" if you click it, but instead returns a 6. Since an @ was put behind the r, it makes the r an instance variable, which means the entire event page will recognize what it is, and not just the script call command alone.

If you want to use different choice buttons (Like Retry or Ignore) then you can look here and replace the 4 with another number which you can find in the Fields section of the site:

https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.messageboxbuttons

And if you want to get the numbers the specific choice buttons return, then you can look at the fields section in here:

https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.dialogresult

#windows #ruby #scripting #rgss #rpgmakervxace #rpgmaker #rpgmakervx #rpgmakerxp



6 comments

Loading...

Next up

Y/N's boss (and he's also her surrogate father just like in the wattpad story) + Time & Date UI that shows minute, hour, day, month, and year.

Y/N desires but a glimpse of the sunlight.... unfortunately, she is not like other girls.

Side Missions where you can assassinate civilians for money and items, requested by corrupt officials and businessmen!

BATTLE SYSTEM IN MY RPG MAKER XP GAME

(srry I forgot to link the post to my game :CC)

#IndieDev #GameDev #videogames #indiegames

Y/N can do whatever she wants in her secret underground hideout as long as she doesn't touch the bombs in the storage room.

After 8 years of development, I am proud to announce that Legends of Celestite Part 1: The All Bearer (Tetsu no bara) has finally been released on Steam, January 30th!

Don't miss out on the -10% launch discount. :)

https://store.steampowered.com/app/1699950/Legends_of_Celestite_…

Train against a Bot whose stats and elemental weaknesses you can modify.

New design for weapon shop that makes the wares more interesting to look at.

After a year of development, The Nian-Xi Chronicles: Prelude is finally released fully! 

Survive an intense gauntlet of labyrinths, battle over 50 uniquely drawn spirits, learn hundreds of skills, and more completely for free in this First Person DRPG!

Weapon Attribute Absorption. Give one weapon an attribute of another weapon.