RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

calling a varying hash?

Started by da good king, January 22, 2008, 07:27:42 PM

0 Members and 1 Guest are viewing this topic.

da good king

i was wondering if it is possilbe to call a certain hash based on a variable. i.e. like calling different arrays using a hash, but using the next step further than a hash??? (superhash? idk)

Zeriab

I am not really sure what exactly you want.
I suggest you try to explain what you want to accomplish.

da good king

wat im saying is, and much like my earlier question about arrays, i have two hashes:

Arshes = {
'v1' => [2,3],
'v2' => [3,4]
}
Basil = {
'v1' => [6,29],
'v2' => [8,31]
}

now i want the game to call "the actors name"['v1'][1], so how do I do that?

modern algebra

I suppose you could make a hash like this: {'Arshes' => {'v1' => [2,3], 'v2' => [3,4]}, 'Basil' => {'v1' => [6,29], 'v2' => [8, 31]}} though I don't know if that would work (I don't see why not though)

Or you could make a method with case branches, as in


def get_actor (name)
  case name
  when 'Arshes'
    return {'v1' => [2,3], 'v2' => [3,4]}
  when 'Basil'
    return {'v1' => [6,29], 'v2' => [8, 31]}
  end
end


It seems like this is a fairly complicated structure. What are you planning?  :o

da good king

Hahaha, another super late reply, but who cares zzzz. Might as well leave all ?'s answered and resolved. I did in fact find a silly way to circumvent this problem using some instance variables and stored hashes.

Quote from: Seamus on January 23, 2008, 07:08:45 PM
It seems like this is a fairly complicated structure. What are you planning?  :o
Actually, the purpose of this is to make things less complicated :P. Simply, I'm just making easily accessible data banks w/ quick references to make data input easy on me. I'm much more accustomed to typing out a nice organized spreadsheet for my data than anything else.