Revisiting Yanfly’s Menu To Open a URL

I’ve already talked about Yanfly’s Menu Manager once before. If you haven’t already, go check out my post on it! You’ll be glad you did!

Today, I want to show you how to use that to do a fun little trick. In Vidar, I’ve added a menu option for “Feedback.” When selected, the game minimizes and opens up a google form! This is in fact just a URL that opens in your browser. You might guess that this has implications well beyond a simple feedback form. For example, you could use it to link the player to a wiki or walkthrough!

Make sureyou have Yanfly’s Menu Manager installed, and let’s get started.

Open_URL

Make a new section of script in RPG Maker, and add the following:

def open_url(filename)
     shell = Win32API.new("shell32", "ShellExecute", ['L', 'P', 'P', 'P', 'P', 'L'], 'L')
     shell.Call(0, "open", filename, 0, 0, 1)
end

This is a little script that will take whatever URL we give it and open that in your browser! Pretty handy right?

We trigger it by just calling

open_url(" ")

and putting the web address in the quotes.

Common Event

So, make a common event that does just that! In the contents, use a script call, and call open_url with your web address.

Feedback1

And incidentally, visit http://www.vidarthegame.com for your regular dose of Vidaryness.

Make a note of the ID of your common event. It’ll be next to the event name in the column on the left.

Add It To the Menu

In Yanfly’s Menu Manager, scroll down to COMMON_EVENT_COMMANDS. Add an event (here I’ve got two) with the display name you want. If you want the link always available, set Enable and Show switches to 0. And add the ID of the common event you created above. Something like this:

Here it's event_2, because I already used event_1 for reset.

Here it’s event_2, because I already used event_1 for reset.

Next, scroll up a little bit and add the :command name to your list of commands. Something like this:

Where you place the event_2 in this list will determine the order it shows up in your menu.

Where you place the event_2 in this list will determine the order it shows up in your menu.

And that’s it! Now when you open your menu in game, the entry will be right in the menu. Click it and the link will automatically be opened in the player’s browser.

You can use the switches discussed above to control whether the menu item is shown or grayed out as well.

You can use the switches discussed above to control whether the menu item is shown or grayed out as well.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s