[VXA] Website Launch from Title 1.0

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Best RPG Maker User (Scripting)2010 Most Mature Member
Website Launch from Title
Version: 1.0
Author: modern algebra
Date: December 11, 2011

Version History


  • <Version 1.0> 2011-12-11 - Original Release

Description


This simple script adds the option to launch a website from a command on the title screen. With this script, you can add multiple commands that open different websites.

Features

  • Can create commands on the Title Menu that, when pressed, will direct the player to a specified URL.
  • Can choose the title of the command and its index in the window
  • Allows you to create more than one of these commands

Screenshots



Instructions

Paste this script into its own slot above Main and below Materials.

Please see the Editable Region at line 27 to gain instructions on how to add a website launch command to the title.

Script


Code: [Select]
#==============================================================================
#    Website Launch from Title [VXA]
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: December 11, 2011
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This simple script adds the option to launch website from a command on
#   the title screen. Only works in Windows, but RMVXA only runs in Windows
#   anyway, so that shouldn't be a problem. With this script, you can add
#   multiple commands that open different websites.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Paste this script into its own slot above Main and below Materials.
#
#    Just go down to the configurable constants area at line 27 and read the
#   instructions there to see how to set up a new website launch command.
#==============================================================================

$imported = {} unless $imported
$imported[:MAWebsiteLaunchTitle] = true

MAWLT_TITLE_WEBSITE_COMMANDS = [
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#  EDITABLE REGION
#``````````````````````````````````````````````````````````````````````````````
#    For each website launching command you want to include, simply add an
#   array at line 45 with the following data, in the following order:
#
#      ["Command Name", index, "url address"]
#
#    "Command Name" is what will show up in the command window itself.
#    index is an integer and it determines in what order the command appears
#    "url address" is the URL opened when the command is pressed.
#
#    If you wish to add more than one website command, you may, but remember to
#   add a comma after all but the last array. It would look like this:
#
#      ["Command Name 1", index, "url address 1"],
#      ["Command Name 2", index, "url address 2"],
#      ["Command Name 3", index, "url address 3"]
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  ["RMRK", 2, "http://rmrk.net"]
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#  END EDITABLE REGION
#//////////////////////////////////////////////////////////////////////////////
]

#==============================================================================
# ** Window_TitleCommand
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - make_command_list; update_placement
#==============================================================================

class Window_TitleCommand
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Make Command List
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_wlft_mkcommands_7yh8 make_command_list
  def make_command_list(*args, &block)
    ma_wlft_mkcommands_7yh8(*args, &block) # Run Original Method
    MAWLT_TITLE_WEBSITE_COMMANDS.each_index { |i|
      website = MAWLT_TITLE_WEBSITE_COMMANDS[i]
      add_command(website[0], "website_launch_#{i}".to_sym)
      @list.insert(website[1], @list.pop)
    }
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Placement
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_wlft_updplace_5fh2 update_placement
  def update_placement(*args, &block)
    ma_wlft_updplace_5fh2(*args, &block) # Run Original Method
    # Make sure title window doesn't go off screen
    self.y = Graphics.height - height if self.y + height > Graphics.height
  end
end

#==============================================================================
# ** Scene_Title
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - create_command_window
#==============================================================================

class Scene_Title
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Command Window
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_wlft_crtcmmndwin_3kj9 create_command_window
  def create_command_window(*args, &block)
    ma_wlft_crtcmmndwin_3kj9(*args, &block) # Run Original Method
    MAWLT_TITLE_WEBSITE_COMMANDS.each_index { |i|
      website = MAWLT_TITLE_WEBSITE_COMMANDS[i]
      @command_window.set_handler("website_launch_#{i}".to_sym,
        lambda {
          Thread.new { system("start #{website[2]}") }
          @command_window.activate
        })
    }
  end
end

Credit


  • modern algebra

Support


Please contact me here at RMRK for support with this script
« Last Edit: December 12, 2011, 12:26:25 AM by modern algebra »

**
Rep: +0/-0Level 64
RMRK Newbie
I discovered that VXA "un expects" ')' and I thought "Hey, why not correct errors by myself?" It worked.
Hope isn't illegal to submit the corrected version  :P
Code: [Select]
#==============================================================================
#    Website Launch from Title [VXA]
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: December 11, 2011
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This simple script adds the option to launch website from a command on
#   the title screen. Only works in Windows, but RMVXA only runs in Windows
#   anyway, so that shouldn't be a problem. With this script, you can add
#   multiple commands that open different websites.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Paste this script into its own slot above Main and below Materials.
#
#    Just go down to the configurable constants area at line 27 and read the
#   instructions there to see how to set up a new website launch command.
#==============================================================================

$imported = {} unless $imported
$imported[:MAWebsiteLaunchTitle] = true

MAWLT_TITLE_WEBSITE_COMMANDS = [
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#  EDITABLE REGION
#``````````````````````````````````````````````````````````````````````````````
#    For each website launching command you want to include, simply add an
#   array at line 45 with the following data, in the following order:
#
#      ["Command Name", index, "url address"]
#
#    "Command Name" is what will show up in the command window itself.
#    index is an integer and it determines in what order the command appears
#    "url address" is the URL opened when the command is pressed.
#
#    If you wish to add more than one website command, you may, but remember to
#   add a comma after all but the last array. It would look like this:
#
#      ["Command Name 1", index, "url address 1"],
#      ["Command Name 2", index, "url address 2"],
#      ["Command Name 3", index, "url address 3"]
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  ["Website", 2, "http://rmrk.net"]
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#  END EDITABLE REGION
#//////////////////////////////////////////////////////////////////////////////
]

#==============================================================================
# ** Window_TitleCommand
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - make_command_list; update_placement
#==============================================================================

class Window_TitleCommand
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Make Command List
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_wlft_mkcommands_7yh8 make_command_list
  def make_command_list(*args, &block)
    ma_wlft_mkcommands_7yh8(*args, &block) # Run Original Method
    MAWLT_TITLE_WEBSITE_COMMANDS.each_index { |i|
      website = MAWLT_TITLE_WEBSITE_COMMANDS[i]
      add_command(website[0], "website_launch_#{i}".to_sym)
      @list.insert(website[1], @list.pop)
    }
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Placement
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_wlft_updplace_5fh2 update_placement
  def update_placement(*args, &block)
    ma_wlft_updplace_5fh2(*args, &block) # Run Original Method
    # Make sure title window doesn't go off screen
    self.y = Graphics.height - height if self.y + height > Graphics.height
  end
end

#==============================================================================
# ** Scene_Title
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - create_command_window
#==============================================================================

class Scene_Title
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Command Window
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_wlft_crtcmmndwin_3kj9 create_command_window
  def create_command_window(*args, &block)
    ma_wlft_crtcmmndwin_3kj9(*args, &block) # Run Original Method
    MAWLT_TITLE_WEBSITE_COMMANDS.each_index { |i|
      website = MAWLT_TITLE_WEBSITE_COMMANDS[i]
      @command_window.set_handler("website_launch_#{i}".to_sym,
        lambda {
          Thread.new { system("start #{website[2]}") }
          @command_window.activate
        })
    }
  end
end
« Last Edit: February 26, 2012, 01:53:01 AM by Woogimember »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Best RPG Maker User (Scripting)2010 Most Mature Member
It's fine to post it, but I am afraid I fail to see any difference aside from your name in the header. As well, there is no error when I test the posted version, so I don't really know what you've purported to fix.
« Last Edit: February 18, 2012, 12:31:04 AM by modern algebra »

*
Rep: +0/-0Level 59
Zennethe Designs
It's fine to post it, but I am afraid I fail to see any difference aside from your name in the header. As well, there is no error when I test the posted version, so I don't really know what you've purported to fix.
I ran the 2 code blocks thru Winmerge... and it reports that the additional credit line on 5 and line 45:
Code: [Select]
["Website", 2, "http://rmrk.net"]

Naughty naughty trying to claim partial credits on something he didn't help with. :/

On topic, I did notice that on my friends computer ( Win 7 home premium ) with certain UAC configurations
it may require the game be ran as an admin to send commands to the browser. Otherwise, on normal default
UAC setting this script works perfectly fine. Good job once again. :)
« Last Edit: February 23, 2012, 04:44:51 AM by Zennethe »

***
hail satan buddy 666
Rep:
Level 55
Blagil VlUE
I using thos script.
[

**
Rep: +0/-0Level 34
RMRK Junior
I really really want to know... How to call this command in game as a script inside an event?
Just so I can trigger the webbrowser opening in game.

To be more specific: what should I copy and paste into... Edit event
                                                                               command @> Scripts:
In order for to call for the web browser to open automatically when triggered in game.



Timberduck

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Best RPG Maker User (Scripting)2010 Most Mature Member
Code: [Select]
site = "http://rmrk.net"
Thread.new { system("start #{site}") }

Just change the site = line and replace the part within the quotation marks with the URL of your website. If the URL is long and requires more than one line in the command box, then it would probably be safest to split it up and do something like this:

Code: [Select]
site = "http://rm"
site += "rk.net"
Thread.new { system("start #{site}") }

**
Rep: +0/-0Level 34
RMRK Junior
OMG... dude thanx

**
Rep: +0/-0Level 34
RMRK Junior
is there a way to get users input
site=gets.chomp
Thread.new { system("start #{site}") }