Posted 08 July 2012 - 08:34 PM
I just programed a BlackJack game, but it dont gives an output and i can't find the reason, thx for your help
cya DMKxD
playerscore1 = 0
playerscore2 = 0
player1scores = {}
player2scores = {}
player1cards = {}
player2cards = {}
weiter = false
endeplayer1 = false
endeplayer2 = false
random = 0
weristdran = 1
zahltimer = 1
test = ""
running = false
go = true
stop = false
player1verloren = false
player2verloren = false
function dummy1(a)
if player1cards[0] == nil then
player1cards[0] = a
elseif player1cards[1] == nil then
player1cards[1] = a
elseif player1cards[2] == nil then
player1cards[2] = a
elseif player1cards[3] == nil then
player1cards[3] = a
elseif player1cards[4] == nil then
player1cards[4] = a
elseif player1cards[5] == nil then
player1cards[5] = a
elseif player1cards[6] == nil then
player1cards[6] = a
elseif player1cards[7] == nil then
player1cards[7] = a
end
end
function dummy2(:)/>/>
if player2cards[0] == nil then
player2cards[0] = b
elseif player2cards[1] == nil then
player2cards[1] = b
elseif player2cards[2] == nil then
player2cards[2] = b
elseif player2cards[3] == nil then
player2cards[3] = b
elseif player2cards[4] == nil then
player2cards[4] = b
elseif player2cards[5] == nil then
player2cards[5] = b
elseif player2cards[6] == nil then
player2cards[6] = b
elseif player2cards[7] == nil then
player2cards[7] = b
end
end
function scores1(c)
if player1scores[0] == nil then
player1scores[0] = c
elseif player1scores[1] == nil then
player1scores[1] = c
elseif player1scores[2] == nil then
player1scores[2] = c
elseif player1scores[3] == nil then
player1scores[3] = c
elseif player1scores[4] == nil then
player1scores[4] = c
elseif player1scores[5] == nil then
player1scores[5] = c
elseif player1scores[6] == nil then
player1scores[6] = c
elseif player1scores[7] == nil then
player1scores[7] = c
end
playerscore1 = player1scores[1] + player1scores[2] + player1scores[3] + player1scores[4] + player1scores[5] + player1scores[6] + player1scores[7]
end
function scores2(d)
if player2scores[0] == nil then
player2scores[0] = d
elseif player2scores[1] == nil then
player2scores[1] = d
elseif player2scores[2] == nil then
player2scores[2] = d
elseif player2scores[3] == nil then
player2scores[3] = d
elseif player2scores[4] == nil then
player2scores[4] = d
elseif player2scores[5] == nil then
player2scores[5] = d
elseif player2scores[6] == nil then
player2scores[6] = d
elseif player2scores[7] == nil then
player2scores[7] = d
end
playerscore2 = player2scores[1] + player2scores[2] + player2scores[3] + player2scores[4] + player2scores[5] + player2scores[6] + player2scores[7]
end
function kartenziehen1()
random = math.random(56) + 1
if random >= 1 and random <= 4 then
dummy1(2)
scores1(2)
elseif random >= 5 and random <= 8 then
dummy1(3)
scores1(3)
elseif random >= 9 and random <= 12 then
dummy1(4)
scores1(4)
elseif random >= 13 and random <= 16 then
dummy1(5)
scores1(5)
elseif random >= 17 and random <= 20 then
dummy1(6)
scores1(6)
elseif random >= 21 and random <= 24 then
dummy1(7)
scores1(7)
elseif random >= 25 and random <= 28 then
dummy1(8)
scores1(8)
elseif random >= 29 and random <= 32 then
dummy1(9)
scores1(9)
elseif random >= 33 and random <= 36 then
dummy1(10)
scores1(10)
elseif random >= 37 and random <= 40 then
dummy1(B)/>/>
scores1(10)
elseif random >= 41 and random <= 44 then
dummy1(D)
scores1(10)
elseif random >= 45 and random <= 48 then
dummy1(K)
scores1(10)
elseif random >= 49 and random <= 52 then
dummy1(J)
scores1(10)
elseif random >= 53 and random <= 56 then
dummy1(A)
scores1(11)
end
end
function kartenziehen2()
sleep(2)
random = math.random(56) + 1
if random >= 1 and random <= 4 then
dummy1(2)
scores1(2)
elseif random >= 5 and random <= 8 then
dummy1(3)
scores1(3)
elseif random >= 9 and random <= 12 then
dummy1(4)
scores1(4)
elseif random >= 13 and random <= 16 then
dummy1(5)
scores1(5)
elseif random >= 17 and random <= 20 then
dummy1(6)
scores1(6)
elseif random >= 21 and random <= 24 then
dummy1(7)
scores1(7)
elseif random >= 25 and random <= 28 then
dummy1(8)
scores1(8)
elseif random >= 29 and random <= 32 then
dummy1(9)
scores1(9)
elseif random >= 33 and random <= 36 then
dummy1(10)
scores1(10)
elseif random >= 37 and random <= 40 then
dummy1(B)/>/>
scores1(10)
elseif random >= 41 and random <= 44 then
dummy1(D)
scores1(10)
elseif random >= 45 and random <= 48 then
dummy1(K)
scores1(10)
elseif random >= 49 and random <= 52 then
dummy1(J)
scores1(10)
elseif random >= 53 and random <= 56 then
dummy1(A)
scores1(11)
end
end
function Wechseln()
while weiter == true or weiter == false do
if go == true then
go = false
stop = true
break end
if go == false then
go = true
stop = false
break end
end
end
function yesno()
repeat
local e, key = os.pullEvent( "key" )
if key == 203 or key == 205 then
Wechseln()
term.clearLine()
end
if go == true then
print("Go")
elseif stop == true then
print("Stop")
end
until key == 28
function scoreboard()
print("BlackJack v1.0 by DMKxD")
print("*********************************")
print("Player Bot")
print(player1cards[0].. " " ..player2cards[0])
print(player1cards[1].. " " ..player2cards[1])
print(player1cards[2].. " " ..player2cards[2])
print(player1cards[3].. " " ..player2cards[3])
print(player1cards[4].. " " ..player2cards[4])
print(player1cards[5].. " " ..player2cards[5])
print(player1cards[6].. " " ..player2cards[6])
print(player1cards[7].. " " ..player2cards[7])
print("")
print("Score Player: " ..playerscore1.." Score Bank: " ..playerscore2)
end
repeat
shell.run("clear")
kartenziehen1()
scoreboard()
write("Continue?")
yesno()
if stop == true then
if playerscore1 > 21 then
print("You loose...")
sleep(3)
shell.run("reboot")
else
print("Your score is saved, now let's see if you could beat the bank!")
weristdran = 2
end
end
until weristdran == 2
repeat
shell.run("clear")
kartenziehen2()
scoreboard()
if playerscore2 > 16 then
if playerscore2 > 21 then
player2verloren = true
end
weristdran = 3
end
until weristran == 3
repeat
if playerscore1 > playerscore2 then
print("You won!")
elseif playerscore1 == playerscore2 then
print("Draw!")
end
sleep(4)
shell.run("reboot")
until weristdran == 4
end
cya DMKxD