This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
TheOddByte's profile picture

Need Help With the code

Started by TheOddByte, 09 December 2012 - 05:31 AM
TheOddByte #1
Posted 09 December 2012 - 06:31 AM
Ok so I've basically started with a game named Boxer Tournament
and I get this error code everytime I try to Use the Action Punch:
Boxer:377: attempt to concatenate nil and string

CODE:

--Boxer
--Made By Hellkid98
--General
local var = 0
local hp = 100 --Player Health
local sta = 50 -- Stamina
local myScore = 0
local money = 0
local wins = 0
local loss = 0
local day = 1
local regainHP = math.random(25,50)
local regainSTA = math.random(25,50)
local lvl = 1
enemyLvl = 1
enemySta = 50
enemyHP = 100
local var4 = 10 --Strenght
local var5 = 10 --Speed
local var6 = 10 -- Defense
d = damage1
a = agility1
s = speed1
dfc = defence1
eAtk = enemyDMG1
--Skills
local damage1 = math.random(5,10)
local damage2 = math.random(5,20)
local damage3 = math.random(5,30)
local damage4 = math.random(5,40)
local damage5 = math.random(5,50)
local agility1 = math.random(5,10)
local agility2 = math.random(10,20)
local agility3 = math.random(20,30)
local agility4 = math.random(30,40)
local agility5 = math.random(40,50)

--Enemies
local enemyHP1 = 100 -- Enemies Health
local enemyHP2 = 125
local enemyHP3 = 150
local enemyHP4 = 175
local enemyHP5 = 200
local enemyDMG1 = math.random(2,8) --Enemies Damage. NOTE:If they are Higher Level they get better damage
local enemyDMG2 = math.random(10,15) --For example: if enemy level = 2 then eAtk = enemyDMG2
local enemyDMG3 = math.random(20,30)
local enemyDMG4 = math.random(30,45)
local enemyDMG5 = math.random(50,60)
--Randomly Selects An Enemy PS. This Is For Solo Play
function randomChallenger()
var = math.random(1,20)
if var ==1 then
enemy = "Rock Hardwood"
elseif var ==2 then
enemy = "Olov Reynkon"
elseif var ==3 then
enemy = "Usumo Binlayden"
elseif var ==4 then
enemy = "Duke Parker"
elseif var ==5 then
enemy = "Peter Pestrami"
elseif var ==6 then
enemy = "Lucky Mook"
elseif var ==7 then
enemy = "Gouda Croissant"
elseif var ==8 then
enemy = "John Dorkian"
elseif var ==9 then
enemy = "Rochy Ballboda"
elseif var ==10 then
enemy = "Felix Mjellberg"
elseif var ==11 then
enemy = "Turk Turkleton"
elseif var ==12 then
enemy = "Rock Hardwood"
elseif var ==13 then
enemy = "Rock Hardwood"
elseif var ==14 then
enemy = "Rock Hardwood"
elseif var ==15 then
enemy = "Rock Hardwood"
elseif var ==16 then
enemy = "Rock Hardwood"
elseif var ==17 then
enemy = "Rock Hardwood"
elseif var ==18 then
enemy = "Rock Hardwood"
elseif var ==19 then
enemy = "Rock Hardwood"
elseif var ==20 then
enemy = "Rock Hardwood"
cleanScreen()
term.setCursorPos(10,9)
print(myName..".VS."..enemy)
end
end

os.pullEvent = os.pullEventRaw
function drawAt(x,y,text)
term.setCursorPos(x,y)
term.write(text)
end
function cleanScreen()
term.clear()
term.setCursorPos(1,1)
end
--Draw Cursor
function drawCursor(x1,x2,y)
  drawAt(x1,y,"[")
  drawAt(x2,y,"]")
end
--Resets Everything
function resetStats()
hp = 100
sta = 50
myScore = 0
money = 0
wins = 0
loss = 0
day = 1
end

--Credits
function credits()
cleanScreen()  
drawAt(1,1,"+----------------------------------------+")
drawAt(1,2,"|			  CREDITS				   |")
drawAt(1,3,"|----------------------------------------|")
drawAt(1,4,"|										|")
drawAt(1,5,"|  CODED BY: Hellkid98				   |")
drawAt(1,6,"|  BETA TESTERS:						 |")
drawAt(1,7,"|										|")
drawAt(1,8,"|										|")
drawAt(1,9,"|										|")
drawAt(1,10,"|										|")
drawAt(1,11,"|										|")
drawAt(1,12,"+----------------------------------------+")
drawAt(1,13,"")
drawAt(1,14," PRESS [ENTER] TO EXIT")
event, p1 = os.pullEvent()
		if event == "key" then
		  if p1 == 28 then
	return
end
end
end	


local warningOptions = {
"Yes", "No"
}
local menuOptions =
{
  "Solo",  "Multiplayer",  "Settings",  "Highscore",  "Help",  "Credits",  "Exit"
}

local hMenuOptions =
{
"Tournament", "Quick Match", "Relax", "Open Map", "Exit To Main Menu"
}


--Draws the Gameplay
function drawMatchArt()
drawAt(11,9,"ACTION:")
end
--Draw The players and The Enemies Grid
function drawGrids()
drawAt(1,1,"|======| "..myName.."   ")
drawAt(1,2,"| O ..O| HP:"..hp.."	")
drawAt(1,3,"|  _   | STA:"..sta.."  ")
drawAt(1,4,"|	  | LVL:"..lvl.."  ")
drawAt(1,5,"|------+				")
drawAt(28,1,"|======| "..enemy.."   ")
drawAt(28,2,"|O ..O | HP:"..enemyHP.."	")
drawAt(28,3,"|   _  | STA:"..enemySta.."  ")
drawAt(28,4,"|	  | LVL:"..enemyLvl.."  ")
drawAt(28,5,"|------+				")
end


--Draws The Main Menu
function drawMenu()
  cleanScreen()
  drawAt(1,1,"+------------------------------------------------+")
  drawAt(1,2,"|			Boxer Tournament V 0.1			  |")
  drawAt(1,3,"+------------------------------------------------+")
  drawAt(1,4,"|												|")
  drawAt(1,5,"|												|")
  drawAt(1,6,"|												|")
  drawAt(1,7,"|												|")
  drawAt(1,8,"|												|")
  drawAt(1,9,"|												|")
  drawAt(1,10,"|												|")
  drawAt(1,11,"|												|")
  drawAt(1,12,"|												|")
  drawAt(1,13,"|												|")
  drawAt(1,14,"|												|")
  drawAt(1,15,"|												|")
  drawAt(1,16,"|												|")
  drawAt(1,17,"|												|")
  drawAt(1,18,"+------------------------------------------------+")
  for i = 1, #menuOptions do
		drawAt(3,i + 3,"*")
		drawAt(5,i + 3,menuOptions[i])
  end
  drawCursor(2,4,2 + menuStat)
end

--Highscore	
function highScore()
cleanScreen()  
print("+------------------------------------------------+")
print("|			  +--Highscore--+				   |")
print("|------------------------------------------------|")	
print("| 1. James Bond  Score: 1337				  |")							
print("| 1. James Bond  Score: 1337				  |")  
print("| 1. James Bond  Score: 1337				  |")	
print("| 1. James Bond  Score: 1337				  |")	
print("| 1. James Bond  Score: 1337				  |")	
print("| 1. James Bond  Score: 1337				  |")	
print("| 1. James Bond  Score: 1337				  |")	
print("| 1. James Bond  Score: 1337				  |")
print("| 1. James Bond  Score: 1337				  |")
print("| 1. James Bond  Score: 1337				  |")
print("+------------------------------------------------+")
print("")
print(" PRESS [ENTER] TO EXIT")
event, p1 = os.pullEvent()
		if event == "key" then
		  if p1 == 28 then
return
end
end
end

--Main Menu Events
function menuEvents()
event, p1 = os.pullEvent()
if event == "key" then
if p1 == 200
then
menuStat = menuStat - 1
if menuStat < 2 then
menuStat = 8
end
elseif p1 == 208 then
		 menuStat = menuStat + 1
		 if menuStat > 8 then
		   menuStat = 2
	 end
	 elseif p1 == 28 then
		   if menuStat == 2 then
	 enterName()
	 solo()
	 elseif menuStat == 3 then
	 cleanScreen()
	 print("Multiplayer Not Available Yet")
	 sleep(2)
	 menu()
	 elseif menuStat == 4 then
	 cleanScreen()
	 print("Settings Not Available Yet")
	 sleep(2)
	 menu()
	 elseif menuStat == 5 then
	 highScore()
	 elseif menuStat == 6 then
	 cleanScreen()
	 print("Help Not Available Yet")
	 sleep(2)
	 menu()
	 elseif menuStat == 7 then
	 credits()
	 elseif menuStat == 8 then
	 os.reboot()
	 menu()
	 end
	 end
	 end
	 end
	
	
-----------------------------------------
--HomeMenu Events
function hMenuEvents()
event, p1 = os.pullEvent()
if event == "key" then
if p1 == 200
then
menuStat = menuStat - 1
if menuStat < 2 then
menuStat = 6
end
elseif p1 == 208 then
		 menuStat = menuStat + 1
		 if menuStat > 6 then
		   menuStat = 2
	 end
	 elseif p1 == 28 then
	 if menuStat == 2 then
	 startTournament()
		   elseif menuStat == 3 then
	 randomChallenger()
	 fight()
	 elseif menuStat == 4 then
	 relax()
	 elseif menuStat == 5 then
	 openMap()
	 elseif menuStat == 6 then
	 warningMenu()
	 end
	 end
	 end
	 end
	
	
--------------------------------
--Tournament
function startTournament()
cleanScreen()
print("Nothing Available")
sleep(1)
return
end
--Quick Match
function fight()
cleanScreen()
matchPlaying = true
repeat
checkMatch()
drawGrids()
drawMatchArt()
if matchPlaying == false
then
solo()
end
fight = string.lower(read())
if fight == "Punch" or fight == "punch"
then
print(myName.." did "..d.." damage")
print(enemy.." did "..eAtk.." damage")
enemyHP = enemyHP - d
hp = hp - eAtk
sleep(2)
cleanScreen()
if hp < 1 then hp = 0
if enemyHP < 1 then enemyHP = 0
end
end
elseif fight == "Block" or fight == "block" then
block = math.random(1,2)
if block == 1
then
print(enemy.." Blocked Successfully")
sleep(2)
cleanScreen()
elseif block == 2 then
print(enemy.." Blocked Unsuccessfully")
hp = hp - eAtk
sleep(2)
cleanScreen()
if hp < 1 then hp = 0
if enemyHP < 1 then enemyHP = 0
end
end
else
term.setCursorPos(10,9)
print("Unkwon Action")
cleanScreen()
end
end
until matchPlaying == false
end
--Checks If someone Has Won
function checkMatch()
if hp == 0 then
drawAt(10,9,enemy.." Won")
loss = loss + 1
sleep(2)
matchPlaying = false
elseif enemyHP == 0
then
drawAt(10,9,myName.." Won")
wins = wins + 1
sleep(2)
matchPlaying = false
end
end


--Relax
function relax()
sta = sta + regainSTA
hp = hp + regainHP	
day = day + 1	
cleanScreen()
drawAt(6,6,"Played "..day.." days")
sleep(2)
solo()
end	
	
	 --Draws the Home Menu
function drawHomeMenu()
  cleanScreen()
  drawAt(1,1,"+-------------------------+----------------------+")
  drawAt(1,2,"|		 HOME			|======+ "..myName.."   ")
  drawAt(1,3,"|-------------------------| O ..O| HP:"..hp.."	")
  drawAt(1,4,"|						 |  _   | STA:"..sta.."  ")
  drawAt(1,5,"|						 |	  | LVL:"..lvl.."  ")
  drawAt(1,6,"|						 |------+				")
  drawAt(1,7,"|						 | MONEY:"..money.."$	")
  drawAt(1,8,"|						 | WINS:"..wins.."	   ")
  drawAt(1,9,"|						 | LOSSES:"..loss.."	  ")
  drawAt(1,10,"|						 | SCORE:"..myScore.."   ")
  drawAt(1,11,"+-------------------------+----------------------+")


  for i = 1, #hMenuOptions do
		drawAt(4,i + 3,"*")
		drawAt(6,i + 3,hMenuOptions[i])
  end
  drawCursor(3,5,2 + menuStat)
end
	
	
	
----------------------------------------------
--Draws Warning Menu
function drawWarningMenu()
cleanScreen()
drawAt(1,1,"+------------------------------------------------+")
drawAt(1,2,"|		  #####---!WARNING!---#####			 |")
drawAt(1,3,"+------------------------------------------------+")
drawAt(1,4,"|	  If you quit to the main menu you will	 |")
drawAt(1,5,"|	  lose all progress made in the game		|")
drawAt(1,6,"|	   ARE YOU SURE YOU WANT TO QUIT?		   |")
drawAt(1,7,"|												|")
drawAt(1,8,"|												|")
drawAt(1,9,"|												|")
drawAt(1,10,"+------------------------------------------------+")
for i = 1, #warningOptions do
		drawAt(20,i + 6,"*")
		drawAt(22,i + 6,warningOptions[i])
  end
  drawCursor(19,21,2 + menuStat)
end

----------------------------------------------
--Warning Menu events
function wMenuEvents()
event, p1 = os.pullEvent()
if event == "key" then
if p1 == 200
then
menuStat = menuStat - 1
if menuStat < 5 then
menuStat = 6
end
elseif p1 == 208 then
		 menuStat = menuStat + 1
		 if menuStat > 6 then
		   menuStat = 5
	 end
	 elseif p1 == 28 then
	 if menuStat == 5 then
	 resetStats()
	 menu()
	 elseif menuStat == 6 then
	 solo()
	 end
	 end
	 end
	 end


--Enter Your Name
function enterName()
cleanScreen()
drawAt(1,2,"+-------------------------+")
drawAt(1,4,"+-------------------------+")
term.setCursorPos(1,3)
write("|ENTER NAME:")
myName = read()
end		  
--Warning Menu
function warningMenu()
menuStat = 5
while true do
drawWarningMenu()
wMenuEvents()
end
end

--Solo Menu
function solo()
menuStat = 2
while true do
drawHomeMenu()
hMenuEvents()
end
end

--Main Menu
function menu()
  menuStat = 2
  while true do
		drawMenu()
		menuEvents()
  end
end
--Main Function
function main()
menu()
end
--Starts
main()


I know the code is a bit of a mess.
Please Help me and tell me what I'm doing wrong
TheOddByte #2
Posted 09 December 2012 - 06:41 AM
Wow, It did not look like that in notepad!
dissy #3
Posted 09 December 2012 - 06:49 AM
I can't tell for sure which line is 377 in your paste, but I believe it is this one:
drawAt(10,9,enemy.." Won")

That is the second line in the function checkMatch() and "enemy" is not defined within the function or as a global, thus is null.
You'll need to make sure the varaible exists, and that it has a string in it.
TheOddByte #4
Posted 09 December 2012 - 06:57 AM
This is line 377 in notepad:

print(myName.." did "..d.." damage")
billysback #5
Posted 09 December 2012 - 07:03 AM
are you sure both myName and d are initialized and are not nil
(try printing myname and d in two seperate prints to see what they equal to at the time, if nothing is coming up then that value is nil, then look through your code to see why)
TheOddByte #6
Posted 09 December 2012 - 08:45 AM
​Wait.. How do you initialize 'em?
Never Mind I've fixed that, But now I've got a new problem that if I play a quickmatch It works fine the
first time but when I try to play it again it says: Boxer:338: attempt to call string

CODE:

--Boxer
--Made By Hellkid98
--General
local var = 0
local hp = 100 --Player Health
local sta = 50 -- Stamina
local totalXp = 100
local xp = 0
local myScore = 0
local money = 0
local wins = 0
local loss = 0
local day = 1
local regainHP = math.random(25,50)
local regainSTA = math.random(25,50)
local lvl = 1
local enemyLvl = 1
local enemySta = 50
local enemyHP = 100
d = damage1
a = agility1
s = speed1
dfc = defence1
eAtk = enemyDMG1
--Skills
local damage1 = math.random(5,10)
local damage2 = math.random(5,20)
local damage3 = math.random(5,30)
local damage4 = math.random(5,40)
local damage5 = math.random(5,50)
local agility1 = math.random(5,10)
local agility2 = math.random(10,20)
local agility3 = math.random(20,30)
local agility4 = math.random(30,40)
local agility5 = math.random(40,50)

--Enemies
local enemyHP1 = 100 -- Enemies Health
local enemyHP2 = 125
local enemyHP3 = 150
local enemyHP4 = 175
local enemyHP5 = 200
local enemyDMG1 = math.random(2,8) --Enemies Damage. NOTE:If they are Higher Level they get better damage
local enemyDMG2 = math.random(10,15) --For example: if enemy level = 2 then eAtk = enemyDMG2
local enemyDMG3 = math.random(20,30)
local enemyDMG4 = math.random(30,45)
local enemyDMG5 = math.random(50,60)
--Randomly Selects An Enemy PS. This Is For Solo Play
function randomChallenger()
var = math.random(1,20)
if var ==1 then
enemy = "Rock Hardwood"
elseif var ==2 then
enemy = "Olov Reynkon"
elseif var ==3 then
enemy = "Usumo Binlayden"
elseif var ==4 then
enemy = "Duke Parker"
elseif var ==5 then
enemy = "Peter Pestrami"
elseif var ==6 then
enemy = "Lucky Mook"
elseif var ==7 then
enemy = "Gouda Croissant"
elseif var ==8 then
enemy = "John Dorkian"
elseif var ==9 then
enemy = "Rochy Ballboda"
elseif var ==10 then
enemy = "Felix Mjellberg"
elseif var ==11 then
enemy = "Turk Turkleton"
elseif var ==12 then
enemy = "Rock Hardwood"
elseif var ==13 then
enemy = "Rock Hardwood"
elseif var ==14 then
enemy = "Rock Hardwood"
elseif var ==15 then
enemy = "Rock Hardwood"
elseif var ==16 then
enemy = "Rock Hardwood"
elseif var ==17 then
enemy = "Rock Hardwood"
elseif var ==18 then
enemy = "Rock Hardwood"
elseif var ==19 then
enemy = "Rock Hardwood"
elseif var ==20 then
enemy = "Rock Hardwood"
print(enemy)
cleanScreen()
end
end

os.pullEvent = os.pullEventRaw
function drawAt(x,y,text)
term.setCursorPos(x,y)
term.write(text)
end
function cleanScreen()
term.clear()
term.setCursorPos(1,1)
end
--Draw Cursor
function drawCursor(x1,x2,y)
  drawAt(x1,y,"[")
  drawAt(x2,y,"]")
end
--Resets Everything
function resetStats()
hp = 100
sta = 50
myScore = 0
money = 0
wins = 0
loss = 0
day = 1
end

--Credits
function credits()
cleanScreen()  
drawAt(1,1,"+----------------------------------------+")
drawAt(1,2,"|			  CREDITS				   |")
drawAt(1,3,"|----------------------------------------|")
drawAt(1,4,"|									    |")
drawAt(1,5,"|  CODED BY: Hellkid98				   |")
drawAt(1,6,"|  BETA TESTERS:						 |")
drawAt(1,7,"|									    |")
drawAt(1,8,"|									    |")
drawAt(1,9,"|									    |")
drawAt(1,10,"|									    |")
drawAt(1,11,"|									    |")
drawAt(1,12,"+----------------------------------------+")
drawAt(1,13,"")
drawAt(1,14," PRESS [ENTER] TO EXIT")
event, p1 = os.pullEvent()
	    if event == "key" then
		  if p1 == 28 then
    return
end
end
end	


local warningOptions = {
"Yes", "No"
}
local menuOptions =
{
  "Solo",  "Multiplayer",  "Settings",  "Highscore",  "Help",  "Credits",  "Exit"
}

local hMenuOptions =
{
"Tournament", "Quick Match", "Relax", "Open Map", "Exit To Main Menu"
}


--Draws the Gameplay
function drawMatchArt()
drawAt(11,9,"ACTION:")
end
--Draw The players and The Enemies Grid PS. This Is for solo Play
function drawGrids()
drawAt(1,1,"|======| "..myName.."   ")
drawAt(1,2,"| O ..O| HP:"..hp.."    ")
drawAt(1,3,"|  _   | STA:"..sta.."  ")
drawAt(1,4,"|	  | LVL:"..lvl.."  ")
drawAt(1,5,"|------+			    ")
drawAt(28,1,"|======| "..enemy.."   ")
drawAt(28,2,"|O ..O | HP:"..enemyHP.."    ")
drawAt(28,3,"|   _  | STA:"..enemySta.."  ")
drawAt(28,4,"|	  | LVL:"..enemyLvl.."  ")
drawAt(28,5,"|------+			    ")
end


--Draws The Main Menu
function drawMenu()
  cleanScreen()
  drawAt(1,1,"+------------------------------------------------+")
  drawAt(1,2,"|		    Boxer Tournament V 0.1			  |")
  drawAt(1,3,"+------------------------------------------------+")
  drawAt(1,4,"|											    |")
  drawAt(1,5,"|											    |")
  drawAt(1,6,"|											    |")
  drawAt(1,7,"|											    |")
  drawAt(1,8,"|											    |")
  drawAt(1,9,"|											    |")
  drawAt(1,10,"|											    |")
  drawAt(1,11,"|											    |")
  drawAt(1,12,"|											    |")
  drawAt(1,13,"|											    |")
  drawAt(1,14,"|											    |")
  drawAt(1,15,"|											    |")
  drawAt(1,16,"|											    |")
  drawAt(1,17,"|											    |")
  drawAt(1,18,"+------------------------------------------------+")
  for i = 1, #menuOptions do
	    drawAt(3,i + 3,"*")
	    drawAt(5,i + 3,menuOptions[i])
  end
  drawCursor(2,4,2 + menuStat)
end

--Highscore	
function highScore()
cleanScreen()   
print("+------------------------------------------------+")
print("|			  +--Highscore--+				   |")
print("|------------------------------------------------|")	
print("| 1. James Bond  Score: 1337				  |")							 
print("| 1. James Bond  Score: 1337				  |")   
print("| 1. James Bond  Score: 1337				  |")	
print("| 1. James Bond  Score: 1337				  |")	
print("| 1. James Bond  Score: 1337				  |")	
print("| 1. James Bond  Score: 1337				  |")	
print("| 1. James Bond  Score: 1337				  |")	
print("| 1. James Bond  Score: 1337				  |")
print("| 1. James Bond  Score: 1337				  |")
print("| 1. James Bond  Score: 1337				  |")
print("+------------------------------------------------+")
print("")
print(" PRESS [ENTER] TO EXIT")
event, p1 = os.pullEvent()
	    if event == "key" then
		  if p1 == 28 then
return
end
end
end

--Main Menu Events
function menuEvents()
event, p1 = os.pullEvent()
if event == "key" then
if p1 == 200
then
menuStat = menuStat - 1
if menuStat < 2 then
menuStat = 8
end
elseif p1 == 208 then
		 menuStat = menuStat + 1
		 if menuStat > 8 then
		   menuStat = 2
	 end
	 elseif p1 == 28 then
		   if menuStat == 2 then
	 enterName()
	 solo()
	 elseif menuStat == 3 then
	 cleanScreen()
	 print("Multiplayer Not Available Yet")
	 sleep(2)
	 menu()
	 elseif menuStat == 4 then
	 cleanScreen()
	 print("Settings Not Available Yet")
	 sleep(2)
	 menu()
	 elseif menuStat == 5 then
	 highScore()
	 elseif menuStat == 6 then
	 cleanScreen()
	 print("Help Not Available Yet")
	 sleep(2)
	 menu()
	 elseif menuStat == 7 then
	 credits()
	 elseif menuStat == 8 then
	 os.reboot()
	 menu()
	 end
	 end
	 end
	 end
	
	
-----------------------------------------
--HomeMenu Events
function hMenuEvents()
event, p1 = os.pullEvent()
if event == "key" then
if p1 == 200
then
menuStat = menuStat - 1
if menuStat < 2 then
menuStat = 6
end
elseif p1 == 208 then
		 menuStat = menuStat + 1
		 if menuStat > 6 then
		   menuStat = 2
	 end
	 elseif p1 == 28 then
	 if menuStat == 2 then
	 startTournament()
		   elseif menuStat == 3 then
	 randomChallenger()
	 fight()
	 elseif menuStat == 4 then
	 relax()
	 elseif menuStat == 5 then
	 openMap()
	 elseif menuStat == 6 then
	 warningMenu()
	 end
	 end
	 end
	 end
	
	
--------------------------------
--Tournament
function startTournament()
cleanScreen()
print("Nothing Available")
sleep(1)
return
end
--Quick Match
function fight()
cleanScreen()
matchPlaying = true
repeat
checkStatus()
checkMatch()
drawGrids()
drawMatchArt()
if matchPlaying == false
then
solo()
end
fight = string.lower(read())
if fight == "Punch" or fight == "punch"
then
drawGrids()
drawMatchArt()
print("")
print(myName.." did "..d.." damage")
print(enemy.." did "..eAtk.." damage")
enemyHP = enemyHP - d
hp = hp - eAtk
sleep(2)
cleanScreen()
if hp < 1 then hp = 0
if enemyHP < 1 then enemyHP = 0
sleep(2)
end
end
elseif fight == "Block" or fight == "block" then
block = math.random(1,2)
if block == 1
then
print(enemy.." Blocked Successfully")
sleep(2)
cleanScreen()
elseif block == 2 then
print(enemy.." Blocked Unsuccessfully")
hp = hp - eAtk
sleep(2)
cleanScreen()
if hp < 1 then hp = 0
if enemyHP < 1 then enemyHP = 0
end
end
else
term.setCursorPos(10,9)
print("Unknown Action")
cleanScreen()
end
end
until matchPlaying == false
end
--Checks If someone Has Won
function checkMatch()
myName = myName
d = damage1
enemy = enemy
eAtk = enemyDMG1
if hp == 0 then
cleanScreen()
drawAt(10,9,enemy.." Won")
loss = loss + 1
sleep(2)
matchPlaying = false
elseif enemyHP == 0
then
cleanScreen()
xp = xp + 50
drawAt(10,9,myName.." Won")
drawAt(11,10,xp.." Xp Earned")
wins = wins + 1
sleep(2)
matchPlaying = false
if sta == 0 then
drawAt(10,9,enemy.." Won")
loss = loss + 1
sleep(2)
matchPlaying = false
elseif enemySta == 0
then
drawAt(10,9,myName.." Won")
wins = wins + 1
sleep(2)
matchPlaying = false
end
end
end

--Checks Status of HP/STA
function checkStatus()
if hp < 1 then hp = 0
end
if enemyHP < 1 then enemyHP = 0
end
end

function checkXp()
if xp == totalXp then
lvl = lvl + 1
totalXp = totalXp + 50
end
end

--Relax
function relax()
sta = sta + regainSTA
hp = hp + regainHP	
day = day + 1	
cleanScreen()
drawAt(6,6,"Played "..day.." days")
sleep(2)
solo()
end
--Opens the Map
function openMap()
cleanScreen()
print("Nothing Available YET")
sleep(1)
return
end   
	
	 --Draws the Home Menu
function drawHomeMenu()
  cleanScreen()
  drawAt(1,1,"+-------------------------+----------------------+")
  drawAt(1,2,"|		 HOME		    |======+ "..myName.."   ")
  drawAt(1,3,"|-------------------------| O ..O| HP:"..hp.."    ")
  drawAt(1,4,"|						 |  _   | STA:"..sta.."  ")
  drawAt(1,5,"|						 |	  | LVL:"..lvl.."  ")
  drawAt(1,6,"|						 |------+ XP:"..xp.."/"..totalXp)
  drawAt(1,7,"|						 | MONEY:"..money.."$    ")
  drawAt(1,8,"|						 | WINS:"..wins.."	   ")
  drawAt(1,9,"|						 | LOSSES:"..loss.."	  ")
  drawAt(1,10,"|						 | SCORE:"..myScore.."   ")
  drawAt(1,11,"+-------------------------+----------------------+")
 
 
  for i = 1, #hMenuOptions do
	    drawAt(4,i + 3,"*")
	    drawAt(6,i + 3,hMenuOptions[i])
  end
  drawCursor(3,5,2 + menuStat)
end
	
	
	
----------------------------------------------
--Draws Warning Menu
function drawWarningMenu()
cleanScreen()
drawAt(1,1,"+------------------------------------------------+")
drawAt(1,2,"|		  #####---!WARNING!---#####			 |")
drawAt(1,3,"+------------------------------------------------+")
drawAt(1,4,"|	  If you quit to the main menu you will	 |")
drawAt(1,5,"|	  lose all progress made in the game	    |")
drawAt(1,6,"|	   ARE YOU SURE YOU WANT TO QUIT?		   |")
drawAt(1,7,"|											    |")
drawAt(1,8,"|											    |")
drawAt(1,9,"|											    |")
drawAt(1,10,"+------------------------------------------------+")
for i = 1, #warningOptions do
	    drawAt(20,i + 6,"*")
	    drawAt(22,i + 6,warningOptions[i])
  end
  drawCursor(19,21,2 + menuStat)
end

----------------------------------------------
--Warning Menu events
function wMenuEvents()
event, p1 = os.pullEvent()
if event == "key" then
if p1 == 200
then
menuStat = menuStat - 1
if menuStat < 5 then
menuStat = 6
end
elseif p1 == 208 then
		 menuStat = menuStat + 1
		 if menuStat > 6 then
		   menuStat = 5
	 end
	 elseif p1 == 28 then
	 if menuStat == 5 then
	 resetStats()
	 menu()
	 elseif menuStat == 6 then
	 solo()
	 end
	 end
	 end
	 end


--Enter Your Name
function enterName()
while true do
drawNameMenu()
term.setCursorPos(1,3)
write("|ENTER NAME:")
myName = read()
solo() 
end		  
end

--Draws the Name menu
function drawNameMenu()
cleanScreen()
drawAt(1,2,"+-------------------------+")
drawAt(27,3,"|")
drawAt(1,4,"+-------------------------+")
end

--Warning Menu
function warningMenu()
menuStat = 5
while true do
drawWarningMenu()
wMenuEvents()
end
end

--Solo Menu
function solo()
menuStat = 2
while true do
checkXp()
drawHomeMenu()
hMenuEvents()
end
end

--Main Menu
function menu()
  menuStat = 2
  while true do
  checkXp()
	    drawMenu()
	    menuEvents()
  end
end
--Main Function
function main()
menu()
end
--Starts
main()


Here is The Part Of The Error:

--HomeMenu Events
function hMenuEvents()
event, p1 = os.pullEvent()
if event == "key" then
if p1 == 200
then
menuStat = menuStat - 1
if menuStat < 2 then
menuStat = 6
end
elseif p1 == 208 then
		 menuStat = menuStat + 1
		 if menuStat > 6 then
		   menuStat = 2
	 end
	 elseif p1 == 28 then
	 if menuStat == 2 then
	 startTournament()
		   elseif menuStat == 3 then
	 randomChallenger()
	 fight() -- Line 338
	 elseif menuStat == 4 then
	 relax()
	 elseif menuStat == 5 then
	 openMap()
	 elseif menuStat == 6 then
	 warningMenu()
	 end
	 end
	 end
	 end
	
billysback #7
Posted 09 December 2012 - 12:16 PM

myName = "billy"
TheOddByte #8
Posted 10 December 2012 - 09:16 AM
Here is the pastebin Link so anyone can test It and see What Im doing Wrong!
http://pastebin.com/NZXn0f8t
Or just type: pastebin get NZXn0f8t <Whatever You Wanna call It>
on your computer in CC
And Im wondering if anyone can come up with names for enemies
because I got completly stuck with coming up with names.
Anyone that wants their name as the name of an enemy?