Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.
Original Source
- Original title: [Ace] Can't figure out what I am doing wrong.
- Original author: omoney
- Original date: June 19, 2012
- Source thread: https://forums.rpgmakerweb.com/threads/ace-cant-figure-out-what-i-am-doing-wrong.2651/
- Source forum path: Game Development Engines > Ruby Game System (RGSS) Scripts > RGSSx Script Support
Summary
My question is why is it that when I call getValue(name) in the code below, that 0 returns when I'm expecting an array. Thanks for reading Spoiler class exampleClass attr_accessor :variableName
Archived First Post
My question is why is it that when I call getValue(name) in the code below, that 0 returns when I'm expecting an array. Thanks for reading
Note: I have two events on the map that each activate with action button. The first one calls "anotherMethod" while the second one calls getValue(name). First I talk to the first event than I talk to the second event but getValue(name) returns 0. I am unsure why that is.
More details: http://www.mediafire.com/?zca21o16sutpgxz
class exampleClass
attr_accessor :variableName
def initialize()
@variableName = {}
end
def someMethod()
@variableName["example"] = [1,2,3,4]
end
end
class Game_Interpreter
alias original_initialize initialize
def initialize(depth = 0)
original_initialize(depth)
$global_variable = exampleClass.new
end
def anotherMethod()
$global_variable.someMethod()
end
def getValue(name)
return $global_variable.variableName[name]
end
end
attr_accessor :variableName
def initialize()
@variableName = {}
end
def someMethod()
@variableName["example"] = [1,2,3,4]
end
end
class Game_Interpreter
alias original_initialize initialize
def initialize(depth = 0)
original_initialize(depth)
$global_variable = exampleClass.new
end
def anotherMethod()
$global_variable.someMethod()
end
def getValue(name)
return $global_variable.variableName[name]
end
end
Code:
More details: http://www.mediafire.com/?zca21o16sutpgxz
Downloads / Referenced Files
Log in to download
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadCreator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
0
replies
1
view
Topic Summary
Loading summary...