Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

HTML Links Within Your Game

HTML Link
Version: 1.05

Introduction

This script will allow you to include links to webpages within your game and will open these webpages in the player's default web browser. To do this, simply call the following command:
Code:
A.href('name.of.webpage')
and replace 'name.of.webage' with the address of the webpage. Make sure it is entered as a string.
Examples:
Code:
A.href('www.google.com') #Opens Google's homepage in the default browser
A.href('http://www.google.com') # does the same
A.href('http://google.com') # and again
A.href('google.com') # yep, still Google's homepage

Screenshots

You open a webpage from within a game using the player's default web browser. You can see it, can't you?

Demo

Hosted by Geocities
Hosted in the Download Manager

Script

Code:
#=============================================================================
# ** HTML Link
#-----------------------------------------------------------------------------
# Draycos Goldaryn
# 1.05
# 07/02/07
# SDK Version : 2.2 - Part 1
#-----------------------------------------------------------------------------
# This script will allow you to include links to webpages within your game
# and will open these webpages in the player's default web browser.
# To do this, simply call the following command:
#    A.href('name.of.webpage')
# and replace 'name.of.webage' with the address of the webpage. Make sure it
# is entered as a string.
# Examples:
#   A.href('www.google.com') #Opens Google's homepage in the default browser
#   A.href('http://www.google.com') # does the same
#   A.href('http://google.com') # and again
#   A.href('google.com') # yep, still Google's homepage
#=============================================================================

#-----------------------------------------------------------------------------
# * SDK Log Script
#-----------------------------------------------------------------------------
SDK.log('HTML Link', 'Draycos Goldaryn', 1.05, '07/02/07')
SDK.check_requirements(2.20, [1], {'Aleworks Library' => 1.00})

#-----------------------------------------------------------------------------
# * Begin SDK Enable Test
#-----------------------------------------------------------------------------
if SDK.enabled?('HTML Link')

module A
  #--------------------------------------------------------------------------
  # ? instance variables
  #--------------------------------------------------------------------------
  attr_reader :browser
  attr_reader :browser_path

  #--------------------------------------------------------------------------
  # ? initialize
  #--------------------------------------------------------------------------
  def initialize
    @HLM = 'HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet'
    @browser = Aleworks::Registry.read_entry(@HLM, '')
    @HLM = 'HKEY_LOCAL_MACHINE' + '\\' + @HLM + '\\'
    @HLM += @browser + '\shell\open\command'
    @browser_path = Aleworks::Registry.read_entry(@HLM, '')
  end

  #--------------------------------------------------------------------------
  # ? a.href('name.of.webpage')
  #--------------------------------------------------------------------------
  def href(link)
    if link.is_a?(String)
      Thread.start{system(@browser_path, link)}
    else
      print 'Invalid command. Webpage must be entered as a string.'
    end
  end

  #--------------------------------------------------------------------------
  # ? module functions
  #--------------------------------------------------------------------------
  module_function :initialize
  module_function :href
end
A.initialize

#-----------------------------------------------------------------------------
# * End SDK Enable Test
#-----------------------------------------------------------------------------
end
This also requires SDK 2.2 part I and Aleworks Library

Instructions
Installation:
Insert the scripts in this order:
Default Scripts
SDK
Aleworks Library
HTML Link
Main​

Usage:
Simple: just call
A.href('name.of.webpage')
Just remember to change 'name.of.webpage' with, you guessed it, the http address of the webpage.

FAQ

Q: My game crashes when I use the command!
A: Make sure you enter the webpage address as a string.

Q: Why can't I open webpages with long names?
A: If you are calling this script from an event, split the string in the following format:
Code:
A.href('http://www.google.com/' +
'search?q=RPG+Maker+XP')

Compatibility

There shouldn't be any compatablitity issues, though it does require Part 1 of the SDK 2.2 or greater, and Aleworks Library version 1.00

Credits and Thanks

Thanks to the SDK team, and to Aleworks (aka vgvgf).

Terms and Conditions

Free to use, just credit Draycos Goldaryn.
Also credit Aleworks for his library.
Yes, you can use it in a commercial game. Only credit is required.

Notes

Wow, this script has gone international! I randomly google my name at times and i found a link to a planetarpg.com.ar but the thread where my script was posted must have been deleted :( I also found a link to a polish site where they also posted my script and even provided a link to the demo located in the download manager!

If anyone else knows of other sites where this script has been posted, can you let me know? If anyone else wants to post this script on another site, feel free, just, please, let me know too. And don't forget to provide the proper credit!
 
At last you have released this script. It's nice, and not only because it is usefull, it's nice because uses my scripts, too.
Some things:
You can use constants insteand of "@" variables(I don't remember the name of the @ variables...), so you can remove the attr_readers and A.initialize.
And the other thing, is that you can use one module_function before the definitions methods, insteand of using it for each method.
 
Hijj!
i think this script isnt bad coded, but isnt there a other function how u can call the internet explorer directly with a syntax?

q_q
i have that syntax at home in a game, so i can send u that at weekend, its something like
system("explorer","www.google.com")
or like that xD
maybe u know it ^^

MfG
Guko
 
that is what he uses, except he calls the path,. There is a simple way to do it of course, its in the Ruby Help File :p. but he looks for the default browser ;). Useful script.

btw, if you declare module_function right before the first method, you don't have to use : methodName. I might be wrong but thats how I remember it, don't have RMXP in this PC...
 
Gukosowa;238178":2k76mojx said:
Hijj!
i think this script isnt bad coded, but isnt there a other function how u can call the internet explorer directly with a syntax?

q_q
i have that syntax at home in a game, so i can send u that at weekend, its something like
system("explorer","www.google.com")
or like that xD
maybe u know it ^^

MfG
Guko

As Mr. Mo stated, This script uses the player's default browser, in case they don't want to use internet explorer. For example, I disabled my intenet explorer because of all the stupid adware pop ups that keep popping up even after running adware removal programs. I only use Firefox, so if I played your game and it tried to open a link in iexplorer, It would not work. but if I used my script, it would see that Firefox is my default browser and open the webpage in there.

Mr.Mo;238313":2k76mojx said:
btw, if you declare module_function right before the first method, you don't have to use : methodName. I might be wrong but thats how I remember it, don't have RMXP in this PC...

Since I'm still very new to scripting, I have to look at other scripts to get the basics down. I sort of modeled this one off of Selwyn's Resolution Script.
 
Wow, this script will be so useful, especially for people with a website for their game.

One question: am I allowed to use this script in a commercial game?
 
Wow, this script has gone international! I randomly google my name at times and I found a link to a planetarpg.com.ar but the thread where my script was posted must have been deleted :( I also found a link to a polish site where they also posted my script and even provided a link to the demo located in the download manager!

If anyone else knows of other sites where this script has been posted, can you let me know? If anyone else wants to post this script on another site, feel free, just, please, let me know too. And don't forget to provide the proper credit!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top