blizzabs controls config

Started by nathmatt, June 05, 2010, 08:48:04 am

Previous topic - Next topic

nathmatt

im trying to make a blizzabs controls config but i keep getting an error heres the code

(0...256).each{|i|
if Input.trigger?(i)
  Input::Up = [[Input::Key[Input::Key.index(i)]]]
  break
end}
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


SBR*

Firstly, what is the error?

Secondly, why do you want the key to be in two arrays? So you want it to be accessed by using
Input::Up[0][0]
?

nathmatt

didnt pay attention that is was in another array and it is a syntax on the Input::Up line
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


SBR*


nathmatt

Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


SBR*

June 05, 2010, 12:07:03 pm #5 Last Edit: June 06, 2010, 11:16:11 am by SBR*
Why not just do it like this?
Input::Up = [i]

YOU just entered the ASCII number to find the key of the hash, just to enter it in the hash again to find the ASCII number  :urgh:.

Oh, and I just looked at the blizz ABS simple ASCII table, and I saw that not every value is used, e.g. 3. So you can better do this:
Input::Key.each_value{|i|
if Input.trigger?(i)
   Input::Up = [i]
   break
end}


Oh, and on a side note, which you of course already thought of:
Constants are kept the same throughout the whole gaming session, so if you switch files or start a new game, your configuration stays the same. Also, if you restart the game, everthing is set back to default, so you have to configure it again. So: Remember to store the configuration in a game variable and update it everytime you change maps.

EDIT: So is it fixed now?

nathmatt

no because i dont think Input::Up = works
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


SBR*

It should work, it's a constant, right? It is predefined in module Input, so if you change it, you change it until the end of the gaming session?

G_G

module variables are constants. Constants cannot be changed.

SBR*

I know, they CAN be changed, but their data is lost when quitting the game. I tested it:

Test: ShowHide

I made:
module TEST
TEST = 'unchanged'
end

And after that I printed TEST in an event's script call:
print TEST::TEST

It printed 'unchanged'.
After that I changed it in an event's script call:
TEST::TEST = 'changed'

and printed it again in an event's script call:
print TEST::TEST

It printed 'changed'.

See?

nathmatt

thats what i thought until i read this
Quote from: CountVlad on June 03, 2010, 08:53:22 pm
I was wondering if anyone knows how to allow the user to change the BlizzABS controls in game, or if it's even possible?
Most games now allow you to change the controls, so it's a nice feature that's been requested and one I'd like to include in my game.
Quote from: winkio on June 03, 2010, 09:01:42 pm
yes.  Use a script call of the following form:

Input::UP = [Input::Key['T']]


UP is the control, T is the key that will be assigned to it.  You can assign multiple keys to the same control by adding elements to the array.
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


SBR*

That's what I said. Now we have a practical proof and Winkio's word, we can thrust that you can do it, right? So, what would the error be?

nathmatt

June 06, 2010, 01:06:05 pm #12 Last Edit: June 06, 2010, 03:06:36 pm by nathmatt
i was posting that when you posted that pose it told me some1 just posted but i posted it any way but for some reason it always gives me that syntax error here is the full code change how i was doing it i defined a change in Input to see if it did better in input

Spoiler: ShowHide
class Scene_Contols
 
  def main
    # Make command window
    commands = [
    'Up',
    'Left',
    'Down',
    'Right',
    'Prevpage',
    'Nextpage',
    'Confirm',
    'Cancel',
    'Attack',
    'Defend',
    'Skill',
    'Item',
    'Select',
    'Run',
    'Sneak',
    'Jump',
    'Turn']
    @help_window = Window_Help.new
    @help_window.set_text('Controls',1)
    @command_window = Window_Item_Command.new(commands,get_contols)
    @text_window = Window_Help.new
    @text_window.set_text('Press A Key')
    @text_window.width = 200
    @text_window.x = 220
    @text_window.y = 176
    @text_window.z = 100
    @text_window.visible = false
    # 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
  end
 
  def update
    @command_window.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Menu.new(4)
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @text_window.visible = true
      loop do
        Input::Key.each_value{|i|
        if Input.trigger?(i)
          Input.change(@command_window.index,i)
          break
        end}
      end
      @text_window.visible = false
    end
  end
 
  def get_contols
    name = [
    Input::Up,
    Input::Left,
    Input::Down,
    Input::Right,
    Input::Prevpage,
    Input::Nextpage,
    Input::Confirm,
    Input::Cancel,
    Input::Attack,
    Input::Defend,
    Input::Skill,
    Input::Item,
    Input::Select,
    Input::Run,
    Input::Sneak,
    Input::Jump,
    Input::Turn]
    name.each_index{|i| name[i] = Input::Key.index(name[i][0])}
    return name
  end
 
end
#==============================================================================
# Window_Item_Command
#==============================================================================

class Window_Item_Command < Window_Selectable
 
  def initialize(commands,name)
    super(0, 64, 640, 416)
    @commands = commands
    @name = name
    refresh
    self.index = 0
    self.active = true
  end
 
  def item
    return @commands[self.index]
  end
 
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @item_max = @commands.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      @commands.each_index{|i|draw_item(i)}
    end
  end
 
  def draw_item(index)
    y  = index * 32
    self.contents.draw_text(4, y, 120, 32, @commands[index])
    self.contents.draw_text(420, y, 120, 32, @name[index])
  end
 
end

module Input
 
  def self.change(key,value)
    case key
    when 0
      Up = value
    when 1
      Left = value
    when 2
      Down = value
    when 3
      Right = value
    when 4
      Prevpage = value
    when 5
      Nextpage = value
    when 6
      Confirm = value
    when 7
      Cancel = value
    when 8
      Attack = value
    when 9
      Defend = value
    when 10
      Skill = value
    when 11
      Item = value
    when 12
      Select = value
    when 13
      Run = value
    when 14
      Sneak = value
    when 15
      Jump = value
    when 16
      Turn = value
    end
  end
end
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script


SBR*

Firstly, in method get_contols, you're defining name between do and end, and I thought that local variables aren't defined outside do and end anymore? Also, you're asking name to be set to that value, so you'll have just one value, not an array. So use:
@name.each_index{|i| @name[i] = Input::Key.index(@name[i])}

But I can't find anything else...

nathmatt

actually i did that just forgot to post it in code tags
Join Dead Frontier
Sorry, I will no longer be scripting for RMXP. I may or may not give support for my scripts. I don't have the will to script in RGSS anymore.
My script