Local variable in event?

It seems to me that you are overcomplicating matters.

Go ahead should that be the goal. I suggest adding some lambda functions as well. It is easy to add complexity with those, and they are also fun to play with 😀

Otherwise what are you attempting to do? No, what problem are you trying to solve? Do you want to store new information specific to an event? To an interpreter? Actually want to use local variables (we already know the answer to this is no)? Share data among events?

First step is to understand how the interpreter structure work. I went ahead and search for where Game_Interpreter instances are created in the code. I found the information:

  • Battle event interpreter
  • Parallel common event interpreter
  • Parallel map event interpreter
  • Map interpreter
  • Interpreter child interpreter (Common event call)

Remember that you have different types of events

  • Battle event
  • Map event
  • Common event

Searching and finding valuable information is usually an important step.

*hugs*

 - Zeriab
What do you mean, you "can't prefix the event id"? @event_id (not event_id) in the interpreter means the current event's id.
The whole point for me not ussing an attr_accessor is that an attr_accessor can not automatically prefix the @event_id in the Game_Intepreter. And neither can it be done through adding a hash-setter (not supported by Ruby)

anyway, why not just use a global variable? (aside from it denoted as $, which means 1 additional character)
Yeah a $global = {} could probable be used. Maybe I'm over complicating things.

This may interest you...

class Testerdef initialize

@local = {}

end

def local(key, value)

@local[key] = value

self.class.send🙂define_method, key) do

value

end

end

end

test = Tester.new

test.local🙂one, 1)

test.local🙂two, 2)

p test.one

p test.two
That's pretty much what I was looking for! Thanks that should do it 🙂 .
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/local-variable-in-event.20861/