How do I customize the keyboard?

From OHRRPGCE-Wiki
Jump to: navigation, search

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


Arrow Keys Movement
Space or Enter or CTRL Use/Talk
ESC or ALT Menu/Cancel
Hold ESC 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

  variable (x,y,d,w)
  
  w := 3 #wait time between actions
  
  if (hero is walking(me) == false) then,begin
    if (topmenu == false) then,begin
      if (current text box == -1) then,begin
    
        if (key is pressed(Key:Up)) then (walk hero(me, up, 1), exit script)
        if (key is pressed(Key:Left)) then (walk hero(me, left, 1), exit script)
        if (key is pressed(Key:Down)) then (walk hero(me, down, 1), exit script)
        if (key is pressed(Key:Right)) then (walk hero(me, right, 1), exit script)
      end
    end
    
    if (key is pressed(Key:Space),or,key is pressed(Key:Enter),or,key is pressed(Key:Ctrl)) then,begin
    
      if (topmenu == false) then,begin
    	if (current text box == -1) then,begin
          x := hero X(me)
          y := hero Y(me)
          d := hero direction(me)
          if (d == up) then(decrement(y))
          if (d == left) then(decrement(x))
          if (d == down) then(increment(y))
          if (d == right) then(increment(x))
          if (NPC at spot (x,y)) then,begin
            use NPC(NPC at spot(x,y)) 
            wait (w)
            exit script
          end
        end
      end
      if (topmenu) then, begin
        use menu item(selected menu item)
        wait (w)
        exit script
      end
      if (current text box >= 0) then,begin
      	advance text box
      	wait (w)
      	exit script
      end
    end
    
    
    if (key is pressed(Key:Esc),or,key is pressed(Key:Alt)) then,begin
      if (top menu == false) then,begin
        main menu
        wait (w)
        exit script
      end
      else,begin
        close menu(top menu)
        wait (w)
        exit script
      end
    end
  end    
        
end

Caveats: This works in the main menus and all custom menus, but not on any other built in menus. Additionally, due to a bug in the Ypsiliform version, use menu item doesn't work on menu items that close the current menu, though with this script you can close the current menu with the secondary button (the same one that opens it). This has been fixed in the nightly build. Finally, this doesn't work in battle menus, for obvious reasons.