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.

A question of ethics (see last post)

I'm using Near's keyboard input module and trying to use the numpad for movement rather than the arrows.

Here is the code I used, why does it not work? instead, it gives me 8 directional movement with the arrow keys.

Code:
class Game_Player < Game_Character

  def update
    # Remember whether or not moving in local variables
    last_moving = moving?
    # If moving, event running, move route forcing, and message window
    # display are all not occurring
    Keyboard.update
    Mouse.update
    unless moving? or $game_system.map_interpreter.running? or
           @move_route_forcing or $game_temp.message_window_showing
      # Move player in the direction using the numpad
      if Keyboard.pressed?(Keyboard::Numberpad[1])
        move_lower_left
      end
      if Keyboard.pressed?(Keyboard::Numberpad[2])
        move_down
      end
      if Keyboard.pressed?(Keyboard::Numberpad[3])
        move_lower_right
      end
      if Keyboard.pressed?(Keyboard::Numberpad[4])
        move_left
      end
      if Keyboard.pressed?(Keyboard::Numberpad[6])
        move_right
      end
      if Keyboard.pressed?(Keyboard::Numberpad[7])
        move_upper_left
      end
      if Keyboard.pressed?(Keyboard::Numberpad[8])
        move_up
      end
      if Keyboard.pressed?(Keyboard::Numberpad[9])
        move_upper_right
      end
    end
    # Remember coordinates in local variables
    last_real_x = @real_x
    last_real_y = @real_y
    super
    # If character moves down and is positioned lower than the center
    # of the screen
    if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
      # Scroll map down
      $game_map.scroll_down(@real_y - last_real_y)
    end
    # If character moves left and is positioned more let on-screen than
    # center
    if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
      # Scroll map left
      $game_map.scroll_left(last_real_x - @real_x)
    end
    # If character moves right and is positioned more right on-screen than
    # center
    if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
      # Scroll map right
      $game_map.scroll_right(@real_x - last_real_x)
    end
    # If character moves up and is positioned higher than the center
    # of the screen
    if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
      # Scroll map up
      $game_map.scroll_up(last_real_y - @real_y)
    end
    # If not moving
    unless moving?
      # If player was moving last time
      if last_moving
        # Event determinant is via touch of same position event
        result = check_event_trigger_here([1,2])
        # If event which started does not exist
        if result == false
          # Disregard if debug mode is ON and ctrl key was pressed
          unless $DEBUG and Input.press?(Input::CTRL)
            # Encounter countdown
            if @encounter_count > 0
              @encounter_count -= 1
            end
          end
        end
      end
      # If C button was pressed
      if Input.trigger?(Input::C)
        # Same position and front event determinant
        check_event_trigger_here([0])
        check_event_trigger_there([0,1,2])
      end
    end
  end
end
 
Sorry for the double post, but I found the answer to my problem. Here is what I found:

1) When I deactivated mouse keys in windows, the numpad worked with num lock off
2) the following keys also moved the character:
Home
End
PgDn
PgUp
Up
Left
Right
Down

3) I changed the values in the keyboard module to work when num lock is activated.
4) I will now go about changing any other values that are incorrect and add any that are missing.
5) The most recent version of cybersam's script that is floating around is almost the same as near's, while cybersam's version 1 uses hex number values. By creating a new script based off ver 5 of Near's and ver 1 of Cybersam's, can I claim it as my script and post it as thus, giving credit, or is it considered a modded script and would I need one or both of their permission to post my version?
 

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