Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Word Combi-Teleport
#1
Word Combi-Teleport
by GoldenShadow
v 2.0
Aug 11, 2005

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


Since the topic is not self-explaining, I'll explain:

GoldenShadow Wrote:Demo available, scroll to end of this 1st post.
Remember though, the posted script and the script in the demo are not the same!
I'll update it soon!!


THE MAIN PURPOSE
Let's you have a list of words, which you then can choose to combine them
and use it as key word for an location.
For you who are familiar with .hack// games, it's like that.


HOW TO MAKE A LIST OF WORDS
You'd use this in an event or somewhere in script,
assuming you defined $wtel:
Code:
$wtel.add_word("word")


HOW TO MAKE A LIST OF POSSIBLE LOCATIONS
You'd use this in an event or somewhere in script,
assuming you defined $wtel:
Code:
$wtel.add_location("name", map_ID, x-pos, y-pos, description, area_type)

Name: The word that needs to be combined by the words
Map ID: Target location
X-pos: X position on the target map
Y-pos: Y position on the target map
Description: Description of new location in Array format: ["Line 1", "Line 2","etc"]
Area Type: Type, like Plains, Mountains or whatever in String format: "Plains"

That's about it. If it's still unclear, notify me.
By the way, the (space) is just a regular space to add between words.
Keep in mind though, it also counts as 1 word.


THE SCRIPT
Code:
#======================================================
#  <> Word Teleport Script v2.0 RELOADED
#  ==> You can delete all the comments except the copyright and creator info. Thanks.
#  ==> Do not rip, repost or any other way of reproducing without proper credit. Thanks.
#  ShadowClan Technologies � 2003-2005 - All rights reserved.
#  DutchSoft Technologies � 2005 - All pies reserved.
#  Creation Asylum Project � 2005 - This script is exclusively only for this project.
#-----------------------------------------------------------------------------------------------
# * How to use
# Set up in title screen or somewhere near intro of game:
#    $wtel = Word_Teleport_Script.new
# Then just call up:
#    $scene = Scene_WTS.new
# That would be it. Adding...
# Words: $wtel.add_word(word) --> word must be in this format: "word" with quotes.
# Location: $wtel.add_location(name, map_id, x, y, description, area_type)
# --> name format: "name" with quotes. Description and Area Type are optional.
# Thats all.
#
# * Notes
# 1. Don't parallel this: $wtel = Word_Teleport_Script.new
# 2. First set the $wtel and then add words and locations. Not reversed.
# 3. Description must be written in Array format: ["Line 1","Line 2","etc"]
# 4. Description and Area Type are both optional.
#
# I'll try and fix bugs here and there, meanwhile, you can suggest stuff. Thanks in advance.
#---------------------------------------------------------------------------------------------------
# * Suggestions? ==> PM or post in the section where this is posted.
# * Created by: GoldenShadow and Nick
# * Credits: JyJ for bug-/beta testing
#=======================================================

class Data_Wts
  attr_accessor :word         # Specify word
  attr_accessor :map          # Map to tele to
  attr_accessor :x            # X
  attr_accessor :y            # Y
  attr_accessor :description  # Description of the map (optional)
  attr_accessor :area_type # Optional: Shows area type, like Mountain, Woods, etc.
  def initialize(word, map, x, y, description, area_type) # More info can be added easily
    @word = word
    @map = map
    @x = x
    @y = y
    @description = description
    @area_type = area_type
  end
end

class Word_Teleport_Script # this is the main thing.  
  attr_accessor :word      # The available words
  attr_accessor :locs      # The available locations
  attr_accessor :active    # Active word. Will be reset after each cancel/teleport
  attr_accessor :sneak_id  # Sneak_id to pass id to classes
  def initialize
    @word = []        # Array, or would you prefer lotta variables?
    @locs = []   # Yes, an array, it saves all Data_WTS vars
    @active = []      # Also an array. It was required.
    @sneak_id = 0
  end

  def add_word(word) # This is for adding words as the story progresses
    unless @word.include?(word) # If it exists already, dont add it
      @word.push(word)
    end
  end
  
  def add_location(name, map_id, x, y, description = [], area_type = "") # Also adding locations.
    if map_id.is_a?(String) or x.is_a?(String) or y.is_a?(String)#ID, x, y must be numerics
      return # if they are not, dont add it
    elsif !description.is_a?(Array) or !area_type.is_a?(String) # must be those stuff
      return # stop transmission
    else
      if include_name(name) == false
        @locs.push(Data_Wts.new(name,map_id,x,y,description, area_type)) # push, if doesnt exist
      else
        @locs[@sneak_id] = (Data_Wts.new(name,map,x,y,description, area_type)) # else, overwrite
      end
    end
  end
  
  def include_name(word)
    inclusive = false
    for i in 0...@locs.size
      xyz = @locs[i]
      if xyz.word == word
        @sneak_id = i
        inclusive = true
      end
    end
    return inclusive
  end    
end

class Window_Word < Window_Base # The 'status' window
  
  def initialize
    super(320, 64, 320, 416 - 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface.is_a?(String) ? $fontface : $defaultfonttype
    self.contents.font.size =  $defaultfontsize == nil ? $fontsize : $defaultfontsize
    refresh
  end
  
  def refresh
    self.contents.clear
    self.contents.draw_text(0, 16, self.width - 40, 32, "Your destination will be...", 1)
    if $wtel.include_name($wtel.active.join)
      self.contents.font.color = Color.new(152, 239, 95) # green color
    else
      self.contents.font.color = Color.new(255, 96, 96) # red color
    end
    self.contents.draw_text(0, 64, self.width - 40, 32, $wtel.active.join, 1) # the temp. var
    self.contents.font.color = normal_color # normal..
    self.contents.draw_text(0, 114, self.width - 40, 32, "(max. 4 words.)", 1) # max...
    self.contents.draw_text(4, 160, self.width - 40, 32, "Press the 'S' button to")
    self.contents.draw_text(4, 192, self.width - 40, 32, "switch between windows.")
  end
end

class Window_WTSList < Window_Selectable # the word list
  # all i did was just customize the Window_Item. No big deal
  def initialize
    super(0, 64, 320, 416)
    @column_max = 1
    refresh
    self.index = 0
  end

  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @item_max = $wtel.word.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = $fontface.is_a?(String) ? $fontface : $defaultfonttype
      self.contents.font.size =  $defaultfontsize == nil ? $fontsize : $defaultfontsize
      for i in 0...@item_max
        draw_item(i) # show (draw) each item
      end
    end
  end

  def draw_item(index)
    self.contents.font.color = normal_color
    x = 4 # aligned of x-axis '4'
    y = index  * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(x, y, 212, 32, $wtel.word[index], 0) # showing it.
  end
end

class Window_WTSCommand < Window_Selectable # command box

  def initialize
    super(0, 0, 320, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface.is_a?(String) ? $fontface : $defaultfonttype
    self.contents.font.size =  $defaultfontsize == nil ? $fontsize : $defaultfontsize
    @commands = ["Go!", "Cancel"] # the commands...
    @item_max = 2
    @column_max = 2
    draw_item(0, normal_color) # 'Go'
    draw_item(1, normal_color) # 'Cancel'
    self.active = false
    self.index = 0
  end

  def draw_item(index, color) #
    self.contents.font.color = color
    rect = Rect.new(index * 160 + 4, 0, 128 - 10, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index], 1)
  end

  def update_cursor_rect # needed to show actual selection
    self.cursor_rect.set(index * 160, 0, 128, 32)
  end
end


class Scene_WTS # this is the whole thing!
  
  def main
    if $wtel.word.include?("(space)")
      $wtel.word.delete("(space)") # delete this word
      $wtel.word.push("(space)") # and add it at the end of all the other words
    else
      $wtel.word.push("(space)")
    end
    @help_window = Window_Help.new
    @help_window.set_text("Choose a combination of words to form the destination.") # a msg
    @status_window = Window_Word.new
    @list_window = Window_WTSList.new
    @command_window = Window_WTSCommand.new
    @command_window.x = 320 # command box x-axis
    @command_window.y = 416 # command box -y-axis
    @area_description = Window_WTSDescription.new
    @area_description.x = 320 - @area_description.width / 2
    @area_description.y = 240 - @area_description.height / 2
    @area_description.z = 9999
    @area_description.active = @area_description.visible = false
    Graphics.transition # transing it, so it updates
    loop do
      Graphics.update
      Input.update
      update # updating the stuff, see def update
      if $scene != self
        break
      end
    end
    Graphics.freeze # when closing, freeze it all first
    @help_window.dispose # and dispose all the items/windows
    @status_window.dispose #
    @list_window.dispose #
    @command_window.dispose #
    @area_description.dispose #
  end
  
  def update # update all the windows
    @help_window.update
    @status_window.update
    @list_window.update
    @command_window.update
    @area_description.update
    if Input.trigger?(Input::Y) and @list_window.active # switch between windows
      @list_window.active = false
      @command_window.active = true
      @help_window.set_text("Select 'Go' to go the the location if green. 'D' button for info.")
    elsif Input.trigger?(Input::Y) and @command_window.active # same here
      @list_window.active = true
      @command_window.active = false
      @help_window.set_text("Choose a combination of words to form the destination.")
    elsif Input.trigger?(Input::Z) and @command_window.active
      if $wtel.include_name($wtel.active.join)
        @info = $wtel.locs[$wtel.sneak_id]
        @area_description.show_info(@info.description, @info.area_type)
        @command_window.active = false
        @area_description.visible = true
        @area_description.active = true
      end
    end
    if @command_window.active
      update_command
    end
    if @list_window.active
      update_list
    end
    if @area_description.active
      update_description
    end
  end
  
  def update_command
    if Input.trigger?(Input::C) # when the command box is active and selection is made
      case @command_window.index
      when 0 # the 'GO' selection
        #to do
        if $wtel.include_name($wtel.active.join) # unless destination doesn't exist
          $game_system.se_play($data_system.decision_se)
          $game_map.setup($wtel.locs[$wtel.sneak_id].map) # go to map
          $game_player.moveto($wtel.locs[$wtel.sneak_id].x, $wtel.locs[$wtel.sneak_id].y)  # exact location
          $game_player.refresh # refresh stuff
          $game_map.autoplay
          $game_map.update
          $wtel.active = [] # clear array
          $scene = Scene_Map.new # go to map
        else
          $game_system.se_play($data_system.buzzer_se)
        end
      when 1
        $game_system.se_play($data_system.cancel_se)
        $wtel.active = [] # clear it
        $scene = Scene_Map.new # and go to actual map
      end
    end
  end
  
  def update_list
    if Input.trigger?(Input::C) and $wtel.active.size <= 3 # 4 is the max words
      $game_system.se_play($data_system.decision_se)
      if $wtel.word[@list_window.index] == "(space)" # if its space
         $wtel.active.push(" ") # add a space!
         @status_window.refresh
      else
        $wtel.active.push($wtel.word[@list_window.index]) # otherwise, add the word
        @status_window.refresh
      end
    elsif Input.trigger?(Input::B) # cancel and remove final word
      $game_system.se_play($data_system.cancel_se)
      $wtel.active.pop
      @status_window.refresh
    end
  end
  
  def update_description
    if Input.trigger?(Input::C) or Input.trigger?(Input::B)
      @area_description.active = @area_description.visible = false
      @area_description.contents.clear
      @command_window.active = true
    end
  end
end

# This is the description window....
class Window_WTSDescription < Window_Base
  
  def initialize
    super(0,0, 480, 320)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface == nil ? $defaultfontface : $fontface
    self.contents.font.size = $fontsize == nil ? $defaultfontsize : $fontsize
  end
  
  def refresh
    self.contents.clear
    self.contents.draw_text(0, 4, self.width - 40, 32, "Area Information", 1)
  end
  
  def show_info(description, area_type)
    refresh
    if description == [] or description == nil
      self.contents.font.color = knockout_color
      self.contents.draw_text(4, 64, self.width - 40, 32, "There is no information available.")
      self.contents.font.color = normal_color
    else
      y = 32
      for i in 0...description.size
        self.contents.draw_text(4, y, self.width - 40, 32, description[i].to_s)
        y += 32
      end
    end
    if area_type == nil or area_type == ""
      area = "Unknown Terrain"
    else
      area = area_type
    end
    self.contents.draw_text(4, self.height - 62, self.width - 40, 32, "Area Type: #{area}")
  end
end

# FINAL UPDATE: October the 13th, 7:51 PM CET


THE DEMO

.rar   wts.rar (Size: 200.25 KB / Downloads: 1)



Thanks to Nick for a new system implement which allowed me to make
descriptions and area types and perhaps more in the future. Thank you Nick. Most appriciated!
}




Users browsing this thread: