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.

Super Simple Journal

If you mean you would like something to happen when the user selects one of the quests...

Yes, that can be done. The question is: What do you want to happen?

The window is already a Window_Selectable, which includes the methods to process selection of one of the items in the list.
If you look at the 'update_command' method in Scene_Menu, you'll see a section with the comment: "# If C button was pressed"
You would need to add a section similar in the 'update' method for Scene_Journal.
It is the 'index' property of the window that will tell you which entry is currently selected.
In Scene_Menu, it's @command_window.index
In Scene_Journal, it would be @journal_window.index.

Look at the 'update_item' method in Scene_Journal. It already handles what happens if the "B" (X or Escape key) button is pressed.
It either returns to the menu, or the map, depending on from where it was called.

So, if you add a section that looks like:

Code:
    # If C button was pressed

    if Input.trigger?(Input::C)

      # Do what you need to do here

    end

 

and use @journal_window.index to indicate which entry is selected.
 

Drey

Member

thanks so much for the quick reply Brew, you're awesome :P

however, It seems I overestimated my abilities a bit... I can't seem to create a custom page based on a selected ID, like the selected [journal_window.index], even though I tried many things throughout the day...

I easily managed to make a second identical journal menu, (nested in the first one) but I just can't seem to turn it into a simple text display with the same graphic box (0, 32, 460, 330), but no selectable list.

the problem is, I hadn't fully considered in what shape the actual extra quest text would be transported, and it just wouldn't work when I tried making a duplicate list of the (@data[1] "Title", @data[2] "Title") list, but with longer entries, in a near-duplicate script I simply called [Window_JournalDetails]... and that was my best plan, I think. (Also have a [Scene_JournalDetails] script)

Worked at this all day, so it's not for lack of trying, heheh... but I''m afraid I gotta rely on your skill again... pleez :3



(for clarification, since my explanations can be confusing sometimes, the user would hit the C button on any of the journal's active entries, and it would open, in a similar frame, a description based on that @data[1] list's values.)

a downside would be that I could only have one text value for any entry, but I could just make a lot of entries. Besides, it would allow for updated titles as the quest progresses.

thanks bro :)
 
Here ya go:

Add above Window_Journal
Code:
# Bitmap_Mods

 

class Bitmap

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

  #   Name      : Draw Paragraph

  #   Info      : Draws a Paragraph

  #   Author    : SephirothSpawn

  #   Call Info : Five

  #               Integer X and Y, Define Position

  #               Integer Width, defines the width of the text rectangle

  #               String Text, Information to Draw

  #               Integer Indent Amount of Space to indent by

  #               Integer Line_Height line height

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

  def draw_paragraph(x, y, width, text, indent = 32, line_height = 24)

    ox, oy = indent, 0

    for word in text.split

      ow = text_size(word).width

      if ow + ox > width

        ox = 0

        oy += line_height

      end

      if word == "n"

        ox = 0

        oy += line_height

        next

      end

      ow = [ow, width].min

      draw_text(x + ox, y + oy, ow + 10, line_height, word)

      ox += ow + text_size(' ').width

    end

  end

end

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

# ** Window_Journal_Detail

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

#  This window displays a detailed description when an entry is

#  selected in the journal.

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

 

class Window_Journal_Detail < Window_Base

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

attr_accessor :index

def initialize

   super(0, 32, 460, 330) 

   

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

# populate your journal with descriptions.

# make sure your descriptions match your journal entries in

# Window_Journal.  Use a single 'n' for a new line.

 

   @data = [] 

   @data[1] = "1: This is a long description to n n illustrate the use of long descriptions"

   @data[2] = "2: This is a long description to illustrate the use of long descriptions"

   @data[3] = "3: This is a long description to illustrate the use of long descriptions"

   @data[4] = "4: This is a long description to illustrate the use of long descriptions"

   @data[5] = "5: This is a long description to illustrate the use of long descriptions"

   

### to change the windowskin for the journal

#   self.windowskin = RPG::Cache.windowskin("RMXP4life_Wood.png")

 

 

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

 

   @column_max = 1

   self.index = 0 

   @offset = 100

 end

 

 

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

# * Draw the contents of the item window

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

 def refresh(index)

   if self.contents != nil

     self.contents.dispose

     self.contents = nil

   end 

   

   # draw the bitmap. the text will appear on this bitmap

   self.contents = Bitmap.new(428, 298)

 

   # get the item to display

    item = index + 1

    count = 0

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

      if $game_switches[i + @offset] == false

        item += 1

      else

        count += 1

      end

      if count == index + 1

        break

      end

    end         

 

   # draw the description

   text = @data[item]

   self.contents.draw_paragraph(0, 0, 428, text)

 end

   

end

Replace Scene_Journal with this:
Code:
#==============================================================================

# ■ Scene_Journal

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

#  This class contains the windows for the Journal

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

 

class Scene_Journal

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

  # ● Initialize the Status menu

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

  def initialize(callback = 0)  #callback from menu

    @callback = callback

  end

  

  def main

 

    @journal_window = Window_Journal.new

    @journal_window.x = 90

    @journal_window.y = 70

    @journal_window.active = true

    @journal_window.visible = true

    @desc_window = Window_Journal_Detail.new

    @desc_window.x = 90

    @desc_window.y = 70

    @desc_window.active = false

    @desc_window.visible = false

    

    Graphics.transition

 

    loop do

      Graphics.update

      Input.update

      update

      if $scene != self

        break

      end  

    end

 

    Graphics.freeze

    @journal_window.dispose

    @desc_window.dispose

  end

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

  # ● Draw the Status menu

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

  def update

    @journal_window.update

    if @journal_window.active

      update_item

      return

    end

    if @desc_window.active

      update_desc

    end

  end

 

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

  # ● Update menu after player makes a selection

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

  def update_item

   

    # Cancel key pressed (go to menu)

    if Input.trigger?(Input::B) or Input.trigger?(Input::L)

      $game_system.se_play($data_system.cancel_se)

      if @callback == 0

        $scene = Scene_Menu.new(4)

      else

        $scene = Scene_Map.new

      end

      return

    end

    # If C button was pressed

    if Input.trigger?(Input::C) and @journal_window.selectable == true

      @journal_window.active = false

      @journal_window.visible = false

      @desc_window.active = true

      @desc_window.visible = true

      @desc_window.refresh(@journal_window.index)

    end

  end

 

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

  # ● Update menu after player makes a selection

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

  def update_desc

   

    # Cancel key pressed (go to menu)

    if Input.trigger?(Input::B) or Input.trigger?(Input::L)

      $game_system.se_play($data_system.cancel_se)

      @journal_window.active = true

      @journal_window.visible = true

      @desc_window.active = false

      @desc_window.visible = false

      return

    end

  end

 

end


Instead of creating a new scene, I just added another window that starts out invisible. When you select an entry, it makes the first window inactive & invisible, and makes the second window active & visible. You'll need to populate the @data structure in the new window to match the first window. The other thing I did was add the Draw_Paragraph method to the Bitmap class so you don't have to worry about breaking up the description into multiple lines.

Try it out
 

Drey

Member

WOW!!! :tongue:

okay, you ROCK dude... :rock: that is absolutely perfect, and the paragraphing tool is exactly what I needed but I thought it was too much to ask, I'm seriously in your debt my friend :grin:

Only one tiny detail I could find that didn't work, was that the game crashes if you try to enter the [blank] journal entry, what's left if all quests are gone...

Can I replace that with a simple [no current quests] and @journal_window.disable_item(0)?
I'm not 100% sure what the condition would be...

thanks again SO MUCH for the help hehe ^_^
-Drey


PS, one little detail I'd love to know, if it's not too much:3

Any way I can add a line break in the text description? I tried combining something in between, like in:["text".<br/>."more text"] but no success, because I dunno what the line break code is.
 
You should not have any blank @data entries. Use the switches to turn quests on/off.

the draw_paragraph method was written by Sephiroth Spawn. (I added the newline character 'n')
To make a newline: "Line 1 of my description n Line 2 of my description n n Line 4 of my description with a blank line above"

I updated the scripts above, re-download and install them. And replace Window_Journal as well...

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

# ** Journal

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

#  This window displays a journal.

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

 

class Window_Journal < Window_Selectable

  attr_accessor :selectable

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

def initialize

   super(0, 32, 460, 330) 

   

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

# populate your journal with entries.

   @data = [] 

   @data[0] = "[No Current Quests]"

   @data[1] = "Help Man"

   @data[2] = "Kill Chicken"

   @data[3] = "Make cow eat"

   @data[4] = "Sniff the Glove"

   @data[5] = "Jump off a bridge after your friends"

   

# this is the offset for your switches. If you start with switch 100, set

# @offset = 99

 

@offset = 100

   

### to change the windowskin for the journal

#   self.windowskin = RPG::Cache.windowskin("RMXP4life_Wood.png")

 

 

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

 

   @column_max = 1

   self.index = 0 

   self.selectable = true

   refresh

 end

 

 

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

# * Draw the contents of the item window

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

  def refresh

    if self.contents != nil

     self.contents.dispose

     self.contents = nil

    end 

    

    # variables

    @journal_height = (@data.size - 1)*32   # y coord of entire journal (# of entries - 1) * 32

    @n = 0                     # y coord for each entry

    @item_max = 0              # max items to display

    

    # draw the bitmap. the text will appear on this bitmap

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

      

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

     if $game_switches[i + @offset] == true

       draw_item(i)

       @item_max += 1

       self.selectable = true

     end

    end    

   

    if @item_max == 0

      draw_item(0)

      self.selectable = false

    end

  

  end

   

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

# * Draw an individual item in the window

#     index : Index of the item to be drawn

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

 

  def draw_item(index)

    item = @data[index]

    rect = Rect.new(10, @n, 640, 32)

    self.contents.fill_rect(rect, Color.new(0,0,0,0))

    if index != 0

      self.contents.draw_text(10, @n, 640, 32, "●", 0)

    end

    self.contents.draw_text(25, @n, 640, 32, item, 0)

    @n += 32

      

  end

 

end
 

Drey

Member

[FIXED] sorry, no I mean how there's an empty box in the interface when you don't actually have any active quests.

If I hit the C button within the journal but without an active mission, it'll crash, giving me this error.
error.jpg
 

Drey

Member

[FIXED] Oh crap... I just swapped in the updated scripts, and now I can't open my journal without a total crash! O.O

error2.jpg

I should've backed up the working version though! *kicks myself hard*


EDIT: FIXED IT! *whew* it was simply because I had fixed the offset back to 0 before, (your default is 100) very important to remember if swapping in code.

Thanks a ton, Brew!!! :thumb:
Everything works like a charm, although it took me a few setbacks cause I switched in my own quests and mistakenly erased the @data(0) you'd added... but it's about as close to perfect as it's getting :biggrin:

You're awesome :tongue:
(BTW tiny last details, any idea why a few of SephirothSpawn's paragraphed words are kinda squashed? not a dealbreaker, just looks curious) :wink:
text.jpg
 
I think there's a discrepancy in the text_size method. Certain letters don't seem to return the correct width.
We should be able to fake it out in the draw_text call in the draw_paragraph method.

Try changing this line:

draw_text(x + ox, y + oy, ow, line_height, word)

to:

draw_text(x + ox, y + oy, ow + 10, line_height, word)

ow for certain words is getting calculated too small. So just draw the text in a larger rectangle.


And, yes. There's a @offset in both Window scripts. You need to change it in 2 places.
 

Drey

Member

perfect, worked without a hitch!! thanks so much Brew, you're a genius man... which is why I'll ask about a new problem I just found, I'm sure you thought of it already...

If any switches, other than my quest switches, get turned on right now, opening my journal crashes the game immediately.

Is the only cause the fact that they have varying numbers? I didn't use numbers 1 2 3 4 5, mine are actually 5 and 85, different numbers for importance... Other switches are obviously being used in other ways than quests, but I hadn't noticed until now that seems to clash with the journal?

my data list goes:
@data[0] = "[No Current Quests]"
@data[5] = "Shota"
@data[85] = "A Broken Staff"


Would it fix this at all if just made them 0, 101 and 102, with the offset? I'd actually like some wiggle room, so I can add more/less important quests in order as I think of them.

thanks bud ^.-
 
You need a contiguous range of switches, and the @data array can't have any empty slots.
That's the reason for the @offset value. If you use the @offset of 100, then switch 101 controls @data[1]. (i.e. you wouldn't use @data[101])
The @data array always starts at 1, you can have any number of slots, but don't leave any empty.
 

Drey

Member

yeaaahhhh... lol figured that was it, but thanks! I wanted to be sure it was the actual problem before changing it all up xD

damn though! Gonna be harder to fit stuff of varying importance into there... though, I suppose I could just make 102-179 blank, and write them into the code but only have their empty form in the list...

Anyways thanks a million, Brew :thumb:
You rock this forum heheh :3

take it easy buddy
-Drey
 

Drey

Member

Been making amazing, crazy progress on that game ever since I added this and a few other mods, I even built myself a codex based on this journal script :biggrin: thanks again for the immense help making this journal script 100x better.

Now, I'm just looking for one tiny additional detail that I can't encode myself, if you'd be so kind :3


I want to display a variable's value within a journal description, so, much like with 'n' for line breaks, could we simply add a defining formula so that when I use: \v[0075], like in the regular message function, it returns the value of variable 75?

thanks bud
 
Ok, in Window_Journal_Detail, after line 65:

Code:
   text = @data[item]

add:

Code:
    # Control text processing

    begin

      last_text = text.clone

      text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }

    end until text == last_text

This is just a copy of the \V substitution code from Window_Message.

Use \\V[#] in your description text.
double backslash because the string gets parsed.
 

Drey

Member

works beautifully! :tongue:
I bow at the feet of the master, heheh xD

One more little issue I'm having, actually? :angel:


I added a mouse script which is really fantastic, and automatically selects what it's hovering over as a target, just as it should.

Took me a while to notice this problem, but if i click anywhere except on the specific entries, I get this error and a crash:
(Bearing in mind, my lines are a few lower down than the default since i have quests)
err.jpg


Likewise, I'd like to be able to simply have a 'return' statement, doing nothing if i click on "nothing" within the journal, and normal menus (if you know how to boil it down) because as it is, clicking on "nothing" always selects the last option.

thanks a LOT, dude :smile:
-Drey
 
Not a clue. I imagine additional code would need to be implemented in the journal windows to accept input from the mouse.
(set the index based on mouse position, and perform a "select" action).
Without seeing the mouse script, I have no idea.
 

Drey

Member

My bad! heheh, any help is immensely appreciated, anyways x3

[it's Blizzard's mouse script, version 2.0b]
Code:
$mouse_controller = 2.0

 

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

# Mouse

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

 

class Mouse

  

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

# START Configuration

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  MOUSE_ICON = 'cursor'

  AUTO_CONFIGURE = true

  APPLY_BORDERS = true

  WINDOW_WIDTH = 640

  WINDOW_HEIGHT = 480

  HIDE_WINDOWS_CURSOR = true

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

# END Configuration

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

  

  if HIDE_WINDOWS_CURSOR

    Win32API.new('user32', 'ShowCursor', 'i', 'i').call(0)

  end

  

  SCREEN_TO_CLIENT = Win32API.new('user32', 'ScreenToClient', %w(l p), 'i')

  READ_INI = Win32API.new('kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l')

  FIND_WINDOW = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')

  CURSOR_POSITION = Win32API.new('user32', 'GetCursorPos', 'p', 'i')

  

  def initialize

    @cursor = Sprite.new

    @cursor.z = 1000000

    self.set_cursor(MOUSE_ICON)

    update

  end

  

  def update

    @cursor.x, @cursor.y = self.position

  end

  

  def x

    return @cursor.x

  end

  

  def y

    return @cursor.y

  end

  

  def position

    x, y = self.get_client_position

    if APPLY_BORDERS

      if x < 0

        x = 0

      elsif x >= WINDOW_WIDTH

        x = WINDOW_WIDTH - 1

      end

      if y < 0

        y = 0

      elsif y >= WINDOW_HEIGHT

        y = WINDOW_HEIGHT - 1

      end

    end

    return x, y

  end

  

  def get_client_position

    pos = [0, 0].pack('ll')

    CURSOR_POSITION.call(pos)

    SCREEN_TO_CLIENT.call(WINDOW, pos)

    return pos.unpack('ll')

  end

  

  def set_cursor(image)

    @cursor.bitmap = RPG::Cache.picture(image)

  end

  

  def show

    @cursor.visible = true

  end

  

  def hide

    @cursor.visible = false

  end

  

  def self.find_window

    game_name = "\0" * 256

    READ_INI.call('Game', 'Title', '', game_name, 255, '.\\Game.ini')

    game_name.delete!("\0")

    return FIND_WINDOW.call('RGSS Player', game_name)

  end

  

  WINDOW = self.find_window

  

end

 

$mouse = Mouse.new

 

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

# module Input

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

 

module Input

  

  class << Input

    alias update_mousecontroller_later update

  end

  

  def self.update

    $mouse.update

    update_mousecontroller_later

  end

  

  

end

 

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

# Rect

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

 

class Rect

  

  def covers?(x, y)

    return !(x < self.x || x >= self.x + self.width ||

        y < self.y || y >= self.y + self.height)

  end

  

end

 

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

# Sprite

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

 

class Sprite

  

  def mouse_in_area?

    return false if self.bitmap == nil

    return ($mouse.x >= self.x && $mouse.x < self.x + self.src_rect.width &&

        $mouse.y >= self.y && $mouse.y < self.y + self.src_rect.height)

  end

  

end

 

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

# Window_Base

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

 

class Window_Base

  

  def mouse_in_area?

    return ($mouse.x >= self.x && $mouse.x < self.x + self.width &&

        $mouse.y >= self.y && $mouse.y < self.y + self.height)

  end

  

  def mouse_in_inner_area?

    return ($mouse.x >= self.x + 16 && $mouse.x < self.x + self.width - 16 &&

        $mouse.y >= self.y + 16 && $mouse.y < self.y + self.height - 16)

  end

  

end

 

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

# Window_Selectable

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

 

class Window_Selectable

  

  alias contents_is_mousecontroller_later contents=

  def contents=(bitmap)

    contents_is_mousecontroller_later(bitmap)

    begin

      update_selections

      update_mouse if self.active

    rescue

    end

  end

  

  alias index_is_mousecontroller_later index=

  def index=(value)

    index_is_mousecontroller_later(value)

    update_selections

  end

  

  alias active_is_mousecontroller_later active=

  def active=(value)

    active_is_mousecontroller_later(value)

    update_cursor_rect

  end

  

  def update_selections

    @selections = []

    index, ox, oy = self.index, self.ox, self.oy

    (0...@item_max).each {|i|

        @index = i

        update_cursor_rect

        rect = self.cursor_rect.clone

        rect.x += self.ox

        rect.y += self.oy

        @selections.push(rect)}

    @index, self.ox, self.oy = index, ox, oy

    self.cursor_rect.empty

  end

  

  alias update_mousecontroller_later update

  def update

    update_mouse if self.active

    update_mousecontroller_later

  end

  

  def update_mouse

    if self.mouse_in_inner_area?

      update_mouse_selection

      return

    end

    self.index = -1

    if self.contents != nil && @selections.size > 0 && self.mouse_in_area?

      update_mouse_scrolling

    end

  end

  

  def update_mouse_selection

    update_selections if @selections.size != @item_max

    @selections.each_index {|i|

        if @selections[i].covers?($mouse.x - self.x - 16 + self.ox,

            $mouse.y - self.y - 16 + self.oy)

          self.index = i if self.index != i

          return

        end}

    self.index = -1

  end

  

  def update_mouse_scrolling

    if Input.repeat?(Input::C)

      if $mouse.x < self.x + 16

        if self.ox > 0

          $game_system.se_play($data_system.cursor_se)

          self.ox -= @selections[0].width

          self.ox = 0 if self.ox < 0

        end

      elsif $mouse.x >= self.x + self.width - 16

        max_ox = self.contents.width - self.width + 32

        if self.ox <= max_ox

          $game_system.se_play($data_system.cursor_se)

          self.ox += @selections[0].width

          self.ox = max_ox if self.ox >= max_ox

        end

      elsif $mouse.y < self.y + 16

        if self.oy > 0

          $game_system.se_play($data_system.cursor_se)

          self.oy -= @selections[0].height

          self.oy = 0 if self.oy < 0

        end

      elsif $mouse.y >= self.y + self.height - 16

        max_oy = self.contents.height - self.height + 32

        if self.oy <= max_oy

          $game_system.se_play($data_system.cursor_se)

          self.oy += @selections[0].height

          self.oy = max_oy if self.oy >= max_oy

        end

      end

    end

  end

  

end

Which I combined with Cybersam's keyboard script,
Code:
#===============================================================================

# Key.press?(key) keyboard Script

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

# Input Module written by Cybersam. Modified by Synthesize

# version 1.0.0

# May 11, 2008

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

module Key

  @keystatus = Win32API.new("user32","GetAsyncKeyState",['i'],'i')

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

  # Check if specified key is being pressed

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

  def self.press?(key)

    return true if @keystatus.call(key) != 0

    return false

  end

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

  # Create Letter Values

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

  Key_A         = 0x41        # A key, no good

  Key_B         = 0x42        # B key

  Key_C         = 0x43        # C key

  Key_D         = 0x44        # D key

  Key_E         = 0x45        # E key

  Key_F         = 0x46        # F key

  Key_G         = 0x47        # G key

  Key_H         = 0x48        # H key

  Key_I         = 0x49        # I key

  Key_J         = 0x4A        # J key

  Key_K         = 0x4B        # K key

  Key_L         = 0x4C        # L key

  Key_M         = 0x4D        # M key

  Key_N         = 0x4E        # N key

  Key_O         = 0x4F        # O key

  Key_P         = 0x50        # P key

  Key_Q         = 0x51        # Q key

  Key_R         = 0x52        # R key

  Key_S         = 0x53        # S key

  Key_T         = 0x54        # T key

  Key_U         = 0x55        # U key

  Key_V         = 0x56        # V key

  Key_W         = 0x57        # W key

  Key_X         = 0x58        # X key, no good

  Key_Y         = 0x59        # Y key

  Key_Z         = 0x5A        # Z key

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

  # Map Mouse

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

  Mouse_L = 0x01        # left mouse button

  Mouse_R = 0x02        # right mouse button

  Mouse_M = 0x04        # middle mouse button

  Mouse_4 = 0x05        # 4th mouse button

  Mouse_5 = 0x06        # 5th mouse button

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

  # Map Control Buttons

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

  Key_Backspace      = 0x08        # BACKSPACE key

  Key_Tab       = 0x09        # TAB key

  Key_Return    = 0x0D        # ENTER key

  Key_Shift     = 0x10        # SHIFT key

  Key_Control      = 0x11        # CTLR key

  Key_Alt       = 0x12        # ALT key

  Key_Pause     = 0x13        # PAUSE key

  Key_Capslock   = 0x14        # CAPS LOCK key

  Key_Escape    = 0x1B        # ESC key

  Key_Space     = 0x20        # SPACEBAR

  Key_Prior     = 0x21        # PAGE UP key

  Key_Next      = 0x22        # PAGE DOWN key

  Key_End       = 0x23        # END key

  Key_Home      = 0x24        # HOME key

  Key_Left      = 0x25        # LEFT ARROW key

  Key_Up        = 0x26        # UP ARROW key

  Key_Right     = 0x27        # RIGHT ARROW key

  Key_Down      = 0x28        # DOWN ARROW key

  Key_Select    = 0x29        # SELECT key

  Key_Print     = 0x2A        # PRINT key

  Key_Snapshot  = 0x2C        # PRINT SCREEN key

  Key_Insert    = 0x2D        # INS key

  Key_Delete    = 0x2E        # DEL key

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

  # Map Number Keys

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

  Key_0         = 0x30        # 0 key

  Key_1         = 0x31        # 1 key

  Key_2         = 0x32        # 2 key

  Key_3         = 0x33        # 3 key

  Key_4         = 0x34        # 4 key

  Key_5         = 0x35        # 5 key

  Key_6         = 0x36        # 6 key

  Key_7         = 0x37        # 7 key

  Key_8         = 0x38        # 8 key

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

  # Map Windows Key

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

  Key_Lwin      = 0x5B        # Left Windows key (Microsoft Natural keyboard)

  Key_Rwin      = 0x5C        # Right Windows key (Natural keyboard)

  Key_Apps      = 0x5D        # Applications key (Natural keyboard)

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

  # Map Numpad

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

  Key_Numpad0   = 0x60        # Numeric keypad 0 key

  Key_Numpad1   = 0x61        # Numeric keypad 1 key

  Key_Numpad2   = 0x62        # Numeric keypad 2 key

  Key_Numpad3   = 0x63        # Numeric keypad 3 key

  Key_Numpad4   = 0x64        # Numeric keypad 4 key

  Key_Numpad5   = 0x65        # Numeric keypad 5 key

  Key_Numpad6   = 0x66        # Numeric keypad 6 key

  Key_Numpad7   = 0x67        # Numeric keypad 7 key

  Key_Numpad8   = 0x68        # Numeric keypad 8 key

  Key_Numpad9     = 0x69        # Numeric keypad 9 key

  Key_Multiply  = 0x6A        # Multiply key (*)

  Key_Add       = 0x6B        # Add key (+)

  Key_Seperator = 0x6C        # Separator key

  Key_Subtract  = 0x6D        # Subtract key (-)

  Key_Decimal   = 0x6E        # Decimal key

  Key_Divide    = 0x6F        # Divide key (/)

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

  # Map F-keys

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

  Key_F1        = 0x70        # F1 key

  Key_F2        = 0x71        # F2 key

  Key_F3        = 0x72        # F3 key

  Key_F4        = 0x73        # F4 key

  Key_F5        = 0x74        # F5 key

  Key_F6        = 0x75        # F6 key

  Key_F7        = 0x76        # F7 key

  Key_F8        = 0x77        # F8 key

  Key_F9        = 0x78        # F9 key

  Key_F10       = 0x79        # F10 key

  Key_F11       = 0x7A        # F11 key

  Key_F12       = 0x7B        # F12 key

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

  # Map Numlock and Scroll keys

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

  Key_Numlock   = 0x90        # NUM LOCK key

  Key_Scroll    = 0x91        # SCROLL LOCK key

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

  # Map Control, Shift and Alt keys

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

  Key_Lshift       = 0xA0        # Left SHIFT key

  Key_Rshift       = 0xA1        # Right SHIFT key

  Key_Lcontrol  = 0xA2        # Left CONTROL key

  Key_Rcontrol  = 0xA3        # Right CONTROL key

  Key_Lalt       = 0xA4        # Left ALT key

  Key_Ralt       = 0xA5        # Right ALT key

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

  # Map seperator keys

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

  Key_Comma         = 0xBC        # , key

  Key_Dash         = 0xBD        # - key

  Key_Period         = 0xBE        # . key  

end

So that I've been making nice simple statements within pre-existing functions, turning these:

if Input.trigger?(Input::C)

into these:

$mousel = Key::Mouse_L
if Input.trigger?(Input::C) or Key.press?($mousel)


To have normal 'selectable' buttons be clickable, as well as retain their "C button" function.

That all worked really good (and i recommend it to anyone who wants a mouse in their game) :tongue:

But, if I'm just clicking around and it's not on a specific target, it'll choose the last option by default, or the game will just crash with that NilClass error, if it's in the Journal screen.

again, let me know if there's any better way i can add details... and I can't thank you enough for the effort :wink:
 
This appears to do the trick:

Code:
    # If C button was pressed

    if Input.trigger?(Input::C) or Key.press?(Key::Mouse_L)

      if @journal_window.selectable == true

        x,y = $mouse.position

        if x >= 106 and x <= 534 and y >= 86 and y <= (86 + @journal_window.item_max * 32)

          @journal_window.active = false

          @journal_window.visible = false

          @desc_window.active = true

          @desc_window.visible = true

          @desc_window.refresh(@journal_window.index)

        end

      end

    end

 

The numbers for x & y are the window position & size, plus (or minus) the 16 pixel margin
 

Drey

Member

no luck, unfortunately...

it doesn't seem to accept the term "item_max"?
Untitled2.jpg

(forget it's on line 155, I added some hotkeys above the mouse script.
It's the same script as the last blurb, but lower down.)

But it's strange, because your script seems fine to me... any ideas, Brew?


[Added note] damn... that piece of code actually made this error show up even if you click correctly, on the specific journal entries.
 

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