How do I customize the keyboard?

From OHRRPGCE-Wiki
Jump to navigation Jump to search

There is no built-in feature to customize the keyboard in an OHRRPGCE game. The default keyboard controls are:


Arrow Keys Movement
Space or Enter or CTRL Use/Talk
ESC or ALT Menu/Cancel
Hold ESC or TAB Run (battle)


It is possible to set up your own keyboard controls using plotscripting. You must use the suspend player command and suspend box advance to disable normal keyboard actions, and then create an On-Keypress script that uses the key is pressed command to check what key the player has pressed.

Here is an example script that re-implements the default controls. You can customize it to suit your own needs

plotscript, keypress handler, begin

  if (hero is walking(me) == false) then, begin
    if (topmenu == false) then, begin
      if (current text box == -1) then, begin
    
        if (key is pressed(up key)) then (walk hero(me, up, 1), exit script)
        if (key is pressed(left key)) then (walk hero(me, left, 1), exit script)
        if (key is pressed(down key)) then (walk hero(me, down, 1), exit script)
        if (key is pressed(right key)) then (walk hero(me, right, 1), exit script)
      end
    end
    
    if (keypress(use key)) then, begin
      if (topmenu == false) then, begin
    	if (current text box == -1) then, begin

         variable (x,y, who)
          x := hero X(me)
          y := hero Y(me)
          switch(hero direction(me)) do (
            case (up) y -= 1
            case (down) y += 1
            case (left) x -= 1
            case (right) x += 1
          )
          if (NPC at spot (x,y)) then (
            who := (NPC at spot(x,y))
            if (read NPC (who,NPCstat:when activated) <> NPCwhenactivated:donotfaceplayer) then (
              switch(hero direction(me)) do, (
                case (up) do (set NPC direction (who, down))
                case (down) do (set NPC direction (who, up))
                case (left) do (set NPC direction (who, right))
                case (right) do (set NPC direction (who, left))
              )
            )
            wait
            use npc (who)
          )
        end
      end, else if (topmenu) then, begin
        use menu item(selected menu item)
      end, else if (current text box >= 0) then, begin
      	advance text box
      end
    end
    
    if (keypress(menu key)) then, begin
      if (top menu == false) then, begin
        main menu
      end, else, begin
        close menu(top menu)
      end
    end
  end    
end

Caveats: This works in the main menus and all custom menus, but not on any other built in menus, including battle menus, because scripts don't run during battles.