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.

Scene Item edit!

Ok so I am amidst development and I have thus far fix and or edited most of the things i needed to in the scripts im using. I am currently using a Moghunter Scene_Item addon.
Below is a copy of what is running so far.
Code:
#_______________________________________________________________________________

# MOG Scene Item Laura V1.2            

#_______________________________________________________________________________

# By Moghunter  

# [url=http://www.atelier-rgss.com]http://www.atelier-rgss.com[/url]

#_______________________________________________________________________________

module MOG

#Transition Time.

MNIT = 20

#Transition Type(Name).

MNITT = "004-Blind04"  

end

$mogscript = {} if $mogscript == nil

$mogscript["menu_laura"] = true

###############

# Window_Base #

###############

class Window_Base < Window

def nada

face = RPG::Cache.picture("")

end    

def drw_face(actor,x,y)

face = RPG::Cache.picture(actor.name + "_fc") rescue nada

cw = face.width 

ch = face.height 

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x , y - ch, face, src_rect)    

end   

def draw_maphp3(actor, x, y)

back = RPG::Cache.picture("BAR0")    

cw = back.width  

ch = back.height 

src_rect = Rect.new(0, 0, cw, ch)    

self.contents.blt(x + 65, y - ch + 30, back, src_rect)

meter = RPG::Cache.picture("HP_Bar")    

cw = meter.width  * actor.hp / actor.maxhp

ch = meter.height 

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x + 65, y - ch + 30, meter, src_rect)

text = RPG::Cache.picture("HP_Tx")    

cw = text.width  

ch = text.height 

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x + 35, y - ch + 30, text, src_rect)

self.contents.font.color = Color.new(0,0,0,255)

self.contents.draw_text(x + 81, y - 1, 48, 32, actor.hp.to_s, 2)

self.contents.font.color = Color.new(255,255,255,255)

self.contents.draw_text(x + 80, y - 2, 48, 32, actor.hp.to_s, 2)    

end  

def draw_mapsp3(actor, x, y)

back = RPG::Cache.picture("BAR0")    

cw = back.width  

ch = back.height 

src_rect = Rect.new(0, 0, cw, ch)    

self.contents.blt(x + 65, y - ch + 30, back, src_rect)

meter = RPG::Cache.picture("SP_Bar")    

cw = meter.width  * actor.sp / actor.maxsp

ch = meter.height 

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x + 65, y - ch + 30, meter, src_rect)

text = RPG::Cache.picture("SP_Tx")    

cw = text.width  

ch = text.height 

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x + 35, y - ch + 30, text, src_rect)

self.contents.font.color = Color.new(0,0,0,255)

self.contents.draw_text(x + 81, y - 1, 48, 32, actor.sp.to_s, 2)

self.contents.font.color = Color.new(255,255,255,255)

self.contents.draw_text(x + 80, y - 2, 48, 32, actor.sp.to_s, 2)    

end  

def draw_mexp_it(actor, x, y)

lv_tx = RPG::Cache.picture("LV_tx")

cw = lv_tx.width 

ch = lv_tx.height 

src_rect = Rect.new(0, 0, cw, ch)

self.contents.blt(x + 60 , y - ch + 32, lv_tx, src_rect)

self.contents.font.color = Color.new(0,0,0,255)

self.contents.draw_text(x + 101, y + 5, 24, 32, actor.level.to_s, 1)

self.contents.font.color = Color.new(255,255,255,255)

self.contents.draw_text(x + 100, y + 4, 24, 32, actor.level.to_s, 1)

end

def draw_actor_state_it(actor, x, y, width = 80)

text = make_battler_state_text(actor, width, true)

self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color

self.contents.draw_text(x, y, width, 32, text,1)

end

end

######################

# Window_Target_Item #

######################

class Window_Target_Item < Window_Selectable

  def initialize

    super(0, 130, 280, 300)

    self.contents = Bitmap.new(width - 32, height - 32)

    self.contents.font.name = "Arial"

    self.z += 10

    @item_max = $game_party.actors.size

    refresh

  end

  def refresh

    self.contents.clear

    for i in 0...$game_party.actors.size

      x = 4

      y = i * 65

      actor = $game_party.actors[i]

      drw_face(actor,x,y + 55)

      if $mogscript["TP_System"] == true

      draw_actor_tp(actor, x + 168, y + 27 ,4)

      else  

      draw_mexp_it(actor, x + 110, y + 25 )

      end

      draw_actor_state_it(actor, x + 165, y )

      draw_maphp3(actor, x + 20, y + 0)

      draw_mapsp3(actor, x + 20, y + 32)

    end

  end

  def update_cursor_rect

    if @index <= -2

      self.cursor_rect.set(0, (@index + 10) * 65, self.width - 32, 60)

    elsif @index == -1

      self.cursor_rect.set(0, 0, self.width - 32, @item_max * 64 )

    else

      self.cursor_rect.set(0, @index * 65, self.width - 32, 60)

    end

  end

end

############

# Type_Sel #

############

class Type_Sel < Window_Base

  attr_reader   :index                    

  attr_reader   :help_window            

  def initialize(x, y, width, height)

    super(x, y, width, height)

    @item_max = 1

    @column_max = 1

    @index = -1

  end

  def index=(index)

    @index = index

  end

  def row_max

    return (@item_max + @column_max - 1) / @column_max

  end

  def top_row

    return self.oy / 32

  end

  def top_row=(row)

    if row < 0

      row = 0

    end

    if row > row_max - 1

      row = row_max - 1

    end

    self.oy = row * 32

  end

  def page_row_max

    return (self.height - 32) / 32

  end

  def page_item_max

    return page_row_max * @column_max

  end

  def update

    super

    if self.active and @item_max > 0 and @index >= 0

      if Input.repeat?(Input::RIGHT)

        if (@column_max == 1 and Input.trigger?(Input::RIGHT)) or

           @index < @item_max - @column_max

          $game_system.se_play($data_system.cursor_se)

          @index = (@index + @column_max) % @item_max

        end

      end

      if Input.repeat?(Input::LEFT)

        if (@column_max == 1 and Input.trigger?(Input::LEFT)) or

           @index >= @column_max

          $game_system.se_play($data_system.cursor_se)

          @index = (@index - @column_max + @item_max) % @item_max

        end

      end

    end 

  end

end

###############

# Window_Type #

###############

class Window_Type < Type_Sel

  def initialize

    super(0, 0, 0, 0)

    @item_max = 3

    self.index = 0

  end

end

##################

# Window_Item_Ex #

##################

class Window_Item_Ex < Window_Selectable 

  def initialize

    super(250, 50, 295, 350)

    @column_max = 1

    refresh

    self.index = 0

    if $game_temp.in_battle

      self.y = 64

      self.height = 256

      self.back_opacity = 160

    end

  end

  def item

    return @data[self.index]

  end

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @data = []

    for i in 1...$data_items.size

      if $game_party.item_number(i) > 0

        @data.push($data_items[i])

      end

    end

    @item_max = @data.size

    if @item_max > 0

      self.contents = Bitmap.new(width - 32, row_max * 32)

      for i in 0...@item_max

        draw_item(i)

      end

    end

  end

  def draw_item(index)

    item = @data[index]

    case item

    when RPG::Item

      number = $game_party.item_number(item.id)

    end

    if item.is_a?(RPG::Item) and

       $game_party.item_can_use?(item.id)

      self.contents.font.color = normal_color

    else

      self.contents.font.color = disabled_color

    end

    x = 4 + index % 1 * (288 + 32)

    y = index / 1 * 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.font.name = "Arial"    

    bitmap = RPG::Cache.icon(item.icon_name)

    opacity = self.contents.font.color == normal_color ? 255 : 128    

    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

    self.contents.draw_text(x + 28, y, 190, 32, item.name, 0)

    self.contents.draw_text(x + 215, y, 16, 32, ":", 1)

    self.contents.draw_text(x + 230, y, 24, 32, number.to_s, 2)

    end

  def update_help

    @help_window.set_text(self.item == nil ? "" : self.item.description)

  end

end

#################

# Window_Weapon #

#################

class Window_Weapon < Window_Selectable 

  def initialize

    super(250, 50, 295, 350)

    @column_max = 1

    refresh

    self.index = 0

     if $game_temp.in_battle

      self.y = 64

      self.height = 256

      self.back_opacity = 160

    end

  end

  def item

    return @data[self.index]

  end

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @data = []

      for i in 1...$data_weapons.size

        if $game_party.weapon_number(i) > 0

          @data.push($data_weapons[i])

        end

      end

    @item_max = @data.size

    if @item_max > 0

      self.contents = Bitmap.new(width - 32, row_max * 32)

      for i in 0...@item_max

        draw_item(i)

      end

    end

  end

  def draw_item(index)

    item = @data[index]

    case item

    when RPG::Weapon

      number = $game_party.weapon_number(item.id)

    end

    if item.is_a?(RPG::Item) and

       $game_party.item_can_use?(item.id)

      self.contents.font.color = normal_color

    else

      self.contents.font.color = disabled_color

    end

    x = 4 + index % 1 * (288 + 32)

    y = index / 1 * 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.font.name = "Arial"    

    bitmap = RPG::Cache.icon(item.icon_name)

    opacity = self.contents.font.color == normal_color ? 255 : 128    

    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

    self.contents.draw_text(x + 28, y, 190, 32, item.name, 0)

    self.contents.draw_text(x + 215, y, 16, 32, ":", 1)

    self.contents.draw_text(x + 230, y, 24, 32, number.to_s, 2)

  end

  def update_help

    @help_window.set_text(self.item == nil ? "" : self.item.description)

  end

end

################

# Window_Armor #

################

class Window_Armor < Window_Selectable 

  def initialize

    super(250, 50, 295, 350)

    @column_max = 1

    refresh

    self.index = 0

    if $game_temp.in_battle

      self.y = 64

      self.height = 256

      self.back_opacity = 160

    end

  end

  def item

    return @data[self.index]

  end

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @data = []

      for i in 1...$data_armors.size

        if $game_party.armor_number(i) > 0

          @data.push($data_armors[i])

        end

      end

    @item_max = @data.size

    if @item_max > 0

      self.contents = Bitmap.new(width - 32, row_max * 32)

      for i in 0...@item_max

        draw_item(i)

      end

    end

  end

  def draw_item(index)

    item = @data[index]

    case item

    when RPG::Armor

      number = $game_party.armor_number(item.id)

    end

    if item.is_a?(RPG::Item) and

       $game_party.item_can_use?(item.id)

      self.contents.font.color = normal_color

    else

      self.contents.font.color = disabled_color

    end

    x = 4 + index % 1 * (288 + 32)

    y = index / 1 * 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.font.name = "Arial"    

    bitmap = RPG::Cache.icon(item.icon_name)

    opacity = self.contents.font.color == normal_color ? 255 : 128    

    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

    self.contents.draw_text(x + 28, y, 190, 32, item.name, 0)

    self.contents.draw_text(x + 215, y, 16, 32, ":", 1)

    self.contents.draw_text(x + 230, y, 24, 32, number.to_s, 2)

  end

  def update_help

    @help_window.set_text(self.item == nil ? "" : self.item.description)

  end

end

 

 

 

 

 

 

 

##############

# Scene_Item #

##############

class Scene_Item

  def main

    @back = Plane.new

    @back.bitmap = RPG::Cache.picture("MN_BK")

    @back.z = 100

    @item_lay = Sprite.new

    @item_lay.bitmap = RPG::Cache.picture("Item_lay")

    @item_lay.z = 100

    @item_com = Sprite.new

    @item_com.bitmap = RPG::Cache.picture("Item_com01")

    @item_com.z = 100

    @type = Window_Type.new

    @type.opacity = 0

    @type.visible = false

    @help_window = Window_Help.new

    @help_window.y = 415

    @item_window = Window_Item_Ex.new

    @item_window.help_window = @help_window

    @item_window.visible = true

    @item_window.active = true

    @weapon_window = Window_Weapon.new

    @weapon_window.help_window = @help_window

    @weapon_window.visible = false 

    @weapon_window.active = true

    @armor_window = Window_Armor.new

    @armor_window.help_window = @help_window

    @armor_window.visible = false 

    @armor_window.active = true    

    @target_window = Window_Target_Item.new

    @target_window.x = -300

    @target_window.active = false

    @help_window.opacity = 0

    @help_window.x = -200

    @help_window.contents_opacity = 0    

    @item_window.opacity = 0

    @weapon_window.opacity = 0

    @armor_window.opacity = 0

    @target_window.opacity = 0    

    @weapon_window.x = 640

    @armor_window.x = 640

    @item_window.x = 640   

    @weapon_window.contents_opacity = 0

    @armor_window.contents_opacity = 0

    @item_window.contents_opacity = 0      

    Graphics.transition(MOG::MNIT, "Graphics/Transitions/" + MOG::MNITT)

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end

    end

    for i in 0..30

    @weapon_window.x += 20

    @armor_window.x += 20

    @item_window.x += 20   

    @weapon_window.contents_opacity -= 15

    @armor_window.contents_opacity -= 15

    @item_window.contents_opacity -= 15     

    @item_lay.zoom_x += 0.2

    @item_lay.opacity -= 15

    @item_com.zoom_y += 0.2

    @item_com.opacity -= 15

    @target_window.x -= 15

    @help_window.contents_opacity -= 15

    @back.ox += 1

    Graphics.update  

    end  

    Graphics.freeze

    @help_window.dispose

    @item_window.dispose

    @weapon_window.dispose

    @armor_window.dispose

    @target_window.dispose

    @item_lay.dispose

    @back.dispose

    @item_com.dispose

    @type.dispose

  end

  def update

    if @target_window.active == true

       @target_window.visible = true

    if @target_window.x < 0

       @target_window.x += 20

    elsif @target_window.x >= 0

       @target_window.x = 0      

    end  

    else

    if @target_window.x > -300

       @target_window.x -= 20

    elsif @target_window.x >= -300

       @target_window.x = -300

       @target_window.visible = false

    end 

    end    

    if @help_window.x < 0

    @help_window.x += 10

    @help_window.contents_opacity += 15    

    elsif @help_window.x >= 0

    @help_window.x = 0

    @help_window.contents_opacity = 255    

    end

    if @item_window.x > 250

    @weapon_window.x -= 20

    @armor_window.x -= 20

    @item_window.x -= 20   

    @weapon_window.contents_opacity += 15

    @armor_window.contents_opacity += 15

    @item_window.contents_opacity += 15    

    elsif  @item_window.x <= 250

    @weapon_window.x = 250

    @armor_window.x = 250

    @item_window.x = 250   

    @weapon_window.contents_opacity = 250

    @armor_window.contents_opacity = 250

    @item_window.contents_opacity = 250      

    end 

    if @target_window.active == false

    if Input.trigger?(Input::RIGHT) or Input.trigger?(Input::LEFT) or

       Input.press?(Input::RIGHT) or  Input.press?(Input::LEFT)

    @weapon_window.x = 640

    @armor_window.x = 640

    @item_window.x = 640       

    @weapon_window.contents_opacity = 0

    @armor_window.contents_opacity = 0

    @item_window.contents_opacity = 0       

    end

    if Input.trigger?(Input.dir4) or Input.trigger?(Input.dir4) or

       Input.trigger?(Input::L) or Input.trigger?(Input::R)      

    @help_window.x = -200

    @help_window.contents_opacity = 0

    end  

    end

    @back.ox += 1

    @help_window.update

    @item_window.update

    @weapon_window.update

    @armor_window.update

    @target_window.update

    @type.update

    case @type.index

    when 0

    @item_com.bitmap = RPG::Cache.picture("Item_com01")

    if @target_window.active == true

      update_target

      @item_window.active = false  

      @type.active = false

      return

    else   

      @item_window.active = true

      @type.active = true

    end    

    @weapon_window.active = false

    @armor_window.active = false

    @item_window.visible = true

    @weapon_window.visible = false

    @armor_window.visible = false    

    when 1 

    @item_com.bitmap = RPG::Cache.picture("Item_com02")

    @item_window.active = false

    @weapon_window.active = true

    @armor_window.active = false

    @item_window.visible = false

    @weapon_window.visible = true

    @armor_window.visible = false    

    when 2

    @item_com.bitmap = RPG::Cache.picture("Item_com03")

    @item_window.active = false

    @weapon_window.active = false

    @armor_window.active = true

    @item_window.visible = false

    @weapon_window.visible = false

    @armor_window.visible = true

    end

    if @item_window.active

      update_item

      return

    end

    if @weapon_window.active

      update_weapon

      return

    end

    if @armor_window.active

      update_armor

      return

    end

  end

  def update_weapon

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      $scene = Scene_Menu.new(0)

      return

    end

  end

  def update_armor

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      $scene = Scene_Menu.new(0)

      return

    end

  end

  def update_item

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      $scene = Scene_Menu.new(0)

      return

    end

    if Input.trigger?(Input::C)

      @item = @item_window.item

      unless @item.is_a?(RPG::Item)

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      unless $game_party.item_can_use?(@item.id)

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      $game_system.se_play($data_system.decision_se)

      if @item.scope >= 3

        @item_window.active = false

        @target_window.x = (@item_window.index + 1) % 1 * 304

        @target_window.active = true

        @target_window.x = -350              

        if @item.scope == 4 || @item.scope == 6

          @target_window.index = -1

        else

          @target_window.index = 0

        end

      else

        if @item.common_event_id > 0

          $game_temp.common_event_id = @item.common_event_id

          $game_system.se_play(@item.menu_se)

          if @item.consumable

            $game_party.lose_item(@item.id, 1)

            @item_window.draw_item(@item_window.index)

          end

          $scene = Scene_Map.new

          return

        end

      end

      return

    end

  end

  def update_target

    if Input.trigger?(Input::B)

      $game_system.se_play($data_system.cancel_se)

      unless $game_party.item_can_use?(@item.id)

        @item_window.refresh

      end

      @item_window.active = true

      @target_window.active = false

      return

    end

    if Input.trigger?(Input::C)

      if $game_party.item_number(@item.id) == 0

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      if @target_window.index == -1

        used = false

        for i in $game_party.actors

          used |= i.item_effect(@item)

        end

      end

      if @target_window.index >= 0

        target = $game_party.actors[@target_window.index]

        used = target.item_effect(@item)

      end

      if used

        $game_system.se_play(@item.menu_se)

        if @item.consumable

          $game_party.lose_item(@item.id, 1)

          @item_window.draw_item(@item_window.index)

        end

        @target_window.refresh

        if $game_party.all_dead?

          $scene = Scene_Gameover.new

          return

        end

        if @item.common_event_id > 0

          $game_temp.common_event_id = @item.common_event_id

          $scene = Scene_Map.new

          return

        end

      end

      unless used

        $game_system.se_play($data_system.buzzer_se)

      end

      return

    end

  end

end

Now What I want to do is when you switch between the -----> ITEM | WEAPON | ARMOR
Selections by clicking left and right, for a picture to show up. I want to picture be called based on the item name + (_pxt)

So what i mean is, lets say you open the item menu and a Potion is highlighted. I want RMXP to opena picture called (Potion_pxt) in my pictures folder.
Then if you switch to the weapon section by clicking right, and a Bronze Sword is now highlighted, I want it to show a picture called (Bronze Sword_pxt) in my pictures folder.
and the same for the armor section.

I will attach a link to the demo project for the mog script pack. It contains the pictures and such neccessary for the scene item.

So far I have tried adding lines under the different items windows like this:
@pxt = Sprite.new
@pxt.bitmap = RPG::Cache.picture((item.name) + "_pxt")
@pxt.x = 0
@pxt.y = 0
@pxt.z = 100
And the picture shows up but once one is loaded it wont refesh etc.
So i think i need a whole new window and I dont know how to do it.
So please, if you can help with this I would be most greatful and I will credit you in the game! thanks again!

LINK TO DEMO WITH WORKING MENU AND SCENE ITEM:
http://www.mediafire.com/?bw9gc4b81i9132n

THE BLUE AREA IS WHERE I WANT THE WINDOW TO BE EXACT SIZE DOESNT MATTER I CAN EDIT IT LATER:


Uploaded with ImageShack.us
If anything is unclear let me know and I will explain it better.
 
First of all... please use a fitting tag (XP/VX) next time for your help threads. Also, this belongs to RGSS Support more than it belongs here.

Your base attempt here is right (judging from what's in your quote tag - please use code tags next time though), you're just not following the Interpreter structure correctly. Lemme guide you through what you need...

First of all, let's pack what you have in it's own method, and call it from initialize (note that all my explanations below are based on your drawing the sprite in the scene directly, not in a window):
[rgss]def initialize(item)
  @item = item
  picture_refresh
end
 
def picture_refresh
  @pxt = Sprite.new
  @pxt.bitmap = RPG::Cache.picture((@item.name) + "_pxt")
end
[/rgss]

So far, everything's exactly as it has been, but for the fact that you now have in instance variable additionally to the local one. The other difference (only structural though) is that you have a method that has exactly and exclusively what you need to draw the current image.
So, let's go to your instance of Window_Selectable that you have (which I'm just going to assume... not going to deeply analyze Mog's cruel scripting; especially as the concept is the same for all the selectables really), find the place where it registers your input (i.e. if Input.press?(INPUT::LEFT)), and do something like this:

[rgss]if Input.press?(INPUT::LEFT)
  # this is whatever line that changes the active index of the window
  $scene.pxt.picture_refresh
end
[/rgss]

The reason you'll find a global variable in there is because you're modifying a picture outside of the current class, so you have to reference it somehow... and the already existant $scene variable seems well-fitting for that.
Add the window's container inbetween $scene and pxt if you'Re drawing the sprite in a window.
 

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