Ok so I thought I would give make a simple text battle thing a try. But when I try to run what I wrote it keeps saying " Could not close next at line 305" 305 is the last line BTW. This is what I have written. I based it on this Code Snippet called Text Battle RPG or something in the Code Snippet forum.
-----------------------------------------
Rem Project: Text Game
Rem Created: 7/16/2010 12:37:38 AM
Rem ***** Main Source File *****
set text font "Ariel"
set text size 15
fighting: ` make the main program first
EnStr$ = "Your enemy's health is "
Ehealth = rnd(200)+350
Gosub Weapons
Gosub Enemy
Gosub Armor
Do
CLS ` so there arent lots of these words below clogging up memory and space
Print "The Enemy is "+Enemy$
Print "You are equiped with a "+Weapon$
Print "Your armor set is "+Armor$
Print EnStr$ + str$(Ehealth)
Print "Your health is "+str$(Yhealth)
Print "The enemy's health is "+str$(Ehealth)
Print Attack$
Print EAttack$
Print "Press A to do a charge and attack.Press B to do a block with your shield and then shield slam."
Do
Gosub EAttack
If Def = 1 then EDefence = 1
If keystate(30) = 1
gosub Charge
Endif
If keystate(48) = 1
EDefence = 0
gosub Shield
endif
Loop
loop
Weapons:
WeaponSR = rnd(5)+1 ` randomize for the results
DIM Weapons#(6)
If WeaponSR = 1 `makin the weapons
Weapon$ ="Axe"
ENdif
If WeaponSR = 2
Weapon$= "Gladius"
Endif
If WeaponSR = 3
Weapon$= "Spear"
Endif
If WeaponSR = 4
Weapon$= "Inflatable Duck"
Endif
If WeaponSR = 5
Weapon$= "Shoop Da WHOOP"
Endif
If WeaponSR = 6
Weapon$= "Chainsaw"
Endif
Return
Enemy:
EnemySR = rnd(5)+1
DIM Enemys#(6)
If EnemySR = 1
Enemy$ = "a Orc"
Endif
If EnemySR = 2
Enemy$ = "a Fire-Drake"
Endif
If EnemySR = 3
Enemy$ = "an Enemy Trooper"
Endif
If EnemySR = 4
Enemy$ = "Barack Obama"
Endif
If EnemySR = 5
Enemy$ = "Some guy"
Endif
If EnemySR = 6
Enemy$ = "Paul The Octopus"
Endif
Return
Armor:
ArmorSR = rnd(5)+1
DIM Armor#(6)
If ArmorSR = 1
Armor$ = "Mithril Ring-Mail Armor"
Endif
If ArmorSR = 2
Armor$ = "Steel Plate Armor"
Endif
If ArmorSR = 3
Armor$ = "Titanium Plate Armor"
Endif
If ArmorSR = 4
Armor$ = "Titanium Ring-Mail Armor"
Endif
If ArmorSR = 5
Armor$ = "Steel Ring-Mail Armor"
Endif
If ArmorSR = 6
Armor$ = "Mithril Plate Armor"
Endif
gosub YourHealth
Return
Charge:
if Weapon = 1
Hitpos = rnd(5)
if Hitpos = 0
Attack$ = "You swing your axe but miss."
else
YDamage=rnd(110)+35
If EDefence = 1 then YDamage = YDamage/10
Attack$ = "You swing your axe and hit him for"+str$(YDamage)+" damage."
Ehealth = Ehealth - YDamage
Endif
if Weapon = 2
Hitpos = rnd(6)
if Hitpos = 0
Attack$ = "You slash your gladius but miss."
else
YDamage=rnd(90)+25
If EDefence = 1 then YDamage = YDamage/10
Attack$ = "You swing your axe and hit him for"+str$(YDamage)+" damage."
Ehealth = Ehealth - YDamage
Endif
if Weapon = 3
Hitpos = rnd(9)
if Hitpos = 0
Attack$ = "You jab your spear but miss."
else
YDamage=rnd(60)+20
If EDefence = 1 then YDamage = YDamage/10
Attack$ = "You jab your spear and hit him for"+str$(YDamage)+" damage."
Ehealth = Ehealth - YDamage
Endif
if Weapon = 1
Hitpos = rnd(40)
if Hitpos = 0
Attack$ = "You throw your Inflatable Duck but miss."
else
YDamage=rnd(40)+10
If EDefence = 1 then YDamage = YDamage/10
Attack$ = "You throw your Inflatable Duck and hit him for"+str$(YDamage)+" damage."
Ehealth = Ehealth - YDamage
Endif
if Weapon = 1
Hitpos = rnd(2)
if Hitpos = 0
Attack$ = "You shoot your Shoop Da WHOOP but miss."
else
YDamage=rnd(250)+60
If EDefence = 1 then YDamage = YDamage/10
Attack$ = "You shoot your Shoop DA WHOOP and hit him for"+str$(YDamage)+" damage."
Ehealth = Ehealth - YDamage
Endif
if Weapon = 1
Hitpos = rnd(13)
if Hitpos = 0
Attack$ = "You revup your chainsaw but miss."
else
YDamage=rnd(40)+15
If EDefence = 1 then YDamage = YDamage/10
Attack$ = "You rev up your chainsaw and hit him for"+str$(YDamage)+" damage."
Ehealth = Ehealth - YDamage
do
if Ehealth<1
cls
Print " You OWNED that scrub! Play again(Y/N)?"
If keystate(21)=1
goto fighting
endif
If keystate(49)=1
end
endif
endif
loop
return
YourHealth:
If Armor = 1
Yhealth = 500
If Armor = 2
Yhealth = 350
If Armor = 3
Yhealth = 450
If Armor = 4
Yhealth = 400
If Armor = 5
Yhealth = 300
If Armor = 6
Yhealth = 550
return
Shield:
ShieldHap = rnd(4)
if ShieldHap = 0
Block = 0
else
SAttack = rnd(5)+1
Block = 1
Ehealth = Ehealth - SAttack
Return
EAttack:
if EnemySR = 1
Ehitpos = rnd(5)
If Ehitpos = 0
EAttack$ = "The Orc slashed his sword but missed."
else
EDamage = rnd(60)+20
if Block = 1
EDamage = Edamage/10
Endif
EAttack$ = "The Orc hit you with his sword for "+str$(EAttack)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 2
Ehitpos = rnd(5)
If Ehitpos = 0
Def = 1
else
EDamage = rnd(100)+30
if Block = 1
EDamage = Edamage/10
Endif
EAttack$ = "The Fire-Drake hit for "+str$(EAttack)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 3
Ehitpos = rnd(10)
If Ehitpos = 0
EAttack$ = "The Enemy Trooper slashed his sword but missed."
else
if Block = 1
EDamage = Edamage/10
Endif
EDamage = rnd(50)+20
EAttack$ = "The Enemy Trooper hit you with his sword for "+str$(EAttack)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 1
Ehitpos = rnd(1)
If Ehitpos = 0
EAttack$ = "Barack Obama had gone into Defense Mode."
else
if Block = 1
EDamage = Edamage/10
Endif
EDamage = rnd(200)+100
EAttack$ = "Obama called the milatary and they hit you for "+str$(EAttack)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 1
Ehitpos = rnd(3)
If Ehitpos = 0
EAttack$ = "ChangBiao Luo is being stupid and missed."
else
if Block = 1
EDamage = Edamage/10
Endif
EDamage = rnd(150)+30
EAttack$ = "ChangBiao Luo yelled at you for "+str$(EAttack)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 1
Ehitpos = rnd(5)
If Ehitpos = 0
EAttack$ = "The Orc slashed his sword but missed."
else
if Block = 1
EDamage = Edamage/10
Endif
EDamage = rnd(60)+20
EAttack$ = "The Orc hit you with his sword for "+str$(EAttack)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
do
if Yhealth>1
cls
Print " Im sorry, you lost. Play again(Y/N)?"
if keystate(21) =1
gosub fighting
endif
if keystate(49) =1
end
endif
endif
loop
return
------------------------------
How do I fix this?
[MODEDIT - Well, firstly, you use code tags around your code ...]
BTW I made the changes but the I attack. I think the keystate isnt working.
Rem Project: Text Game
Rem Created: 7/16/2010 12:37:38 AM
Rem ***** Main Source File *****
set text font "Ariel"
set text size 15
fighting: ` make the main program first
EnStr$ = "Your enemy's health is "
Ehealth = rnd(200)+350
Gosub Weapons
Gosub Enemy
Gosub Armor
Do
Block = 0
CLS ` so there arent lots of these words below clogging up memory and space
Print "The Enemy is "+Enemy$
Print "You are equiped with a "+Weapon$
Print "Your armor set is "+Armor$
Print EnStr$ + str$(Ehealth)
Print "Your health is "+str$(Yhealth)
Print Attack$
Print EAttack$
Print "Press A to do a charge and attack.Press B to do a block with your shield and then shield slam."
wait key
do
If keystate(30)=1
gosub Charge
exit
Endif
If keystate(31)=1
gosub Shield
exit
endif
loop
EDefence = 0
gosub EAttack
loop
Weapons:
WeaponSR = rnd(5)+1 ` randomize for the results
DIM Weapons#(6) ` make an array(IDK why?)
If WeaponSR = 1 `makin the weapons
Weapon$ ="Axe"
ENdif
If WeaponSR = 2
Weapon$= "Gladius"
Endif
If WeaponSR = 3
Weapon$= "Spear"
Endif
If WeaponSR = 4
Weapon$= "Inflatable Duck"
Endif
If WeaponSR = 5
Weapon$= "Shoop Da WHOOP"
Endif
If WeaponSR = 6
Weapon$= "Chainsaw"
Endif
Return
Enemy:
EnemySR = rnd(5)+1
DIM Enemys#(6)
If EnemySR = 1
Enemy$ = "a Orc"
Endif
If EnemySR = 2
Enemy$ = "a Fire-Drake"
Endif
If EnemySR = 3
Enemy$ = "an Enemy Trooper"
Endif
If EnemySR = 4
Enemy$ = "Barack Obama"
Endif
If EnemySR = 5
Enemy$ = "ChangBiao Luo"
Endif
If EnemySR = 6
Enemy$ = "Paul The Octopus"
Endif
Return
Armor:
ArmorSR = rnd(5)+1
DIM Armor#(6)
If ArmorSR = 1
Armor$ = "Mithril Ring-Mail Armor"
Endif
If ArmorSR = 2
Armor$ = "Steel Plate Armor"
Endif
If ArmorSR = 3
Armor$ = "Titanium Plate Armor"
Endif
If ArmorSR = 4
Armor$ = "Titanium Ring-Mail Armor"
Endif
If ArmorSR = 5
Armor$ = "Steel Ring-Mail Armor"
Endif
If ArmorSR = 6
Armor$ = "Mithril Plate Armor"
Endif
gosub YourHealth
Return
Charge:
if Weapon = 1
Hitpos = rnd(5)
if Hitpos = 0
Attack$ = "You swing your axe but miss."
else
YDamage=rnd(110)+35
If EDefence = 1 then YDamage = YDamage/10
Attack$ = "You swing your axe and hit him for"+str$(YDamage)+" damage."
Ehealth = Ehealth - YDamage
Endif
if Weapon = 2
Hitpos = rnd(6)
if Hitpos = 0
Attack$ = "You slash your gladius but miss."
else
YDamage=rnd(90)+25
If EDefence = 1 then YDamage = YDamage/10
Attack$ = "You swing your axe and hit him for"+str$(YDamage)+" damage."
Ehealth = Ehealth - YDamage
Endif
if Weapon = 3
Hitpos = rnd(9)
if Hitpos = 0
Attack$ = "You jab your spear but miss."
else
YDamage=rnd(60)+20
If EDefence = 1 then YDamage = YDamage/10
Attack$ = "You jab your spear and hit him for"+str$(YDamage)+" damage."
Ehealth = Ehealth - YDamage
endif
endif
Endif
if Weapon = 1
Hitpos = rnd(40)
if Hitpos = 0
Attack$ = "You throw your Inflatable Duck but miss."
else
YDamage=rnd(40)+10
If EDefence = 1 then YDamage = YDamage/10
Attack$ = "You throw your Inflatable Duck and hit him for"+str$(YDamage)+" damage."
Ehealth = Ehealth - YDamage
endif
endif
Endif
if Weapon = 1
Hitpos = rnd(2)
if Hitpos = 0
Attack$ = "You shoot your Shoop Da WHOOP but miss."
else
YDamage=rnd(250)+60
If EDefence = 1 then YDamage = YDamage/10
Attack$ = "You shoot your Shoop DA WHOOP and hit him for"+str$(YDamage)+" damage."
Ehealth = Ehealth - YDamage
endif
endif
if Weapon = 1
Hitpos = rnd(13)
if Hitpos = 0
Attack$ = "You revup your chainsaw but miss."
else
YDamage=rnd(40)+15
If EDefence = 1 then YDamage = YDamage/10
Attack$ = "You rev up your chainsaw and hit him for"+str$(YDamage)+" damage."
Ehealth = Ehealth - YDamage
endif
endif
do
if Ehealth<1
cls
Print " You OWNED that scrub! Play again(Y/N)?"
If keystate(21)=1
goto fighting
endif
If keystate(49)=1
end
endif
endif
loop
return
YourHealth:
If ArmorSR = 1
Yhealth = 500
endif
If ArmorSR = 2
Yhealth = 350
endif
If ArmorSR = 3
Yhealth = 450
endif
If ArmorSR = 4
Yhealth = 400
endif
If ArmorSR = 5
Yhealth = 300
endif
If ArmorSR = 6
Yhealth = 550
endif
return
Shield:
ShieldHap = rnd(4)
if ShieldHap = 0
Block = 0
else
SAttack = rnd(5)+1
Block = 1
Ehealth = Ehealth - SAttack
endif
Return
EAttack:
if EnemySR = 1
Ehitpos = rnd(5)
If Ehitpos = 0
EAttack$ = "The Orc slashed his sword but missed."
else
EDamage = rnd(60)+20
if Block = 1
EDamage = Edamage/10
Endif
EAttack$ = "The Orc hit you with his sword for "+str$(EAttack)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 2
Ehitpos = rnd(5)
If Ehitpos = 0
EAttack$ = "The Fire-Drake blocked"
Def = 1
else
EDamage = rnd(100)+30
if Block = 1
EDamage = Edamage/10
Endif
EAttack$ = "The Fire-Drake hit for "+str$(EAttack)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 3
Ehitpos = rnd(10)
If Ehitpos = 0
EAttack$ = "The Enemy Trooper slashed his sword but missed."
else
if Block = 1
EDamage = Edamage/10
Endif
EDamage = rnd(50)+20
EAttack$ = "The Enemy Trooper hit you with his sword for "+str$(EAttack)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 1
Ehitpos = rnd(1)
If Ehitpos = 0
EAttack$ = "Barack Obama had gone into Defense Mode."
Def = 1
else
if Block = 1
EDamage = Edamage/10
Endif
EDamage = rnd(200)+100
EAttack$ = "Obama called the milatary and they hit you for "+str$(EAttack)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 1
Ehitpos = rnd(3)
If Ehitpos = 0
EAttack$ = "ChangBiao Luo is being stupid and missed."
else
if Block = 1
EDamage = Edamage/10
Endif
EDamage = rnd(150)+30
EAttack$ = "ChangBiao Luo yelled at you for "+str$(EAttack)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
if EnemySR = 1
Ehitpos = rnd(5)
If Ehitpos = 0
EAttack$ = "The Orc slashed his sword but missed."
else
if Block = 1
EDamage = Edamage/10
Endif
EDamage = rnd(60)+20
EAttack$ = "The Orc hit you with his sword for "+str$(EAttack)+" damage."
Yhealth = Yhealth - EDamage
endif
endif
do
if Yhealth<1
cls
Print " Im sorry, you lost. Play again(Y/N)?"
if keystate(21) =1
gosub fighting
endif
if keystate(49) =1
end
endif
endif
loop
return
How do I fix this?
Ok I fixed it. Thank all of you guys. There were some serious bugs in my code.