hello a tous
voila j ai une erreur a la ligne 391 avec
"attempt to index field \?/ 'a nil value)
error no script found"
----tente d'indexer un champ '?' (une valeur nulle)---
des que jutilise droite + X ou carré ou triangle j ai cette erreur
je ne comprend pas pourquoi ce genre d erreur arrive ! il me semble pas y avoir de fautes
si qq pouvait m aider svp , merci beaucoup
ligne 391
if statut_kenshiro == 3 then
screen:blit(posmx, posmy-(statut_fire[compteur_statut].h), kenshiro4, statut_fire[compteur_statut].xs, statut_fire[compteur_statut].y, statut_fire[compteur_statut].lg, statut_fire[compteur_statut].h)
compteur_statut = compteur_statut + 1
if compteur_statut > statut_fire[1].n then
compteur_statut = 1
statut_kenshiro = 2
end
end
et voici le code complet :
logomindraisers=nil
-- table des backgrounds
backgroundtable = {"Backgrounds/1.png", "Backgrounds/2.png", "Backgrounds/3.png", "Backgrounds/4.png", "Backgrounds/5.png"}
--sprites DROITE
kenshiro = Image.load("mouvements/planchestand.png") --repos
kenshiro2 = Image.load("mouvements/planche-a-terre2.png") -- a terre
kenshiro3 = Image.load("mouvements/planchemarche.png") -- marche
kenshiro4 = Image.load("mouvements/planchepied.png") -- coup de pied
kenshiro5 = Image.load("mouvements/planchesautcopie.png")-- saut
kenshiro6 = Image.load("mouvements/planchepoing1.png") -- poing
--sprites GAUCHE
kenshiro7 = Image.load("mouvements/planchestandg.png") --repos
kenshiro8 = Image.load("mouvements/planche-a-terre2g.png") -- a terre
kenshiro9 = Image.load("mouvements/planchemarcheg.png") -- marche
kenshiro10 = Image.load("mouvements/planchepiedg.png") -- coup de pied
kenshiro11 = Image.load("mouvements/planchesautcopieg.png")-- saut
kenshiro12 = Image.load("mouvements/planchepoing1g.png") -- poing
backgroundnumber = 3 -- je commence par celui du mileu
background0 = Image.load(backgroundtable[backgroundnumber+1]) -- le background de gauche
background1 = Image.load(backgroundtable[backgroundnumber]) -- le background central
background2 = Image.load(backgroundtable[backgroundnumber-1]) -- le background de droite
-- table des statuts de kenshiro DROITE
statut_standing = {}
statut_standing[1] = {xs=0, y=0, lg=95, h=140, n=5}
statut_standing[2] = {xs=96, y=0, lg=95, h=140, n=5}
statut_standing[3] = {xs=192, y=0, lg=95, h=140, n=5}
statut_standing[4] = {xs=288, y=0, lg=95, h=140, n=5}
statut_standing[5] = {xs=384, y=0, lg=95, h=140, n=5}
statut_standing[6] = {xs=0, y=136, lg=95, h=140, n=6}
statut_run = {}
statut_run[1] = {xs=0, y=0, lg=95, h=140, n=10}
statut_run[2] = {xs=96, y=0, lg=95, h=140, n=10}
statut_run[3] = {xs=192, y=0, lg=95, h=140, n=10}
statut_run[4] = {xs=288, y=0, lg=95, h=140, n=10}
statut_run[5] = {xs=384, y=0, lg=95, h=140, n=10}
statut_run[6] = {xs=0, y=136, lg=95, h=140, n=10}
statut_run[7] = {xs=96, y=136, lg=95, h=140, n=10}
statut_run[8] = {xs=192, y=136, lg=95, h=140, n=10}
statut_run[9] = {xs=288, y=136, lg=95, h=140, n=10}
statut_run[10] = {xs=384, y=136, lg=95, h=140, n=10}
statut_fire = {}
statut_fire[1] = {xs=0 , y=0, lg=150, h=140, n=5}--pied
statut_fire[2] = {xs=160 , y=0, lg=150, h=140, n=5}
statut_fire[3] = {xs=320 , y=0, lg=150, h=140, n=5}
statut_fire[4] = {xs=0, y=136, lg=150, h=140, n=5}
statut_fire[5] = {xs=160 , y=136, lg=150, h=140, n=5}
statut_jump = {}
statut_jump[1] = {xs=0, y=0, lg=95, h=140, n=5}
statut_jump[2] = {xs=96, y=10, lg=95, h=160, n=5}
statut_jump[3] = {xs=192, y=5, lg=95, h=180, n=5}
statut_jump[4] = {xs=288, y=10, lg=95, h=160, n=5}
statut_jump[5] = {xs=384, y=0, lg=95, h=140, n=5}
statut_aterre = {}
statut_aterre[1] = {xs=0, y=0, lg=95, h=140, n=4}
statut_aterre[2] = {xs=96, y=0, lg=95, h=140, n=4}
statut_aterre[3] = {xs=192, y=0, lg=95, h=140, n=4}
statut_aterre[4] = {xs=288, y=0, lg=95, h=140, n=4}
statut_coupdepoing = {}
statut_coupdepoing[1] = {xs=0, y=0, lg=95, h=140, n=6}
statut_coupdepoing[2] = {xs=96, y=0, lg=95, h=140, n=6}
statut_coupdepoing[3] = {xs=192, y=0, lg=95, h=140, n=6}
statut_coupdepoing[4] = {xs=288, y=0, lg=95, h=140, n=6}
statut_coupdepoing[5] = {xs=384, y=0, lg=95, h=140, n=6}
statut_coupdepoing[6] = {xs=0, y=136, lg=95, h=140, n=6}
-- table des statuts de kenshiro GAUCHE
statut_stand = {}
statut_stand[1] = {xs=0, y=0, lg=95, h=140, n=5}
statut_stand[2] = {xs=96, y=0, lg=95, h=140, n=5}
statut_stand[3] = {xs=192, y=0, lg=95, h=140, n=5}
statut_stand[4] = {xs=288, y=0, lg=95, h=140, n=5}
statut_stand[5] = {xs=384, y=0, lg=95, h=140, n=5}
statut_stand[6] = {xs=0, y=136, lg=95, h=140, n=6}
statut_marche = {}
statut_marche[1] = {xs=0, y=0, lg=95, h=140, n=10}
statut_marche[2] = {xs=96, y=0, lg=95, h=140, n=10}
statut_marche[3] = {xs=192, y=0, lg=95, h=140, n=10}
statut_marche[4] = {xs=288, y=0, lg=95, h=140, n=10}
statut_marche[5] = {xs=384, y=0, lg=95, h=140, n=10}
statut_marche[6] = {xs=0, y=136, lg=95, h=140, n=10}
statut_marche[7] = {xs=96, y=136, lg=95, h=140, n=10}
statut_marche[8] = {xs=192, y=136, lg=95, h=140, n=10}
statut_marche[9] = {xs=288, y=136, lg=95, h=140, n=10}
statut_marche[10] = {xs=384, y=136, lg=95, h=140, n=10}
statut_pied = {}
statut_pied[1] = {xs=0 , y=0, lg=150, h=140, n=5}--pied
statut_pied[2] = {xs=160 , y=0, lg=150, h=140, n=5}
statut_pied[3] = {xs=320 , y=0, lg=150, h=140, n=5}
statut_pied[4] = {xs=0, y=136, lg=150, h=140, n=5}
statut_pied[5] = {xs=160 , y=136, lg=150, h=140, n=5}
statut_saut = {}
statut_saut[1] = {xs=0, y=0, lg=95, h=140, n=5}
statut_saut[2] = {xs=96, y=10, lg=95, h=160, n=5}
statut_saut[3] = {xs=192, y=5, lg=95, h=180, n=5}
statut_saut[4] = {xs=288, y=10, lg=95, h=160, n=5}
statut_saut[5] = {xs=384, y=0, lg=95, h=140, n=5}
statut_aterregauche = {}
statut_aterregauche[1] = {xs=0, y=0, lg=95, h=140, n=4}
statut_aterregauche[2] = {xs=96, y=0, lg=95, h=140, n=4}
statut_aterregauche[3] = {xs=192, y=0, lg=95, h=140, n=4}
statut_aterregauche[4] = {xs=288, y=0, lg=95, h=140, n=4}
statut_coupdepoinggauche = {}
statut_coupdepoinggauche[1] = {xs=0, y=0, lg=95, h=140, n=6}
statut_coupdepoinggauche[2] = {xs=96, y=0, lg=95, h=140, n=6}
statut_coupdepoinggauche[3] = {xs=192, y=0, lg=95, h=140, n=6}
statut_coupdepoinggauche[4] = {xs=288, y=0, lg=95, h=140, n=6}
statut_coupdepoinggauche[5] = {xs=384, y=0, lg=95, h=140, n=6}
statut_coupdepoinggauche[6] = {xs=0, y=136, lg=95, h=140, n=6}
statut_kenshiro = 1 -- 1=repos 2=cours 3=frappe 4=saut 5=a terre
compteur_statut = 1
--statut_kenshiro2 = 7
--compteur_statut2 = 1
Music.playFile("musiques/1.it", false)
Music.playFile("musiques/2.it", false)
Music.playFile("musiques/3.it", false)
Music.playFile("musiques/4.it", true)
tatata = Sound.load("musiques/coup de poing.wav")
coupdepied = Sound.load("musiques/coup de pied.wav")
--position de depart
posmx = 150
posmy = 255
x = 0
y = 0
--boucle
while true do
screen:clear()
pad = Controls.read()
minuteur = Timer.new()
--- minuteur pour gerer la vitesse de l'animation---
currentTime = 0 minuteur:start()
while currentTime < 80 do
currentTime = minuteur:time()
end
minuteur:stop()
if pad:left() then
statut = "left"
x = x+10
if posmx>10 then
posmx=posmx-1
end end
if pad:right() then
statut = "right"
x = x-10
if posmx<1000 then
posmx=posmx+1
end end
if pad:down() then
statut = "down"
y = y-20
if posmy>10 then
posmy=posmy+1
end end
if pad:up() then
statut = "up"
y = y+20
if posmy<300 then
posmy=posmy-1
end end
----marche droite--------------------------------------------
if pad:right() and statut_kenshiro==1 then
statut_kenshiro = 2
end
----marche gauche-----
if pad:left() and statut_kenshiro==1 then
statut_kenshiro = 8
end
----marche droite + carré (coup de pieds)----------------------
if pad:right() then
if pad:square() and statut_kenshiro==2 then
local sound =coupdepied
voice = sound:play()
statut_kenshiro = 3
end
end
----pieds droite----
if pad:square() and statut_kenshiro==1 then
local sound =coupdepied
voice = sound:play()
statut_kenshiro = 3
end
----marche gauche + carré (coup de pieds)----------------------
if pad:left() then
if pad:square() and statut_kenshiro==8 then
local sound =coupdepied
voice = sound:play()
statut_kenshiro = 9
end
end
----pieds gauche----
if pad:square() and statut_kenshiro==7 then
local sound =coupdepied
voice = sound:play()
statut_kenshiro = 9
end
----marche droite + X(poings)-------------------------------------
if pad:right() then
if pad:cross() and statut_kenshiro==2 then
local sound = tatata
voice = sound:play()
statut_kenshiro = 6
end
end
----poings droite-----
if pad:cross() and statut_kenshiro==1 then
local sound = tatata
voice = sound:play()
statut_kenshiro = 6
end
----marche gauche + X(poings)-------------------------------------
if pad:left() then
if pad:cross() and statut_kenshiro==8 then
local sound = tatata
voice = sound:play()
statut_kenshiro = 12
end
end
----poing gauche----
if pad:cross() and statut_kenshiro==7 then
local sound = tatata
voice = sound:play()
statut_kenshiro = 12
end
----saut droite + triangle (saut)-----------------------------------
if pad:right() then
if pad:triangle() and statut_kenshiro==2 then
statut_kenshiro = 4
end
end
----saut droite-----
if pad:triangle() and statut_kenshiro==1 then
statut_kenshiro = 4
end
----saut gauche + triangle (saut)------------------------------------
if pad:left() then
if pad:triangle() and statut_kenshiro==8 then
statut_kenshiro = 10
end
end
----saut gauche----
if pad:triangle() and statut_kenshiro==7 then
statut_kenshiro = 10
end
----droite + carré (a terre)--------------------------------------------------
if pad:right() then
if pad:square() and statut_kenshiro==2 then
statut_kenshiro = 5
end
end
----a terre droite-----
if pad:circle() and statut_kenshiro==1 then
statut_kenshiro = 5
end
----gauche + carré (a terre)--------------------------------------------------
if pad:left() then
if pad:square() and statut_kenshiro==8 then
statut_kenshiro = 11
end
end
----a terre gauche------
if pad:circle() and statut_kenshiro==7 then
statut_kenshiro = 11
end
if pad:start() then
os.exit()
end
screen:blit(x, 0, background1)
screen:blit(x+480, 0, background0)
screen:blit(x-480, 0, background2)
if x == 480 then -- arrivé a la limite a gauche
x = 0
backgroundnumber = backgroundnumber - 1 -- on change de background
if backgroundnumber == 0 then -- et on redefini les backgrounds a afficher
backgroundnumber = 5
end
background1 = Image.load(backgroundtable[backgroundnumber])
if backgroundnumber == 1 then
background2 = Image.load(backgroundtable[5])
else
background2 = Image.load(backgroundtable[backgroundnumber-1])
end
if backgroundnumber == 5 then
background0 = Image.load(backgroundtable[1])
else
background0 = Image.load(backgroundtable[backgroundnumber+1])
end
end
if x == -480 then -- pareil que le block au dessus mais a droite
x = 0
backgroundnumber = backgroundnumber + 1
if backgroundnumber == 6 then -- on defini les backgrounds a afficher
backgroundnumber = 1
end
background1 = Image.load(backgroundtable[backgroundnumber])
if backgroundnumber == 1 then
background2 = Image.load(backgroundtable[5])
else
background2 = Image.load(backgroundtable[backgroundnumber-1])
end
if backgroundnumber == 5 then
background0= Image.load(backgroundtable[1])
else
background0 = Image.load(backgroundtable[backgroundnumber+1])
end
end
------------------------DROITE---------------------------------------------
if statut_kenshiro == 1 then
screen:blit(posmx, posmy-(statut_standing[compteur_statut].h), kenshiro, statut_standing[compteur_statut].xs, statut_standing[compteur_statut].y, statut_standing[compteur_statut].lg, statut_standing[compteur_statut].h)
compteur_statut = compteur_statut + 1
if compteur_statut > statut_standing[1].n then
compteur_statut = 1
end
end
if statut_kenshiro == 2 then
screen:blit(posmx, posmy-(statut_run[compteur_statut].h), kenshiro3, statut_run[compteur_statut].xs, statut_run[compteur_statut].y, statut_run[compteur_statut].lg, statut_run[compteur_statut].h)
compteur_statut = compteur_statut + 1
if compteur_statut > statut_run[1].n then
compteur_statut = 1
statut_kenshiro = 0
end
end
if statut_kenshiro == 3 then
screen:blit(posmx, posmy-(statut_fire[compteur_statut].h), kenshiro4, statut_fire[compteur_statut].xs, statut_fire[compteur_statut].y, statut_fire[compteur_statut].lg, statut_fire[compteur_statut].h)
compteur_statut = compteur_statut + 1
if compteur_statut > statut_fire[1].n then
compteur_statut = 1
statut_kenshiro = 2
end
end
if statut_kenshiro == 4 then
screen:blit(posmx, posmy-(statut_jump[compteur_statut].h), kenshiro5, statut_jump[compteur_statut].xs, statut_jump[compteur_statut].y, statut_jump[compteur_statut].lg, statut_jump[compteur_statut].h)
compteur_statut = compteur_statut + 1
if compteur_statut > statut_jump[1].n then
compteur_statut = 1
statut_kenshiro = 2
end
end
if statut_kenshiro == 5 then
screen:blit(posmx, posmy-(statut_aterre[compteur_statut].h), kenshiro2, statut_aterre[compteur_statut].xs, statut_aterre[compteur_statut].y, statut_aterre[compteur_statut].lg, statut_aterre[compteur_statut].h)
compteur_statut = compteur_statut + 1
if compteur_statut > statut_aterre[1].n then
compteur_statut = 1
statut_kenshiro = 0
end
end
if statut_kenshiro == 6 then
screen:blit(posmx, posmy-(statut_coupdepoing[compteur_statut].h), kenshiro6, statut_coupdepoing[compteur_statut].xs, statut_coupdepoing[compteur_statut].y, statut_coupdepoing[compteur_statut].lg, statut_coupdepoing[compteur_statut].h)
compteur_statut = compteur_statut + 1
if compteur_statut > statut_coupdepoing[1].n then
compteur_statut = 1
statut_kenshiro = 0
end
end
------------------------GAUCHE---------------------------------------------
if statut_kenshiro == 7 then
screen:blit(posmx, posmy-(statut_stand[compteur_statut].h), kenshiro7, statut_stand[compteur_statut].xs, statut_stand[compteur_statut].y, statut_stand[compteur_statut].lg, statut_stand[compteur_statut].h)
compteur_statut = compteur_statut + 1
if compteur_statut > statut_stand[1].n then
compteur_statut = 1
statut_kenshiro = 0
end
end
if statut_kenshiro == 8 then
screen:blit(posmx, posmy-(statut_marche[compteur_statut].h), kenshiro9, statut_marche[compteur_statut].xs, statut_marche[compteur_statut].y, statut_marche[compteur_statut].lg, statut_marche[compteur_statut].h)
compteur_statut = compteur_statut + 1
if compteur_statut > statut_marche[1].n then
compteur_statut = 1
statut_kenshiro = 0
end
end
if statut_kenshiro == 9 then
screen:blit(posmx, posmy-(statut_pied[compteur_statut].h), kenshiro10, statut_pied[compteur_statut].xs, statut_pied[compteur_statut].y, statut_pied[compteur_statut].lg, statut_pied[compteur_statut].h)
compteur_statut = compteur_statut + 1
if compteur_statut > statut_pied[1].n then
compteur_statut = 1
statut_kenshiro = 8
end
end
if statut_kenshiro == 10 then
screen:blit(posmx, posmy-(statut_saut[compteur_statut].h), kenshiro11, statut_saut[compteur_statut].xs, statut_saut[compteur_statut].y, statut_saut[compteur_statut].lg, statut_saut[compteur_statut].h)
compteur_statut = compteur_statut + 1
if compteur_statut > statut_saut[1].n then
compteur_statut = 1
statut_kenshiro = 8
end
end
if statut_kenshiro == 11 then
screen:blit(posmx, posmy-(statut_aterregauche[compteur_statut].h), kenshiro8, statut_aterregauche[compteur_statut].xs, statut_aterregauche[compteur_statut].y, statut_aterregauche[compteur_statut].lg, statut_aterregauche[compteur_statut].h)
compteur_statut = compteur_statut + 1
if compteur_statut > statut_aterregauche[1].n then
compteur_statut = 1
statut_kenshiro = 8
end
end
if statut_kenshiro == 12 then
screen:blit(posmx, posmy-(statut_coupdepoinggauche[compteur_statut].h), kenshiro12, statut_coupdepoinggauche[compteur_statut].xs, statut_coupdepoinggauche[compteur_statut].y, statut_coupdepoinggauche[compteur_statut].lg, statut_coupdepoinggauche[compteur_statut].h)
compteur_statut = compteur_statut + 1
if compteur_statut > statut_coupdepoinggauche[1].n then
compteur_statut = 1
statut_kenshiro = 8
end
end
if statut_kenshiro == 0 then
statut_kenshiro = 1
end
--if statut_kenshiro2 == 7 then
--statut_kenshiro2 = 8
--end
screen.waitVblankStart()
screen.flip()
end