I'm making a thing to help me keep track of my players for d&d and i hit a roadblock. relevant piece of code:
playercount = nil
playername = nil
playernamegroup = Array.new
playeracgroup = Array.new
playermaxhpgroup = Array.new
playercurrenthpgroup = Array.new
def party(n)
return if n == 0
party(n-1)
player = {}
puts "-What's player #{n}'s name?"
playername = gets.chomp
playernamegroup << playername
puts "-What's their AC?"
playerac = gets.chomp.to_i
puts "-Got it. What's their max HP?"
playermaxhp = gets.chomp.to_i
$players[n] = player
puts "-Okay."
end
there's a loop further down that runs the party block the number of times given, here:
loop do
puts "-How many players today?"
playercount = gets.chomp.to_i
if 0 >= playercount
puts "-You can't have no players in a party. That's not D&D, that's you having no friends."
redo
elsif 8 < playercount
puts "-Hey now, that's a huge party. I can only handle eight players at once."
redo
elsif 8 >= playercount
break
else
puts "-A number between 1 and 8, please."
redo
end
end
$players = []
party(playercount)
when i run it i get: Error: undefined method `playernamegroup' for main:Object
i've tried shuffling things around and still get the same error, and i've looked through other asks and haven't figured it out. help?