KOpenWeb
#1
KOpenWeb

XP + VX + ACE

by Kyonides Arkanthes


Introduction

Did you ever need to open the URL of your game's website?
Well, now there is a chance to do it! Grinning
Just copy this scriptlet of mine and paste it below Scene_Debug.


XP Version

Code:
# * KOpenWeb XP * #
#   Scripter : Kyonides Arkanthes
#   2023-01-25

# This script is FREE as in BEER.
# It is distributed AS IS.
# No further changes will be added.

# Since most developers will only include a link to their own webiste,
# I crafted this scriptlet to let them open the default web browser via
# triggering the custom "Open My Website" command.
# The player will not notice any changes till the web browser finally opens.
# Feel free to customize the CONSTANTS found in the KOpenWeb module.

module KOpenWeb
  COMMAND_NEW = "New Game"
  COMMAND_WEB = "Save-Point"
  COMMAND_CONTINUE = "Continue"
  COMMAND_END = "Shutdown"
  COMMANDS = [COMMAND_NEW, COMMAND_CONTINUE, COMMAND_WEB, COMMAND_END]
  WEBSITE_URL = "https://www.save-point.org/"
end

class Scene_Title
  include KOpenWeb
  alias :kyon_open_website_scn_title_up :update
  def load_data_files
    $data_actors        = load_data("Data/Actors.rxdata")
    $data_classes       = load_data("Data/Classes.rxdata")
    $data_skills        = load_data("Data/Skills.rxdata")
    $data_items         = load_data("Data/Items.rxdata")
    $data_weapons       = load_data("Data/Weapons.rxdata")
    $data_armors        = load_data("Data/Armors.rxdata")
    $data_enemies       = load_data("Data/Enemies.rxdata")
    $data_troops        = load_data("Data/Troops.rxdata")
    $data_states        = load_data("Data/States.rxdata")
    $data_animations    = load_data("Data/Animations.rxdata")
    $data_tilesets      = load_data("Data/Tilesets.rxdata")
    $data_common_events = load_data("Data/CommonEvents.rxdata")
    $data_system        = load_data("Data/System.rxdata")
  end

  def main
    if $BTEST
      battle_test
      return
    end
    load_data_files
    $game_system = Game_System.new
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.title($data_system.title_name)
    make_command_window
    check_saved_games
    handle_audio
    loop do
      Graphics.update
      Input.update
      update
      break if $scene != self
    end
    terminate
  end

  def make_command_window
    @command_window = Window_Command.new(192, COMMANDS)
    @command_window.back_opacity = 160
    @command_window.x = 320 - @command_window.width / 2
    @command_window.y = 288
    @continue_enabled = false
    @new_cmd_pos = COMMANDS.index(COMMAND_NEW)
    @load_cmd_pos = COMMANDS.index(COMMAND_CONTINUE)
    @web_cmd_pos = COMMANDS.index(COMMAND_WEB)
    @end_cmd_pos = COMMANDS.index(COMMAND_END)
  end

  def check_saved_games
    for i in 0..3
      if FileTest.exist?("Save#{i+1}.rxdata")
        @continue_enabled = true
        break
      end
    end
    if @continue_enabled
      @command_window.index = @load_cmd_pos
    else
      @command_window.disable_item(@load_cmd_pos)
    end
  end

  def handle_audio
    $game_system.bgm_play($data_system.title_bgm)
    Audio.me_stop
    Audio.bgs_stop
    Graphics.transition
  end

  def terminate
    Graphics.freeze
    @command_window.dispose
    @sprite.bitmap.dispose
    @sprite.dispose
  end

  def update
    @command_window.update
    if Input.trigger?(Input::C)
      case @command_window.index
      when @load_cmd_pos
        command_continue
      when @new_cmd_pos
        command_new_game
      when @web_cmd_pos
        command_open_url
      when @end_cmd_pos
        command_shutdown
      end
    end
  end

  def command_open_url
    $game_system.se_play($data_system.decision_se)
    Thread.new{ system("open " + WEBSITE_URL) }
  end
end


VX Version

Code:
# * KOpenWeb VX * #
#   Scripter : Kyonides Arkanthes
#   2023-01-25

# This script is FREE as in BEER.
# It is distributed AS IS.
# No further changes will be added.

# Since most developers will only include a link to their own webiste,
# I crafted this scriptlet to let them open the default web browser via
# triggering the custom "Open My Website" command.
# The player will not notice any changes till the web browser finally opens.
# Feel free to customize the CONSTANTS found in the KOpenWeb module.

module KOpenWeb
  COMMAND_TEXT = "RMW Forums"
  # Options: :new, :load, :web, :shut
  COMMAND_ORDER = [:new, :load, :web, :shut]
  WEBSITE_URL = "https://forums.rpgmakerweb.com/index.php"
end

class Scene_Title
  include KOpenWeb
  def next_command(sym)
    case sym
    when :new
      @new_game_pos = @options.size
      @options << Vocab.new_game
    when :load
      @continue_pos = @options.size
      @options << Vocab.continue
    when :web
      @website_pos = @options.size
      @options << COMMAND_TEXT
    when :shut
      @shutdown_pos = @options.size
      @options << Vocab.shutdown
    end
  end

  def create_command_window
    @options = []
    COMMAND_ORDER.each{|cmd| next_command(cmd) }
    @command_window = Window_Command.new(172, @options)
    @command_window.x = (544 - @command_window.width) / 2
    @command_window.y = 248
    if @continue_enabled
      @command_window.index = @continue_pos
    else
      @command_window.draw_item(@continue_pos, false)
    end
    @command_window.openness = 0
    @command_window.open
  end

  def update
    super
    @command_window.update
    if Input.trigger?(Input::C)
      case @command_window.index
      when @new_game_pos
        command_new_game
      when @continue_pos
        command_continue
      when @website_pos
        command_open_url
      when @shutdown_pos
        command_shutdown
      end
    end
  end

  def command_open_url
    Sound.play_decision
    Thread.new{ system("open " + WEBSITE_URL) }
  end
end


VX ACE Version

Code:
# * KOpenWeb ACE * #
#   Scripter : Kyonides Arkanthes
#   2023-01-25

# This script is FREE as in BEER.
# It is distributed AS IS.
# No further changes will be added.

# Since most developers will only include a link to their own webiste,
# I crafted this scriptlet to let them open the default web browser via
# triggering the custom "Open My Website" command.
# The player will not notice any changes till the web browser finally opens.
# Feel free to customize the CONSTANTS found in the KOpenWeb module.

module KOpenWeb
  COMMAND_TEXT = "Save Point"
  COMMAND_INDEX = 2
  COMMAND_SYMBOL = :open_website
  WEBSITE_URL = "https://www.save-point.org/index.php"
end

class Window_TitleCommand
  include KOpenWeb
  alias :kyon_open_website_mk_cmd_list :make_command_list
  def make_command_list
    kyon_open_website_mk_cmd_list
    place_command(COMMAND_TEXT, COMMAND_SYMBOL)
  end

  def place_command(name, symbol)
    cmd = { name: name, symbol: symbol, enabled: true, ext: nil }
    @list.insert(COMMAND_INDEX, cmd)
  end
end

class Scene_Title
  include KOpenWeb
  alias :kyon_open_website_scn_title_ccw :create_command_window
  def create_command_window
    kyon_open_website_scn_title_ccw
    @command_window.set_handler(COMMAND_SYMBOL, method(:open_url))
  end

  def open_url
    Thread.new{ system("open " + WEBSITE_URL) }
    @command_window.activate
  end
end


Compatibility

It will only work with the Default Scene_Title script.

Terms & Conditions

Free as in Beer beer.
Distributed AS IS. No further changes will be made.
Include my nickname in your TV game credits.
Do not repost it! Leave a link to this website instead.
Authorized Websites: Save-Point, RMW, RMC.
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }


Messages In This Thread
KOpenWeb - by kyonides - 01-26-2023, 03:38 AM



Users browsing this thread: 1 Guest(s)