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.

I know it's right in front of my eyes, but...

Helpme.png


I know it's a simple problem, and it's probably been asked many times...I'm also pretty certain I've overlooked whatever it is that needs to be fixed, but...

The freakin' arrows. I know I've been able to remove them before from other windows by changing some numbers, but I can't seem to see where these numbers are for this window.

I've narrowed it down to the problem being in one of the two obvious places: Scene_Item or Window_Target. Window_Target being the one I'm leaning towards.


Here's the coding for both. Note, don't expect it to be pretty. I'm no expert, but I know enough to make it do what I want it to, usually.


Scene_Item:
Code:
#==============================================================================

# ** Scene_Item

#------------------------------------------------------------------------------

#  This class performs item screen processing.

#==============================================================================

 

class Scene_Item

  #--------------------------------------------------------------------------

  # * Main Processing

  #--------------------------------------------------------------------------

  def main

    # Make help window, item window

    @CMSback = Sprite.new

    @CMSback.bitmap = RPG::Cache.picture("CMSback")

    @CMSItems = Sprite.new

    @CMSItems.bitmap = RPG::Cache.picture("CMSItems")

    @CMSItems.x = 45

    @CMSItems.y = 100

    @CMSHelp = Sprite.new

    @CMSHelp.bitmap = RPG::Cache.picture("CMSHelp")

    @CMSHelp.x = 45

    @CMSHelp.y = 35

    @help_window = Window_Help.new

    @item_window = Window_Item.new

    # Associate help window

    @item_window.help_window = @help_window

    # Make target window (set to invisible / inactive)

    @target_window = Window_Target.new

    @target_window.visible = false

    @target_window.active = false

    @target_window.width = 500

    @target_window.height = 125 

    @item_window.opacity = 0

    @item_window.x = 45

    @item_window.y = 100

    @item_window.width = 450

    @item_window.height = 250

    @help_window.opacity = 0

    @help_window.x = 45

    @help_window.y = 35

    @help_window.width = 450

    @help_window.height = 50

    # Execute transition

    Graphics.transition

    # Main loop

    loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Frame update

      update

      # Abort loop if screen is changed

      if $scene != self

        break

      end

    end

    # Prepare for transition

    Graphics.freeze

    # Dispose of windows

    @CMSItems.dispose

    @help_window.dispose

    @item_window.dispose

    @target_window.dispose

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    # Update windows

    @help_window.update

    @item_window.update

    @target_window.update

    # If item window is active: call update_item

    if @item_window.active

      update_item

      return

    end

    # If target window is active: call update_target

    if @target_window.active

      update_target

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update (when item window is active)

  #--------------------------------------------------------------------------

  def update_item

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Switch to menu screen

      $scene = Scene_Menu.new(0)

      return

    end

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Get currently selected data on the item window

      @item = @item_window.item

      # If not a use item

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

        # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      # If it can't be used

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

        # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      # Play decision SE

      $game_system.se_play($data_system.decision_se)

      # If effect scope is an ally

      if @item.scope >= 3

        # Activate target window

        @item_window.active = false

        @target_window.x = 20

        @target_window.y = 162

        @target_window.visible = true

        @target_window.active = true

        # Set cursor position to effect scope (single / all)

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

          @target_window.index = -1

        else

          @target_window.index = 0

        end

      # If effect scope is other than an ally

      else

        # If command event ID is valid

        if @item.common_event_id > 0

          # Command event call reservation

          $game_temp.common_event_id = @item.common_event_id

          # Play item use SE

          $game_system.se_play(@item.menu_se)

          # If consumable

          if @item.consumable

            # Decrease used items by 1

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

            # Draw item window item

            @item_window.draw_item(@item_window.index)

          end

          # Switch to map screen

          $scene = Scene_Map.new

          return

        end

      end

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update (when target window is active)

  #--------------------------------------------------------------------------

  def update_target

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # If unable to use because items ran out

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

        # Remake item window contents

        @item_window.refresh

      end

      # Erase target window

      @item_window.active = true

      @target_window.visible = false

      @target_window.active = false

      return

    end

    # If C button was pressed

    if Input.trigger?(Input::C)

      # If items are used up

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

        # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      # If target is all

      if @target_window.index == -1

        # Apply item effects to entire party

        used = false

        for i in $game_party.actors

          used |= i.item_effect(@item)

        end

      end

      # If single target

      if @target_window.index >= 0

        # Apply item use effects to target actor

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

        used = target.item_effect(@item)

      end

      # If an item was used

      if used

        # Play item use SE

        $game_system.se_play(@item.menu_se)

        # If consumable

        if @item.consumable

          # Decrease used items by 1

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

          # Redraw item window item

          @item_window.draw_item(@item_window.index)

        end

        # Remake target window contents

        @target_window.refresh

        # If all party members are dead

        if $game_party.all_dead?

          # Switch to game over screen

          $scene = Scene_Gameover.new

          return

        end

        # If common event ID is valid

        if @item.common_event_id > 0

          # Common event call reservation

          $game_temp.common_event_id = @item.common_event_id

          # Switch to map screen

          $scene = Scene_Map.new

          return

        end

      end

      # If item wasn't used

      unless used

        # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

      end

      return

    end

  end

end

 

Window_Target
Code:
#==============================================================================

# ** Window_Target

#------------------------------------------------------------------------------

#  This window selects a use target for the actor on item and skill screens.

#==============================================================================

 

class Window_Target < Window_Selectable

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super(0, 0, 550, 480)

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

    self.contents.font.size = 14

    self.z += 10

    @item_max = $game_party.actors.size

    refresh

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

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

      x = i * 120

      y = 0

      actor = $game_party.actors[i]

      draw_actor_face(actor, x + 10, y + 14)

      draw_actor_name(actor, x, y - 10)

      #draw_actor_class(actor, x + 144, y)

      #draw_actor_level(actor, x + 8, y + 32)

      draw_actor_state(actor, x + 8, y + 64)

      draw_actor_hp(actor, x - 30, y + 32)

      draw_actor_sp(actor, x - 30, y + 48)

    end

  end

  #--------------------------------------------------------------------------

  # * Cursor Rectangle Update

  #--------------------------------------------------------------------------

  def update_cursor_rect

    # Cursor position -1 = all choices, -2 or lower = independent choice

    # (meaning the user's own choice)

    if @index <= -2

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

    elsif @index == -1

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

    else

      self.cursor_rect.set(@index * 120 - 5, -5, 110, 96)

    end

  end

end

 

Like I said, I know it's prolly staring me right in the face, but I've been working on this all day, and it's nearing midnight, so my eyes are tired.

Thanks in advance for the help.
 
In Scene_Item,

@target_window.width = 500
@target_window.height = 125

make the window a little wider & taller until the arrows go away. The window should be 32 pixels bigger than the contents. (16 pixel border on each side)
You will also want to scoot it 1 pixel left & up for each 2 pixels you make it bigger

@target_window.x = 20
@target_window.y = 162

Be Well
 
D'oh. Of course.

I would have normally have made the custom window picture with photoshop and then realized I could stretch it out to get the arrows to go away. Long day...


One other question though, and this is something that I'm certain I've not done before, so maybe you can help.

Dealing with the same screen as posted above, so feel free to reference it.

I have my cursor rectangle at the right size and place, and I've also changed it to move from left to right, as opposed to the default up to down...

however, it still requires me pushing the down arrow key to move it left to right.

I'm fairly certain I saw a snippet of coding in one of the classes that specifies an action to happen when you hit a particular button, such as the arrow keys, but I'm not sure where it's located, or how to implement it in this case.

Any ideas?
 
Is your window only supposed to scroll left-to-right, or can you scroll down too when selecting actors in this scene? (From your screenshot, your arrows are pointing down and left so I had to ask). You might want to double check your @item_max and @column_max and if thats alright...

You might want to overwrite update_cursor_rect in that particular selectable window with something like this...

Code:
if Input.trigger?(Input::LEFT)

  @index > 0 ? @index -= 1 : @index = ($game_party.members.size - 1)

elsif Input.trigger?(Input::RIGHT)

  @index < ($game_party.members.size - 1) ? @index += 1 : @index = 0

end

When you press LEFT and you're at the last actor in the party, it'll go to the very first actor in index, and visa versa with RIGHT.

Good luck with it :thumb:
 
Well, the arrows were the original reason I came for help, and I managed to get rid of them fairly easily. I figured I'd ask about the cursor rectangle while I was here, as well.


I tried implementing the code you provided, and I'm pretty sure I'm doing it wrong.

In psuedo-code, I know it's supposed to be:

show cursor rectangle in default position
IF (Input trigger = right arrow key)
move to next highest up index listing
ELSEIF (Input trigger = left arrow key)
move to next lowest index listing

I'm not concerned about, if I'm index listing 1 and hit left it'll go to 4, or if I'm at 4 and hit right it'll go to 1. As long as I can get it to work like the pseudo-code above, I'll be thrilled.

But anyway, here's the code:

Code:
def update_cursor_rect

    # Cursor position -1 = all choices, -2 or lower = independent choice

    # (meaning the user's own choice)

    self.cursor_rect.set(@index * 120 - 5, -5, 110, 96)

    if Input.trigger?(Input::LEFT)

      @index > 0 ? @index -= 1 : @index = ($game_party.memb ers.size - 1)

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

    elsif Input.trigger?(Input::RIGHT)

      @index < ($game_party.members.size - 1) ? @index += 1 : @index = 0

      self.cursor_rect.set(@index * 120 - 5, -5, 110, 96)

    end

  end

end

I suppose it would be easier for me to figure out if I was familiar with if statements within ruby.

This code here:

self.cursor_rect.set(@index * 120 - 5, -5, 110, 96)

Places the cursor rectangle in the correct default position, and in the correct positions for the next three, as well. Which is why I put it under elseif Input Right. But I know there's probably more to it than that. I know the one under If Input Left is way off, as I just copied one of the other cursor.rect lines from the original coding and just placed it hoping for the best.

Anyway, sorry to bug again, but I really am learning a lot with this CMS project I've started on, and I've gotten much further this time with the scripting portion than I ever have, and I'm eager to continue learning so I can get this project done.
 
The self.cursor_rect.set() statement should be the same in both. Use the one that works.
The x position is referencing @index, so it's the same no matter whether you're moving left or right.
 
Ok, well....


This is the code provided above, with the set cursor rect that works that I whipped up.


Code:
    if Input.trigger?(Input::LEFT)

      @index > 0 ? @index -= 1 : @index = ($game_party.members.size - 1)

      self.cursor_rect.set(@index * 120 - 5, -5, 110, 96)

    elsif Input.trigger?(Input::RIGHT)

      @index < ($game_party.members.size - 1) ? @index += 1 : @index = 0

      self.cursor_rect.set(@index * 120 - 5, -5, 110, 96)

    end


but I keep getting this error whenever I hit one of the arrow keys.

(note that line 47 is :

@index < ($game_party.members.size - 1) ? @index += 1 : @index = 0 )



hmmm-1.png

Maybe I'm just doing something wrong?
 
Thanks, it was that. Fixed the problem, now it works perfectly.


On to my next question....


I'm implementing the Multi Slot Equipment into the CMS, and I'm having trouble getting the Slot ID names and the Item ID names to move about to fit into the boxes I've made for them.

Equiphelp.png

Code:
  def refresh

    # Replaced method to show caption of all items and slot

    self.contents.clear

    self.contents.font.size = 14

    @data = [] 

    # Begin Multi-slot equipment script Edit

    self.contents.font.name = G7_MS_MOD::FONT_NAME

    for i in [email=0...@actor.weapon]0...@actor.weapon[/email]_slots.size

      # Push the name(s) of the weapon(s)

      @data.push($data_weapons[@actor.weapon_ids[i]])

    end

    for i in [email=0...@actor.armor]0...@actor.armor[/email]_slots.size

      # Push the names of the armors

      @data.push($data_armors[@actor.armor_ids[i]])

    end

    @caption = []

    for i in [email=0...@actor.weapon]0...@actor.weapon[/email]_slots.size

      # Push the name(s) of the weapon slots

      @caption.push(@actor.weapon_slot_names[i])

    end

    for i in [email=0...@actor.armor]0...@actor.armor[/email]_slots.size

      # Push the names of the armor slots

      @caption.push(@actor.armor_slot_names[@actor.armor_slots[i]-1])

    end

    @item_max = @data.size

    if @actor.translucent_texts == nil then @actor.translucent_texts = Array.new end

    for i in [email=0...@data.size]0...@data.size[/email]

      if @caption[i] != nil

        self.contents.font.color = system_color

        # Draw the name of the slots

        self.contents.draw_text(0, 30 * i, 92, 32, @caption[i])

      end

      # Draw the name of the equipment

      draw_item_name(@data[i], 92, 32 * i, @actor.translucent_texts[i])

    end

    # Support for other script

    if defined? xrxs_additional_refresh

      xrxs_additional_refresh

    end

  # End Multi-slot equipment script Edit

  end


I've narrowed it down to this section of Multi-Slot Equip: Windows, particularly because it deals with the def refresh for Window_Equipright, so i think I'm in the right place.

Here's my problem. When I try to edit draw_item_name and self.content.draw_text (where i think I need to be), I get some weird results.

For example, I know if I edit the 30 * i, if I change the constant, it changes the distance between the slot names. I'm pretty happy with the distances (I plan on separating the one main box into smaller ones that contain one slot id and item id to fit the distances), but I'm having trouble with changing the default x,y position of said IDs.

If someone could just point out to me the values I need to edit in order to get the positions to change, that would be wonderful.
 

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