|
Page 1 sur 1 [ 2 messages ]
|
[RESOLU] [Lua] Problème avec les dofile()
| Auteur |
Message |
|
PSP addict
Messages: 101 Localisation: Derrière l'ordi!!!
|
 [RESOLU] [Lua] Problème avec les dofile()
Bonjour, j'ai un petit problème de dofile, en suivant ce tuto. Le lua player ne trouve aucun scripts alors qu'en mettant les dofile() comme il est déconseiller sa marche.
Texte caché : cliquez sur le cadre pour l'afficher
script.lua: Code : dofile("menu.lua") dofile("ecrire.lua") dofile("new.lua") dofile("suppr.lua") dofile("credits.lua") dofile("utilisation.lua")
background = Image.load("img/fond.png") police = Font.load("POLICE.TTF") police:setPixelSizes(40, 40) noir = Color.new(0,0,0) blanc = Color.new(255,255,255) selection = 1
while true do screen:clear() pad = Controls.read()
screen:blit(0,0,background) if pad:down() and not oldpad:down() then selection = selection + 2 end
if pad:up() and not oldpad:up() then selection = selection - 2 end
if pad:right() and not oldpad:right() then selection = selection + 1 end
if pad:left() and not oldpad:left() then selection = selection - 1 end
if selection < 1 then selection = 1 end
if selection > 4 then selection = 4 end
if selection == 1 then screen:fontPrint(police, 10 ,120, "Ecrire", blanc) screen:fontPrint(police, 240 ,120, "Supprimer", noir) screen:fontPrint(police, 10 ,160, "Utilisation", noir) screen:fontPrint(police, 240 ,160, "Credits",noir) if pad:cross() and not oldpad:cross() then Menu() end end
if selection == 2 then screen:fontPrint(police, 10 ,120, "Ecrire", noir) screen:fontPrint(police, 240 ,120, "Supprimer", blanc) screen:fontPrint(police, 10 ,160, "Utilisation", noir) screen:fontPrint(police, 240 ,160, "Credits",noir) if pad:cross() and not oldpad:cross() then Suppr() end end
if selection == 3 then screen:fontPrint(police, 10 ,120, "Ecrire", noir) screen:fontPrint(police, 240 ,120, "Supprimer", noir) screen:fontPrint(police, 10 ,160, "Utilisation", blanc) screen:fontPrint(police, 240 ,160, "Credits",noir) if pad:cross() and not oldpad:cross() then Utilisation() end end
if selection == 4 then screen:fontPrint(police, 10 ,120, "Ecrire", noir) screen:fontPrint(police, 240 ,120, "Supprimer", noir) screen:fontPrint(police, 10 ,160, "Utilisation", noir) screen:fontPrint(police, 240 ,160, "Credits",blanc) if pad:cross() and not oldpad:cross() then Credits() end end
oldpad = pad
screen.flip() screen.waitVblankStart()
end menu.lua Code : background = Image.load("img/fond.png") police = Font.load("police.TTF") police:setPixelSizes(50, 45) noir = Color.new(0,0,0) blanc = Color.new(255,255,255) selection = 1 nn = 1
function Menu() while true do screen:clear() pad = Controls.read()
screen:blit(0,0,background)
if pad:down() and not oldpad:down() then selection = selection + 1 end
if pad:up() and not oldpad:up() then selection = selection - 1 end
if selection < 1 then selection = 1 end
if selection > 2 then selection = 2 end
if selection == 1 then screen:fontPrint(police,10,160,"Nouveau",blanc) screen:fontPrint(police, 10, 200,"Ouvrir",noir) if pad:cross() and not oldpad:cross() then New() end end end
if selection == 2 then screen:fontPrint(police, 10, 160,"Nouveau",noir) screen:fontPrint(police,10,200,"Ouvrir",blanc) if pad:cross() and not oldpad:cross() then Ecrire() end end
if pad:circle() and not oldpad:circle() then return end
oldpad = pad end ecrire.lua Code : police = Font.load("POLICE.TTF") police:setPixelSizes(40, 40) lecture = Font.load("POLICE.TTF") lecture:setPixelSizes(20, 20) fond = Image.load("img/fondl.png") background = Image.load("img/fond.png") rouge = Color.new(255,0,0) blanc = Color.new(255,255,255) noir = Color.new(0,0,0)
Partie = 1 Saut = 4 select = 1 PosY = 120 Espace = 50 PosYDep = 30 PosX = 10
System.currentDirectory("ms0:/PSP/GAME/iNotes/Notes") Fichiers = System.listDirectory()
endroit = "charger"
function Ecrire() while true do pad = Controls.read() screen:clear() screen:blit(0,0,background)
if endroit == "charger" then if pad:circle() and not oldpad:circle() then return end for i = Partie, Partie + Saut - 1 do screen:fontPrint(police,PosX,PosY,Fichiers[i].name,blanc) PosY = PosY + Espace if table.getn(Fichiers) == i then break end end
PosY = PosYDep
screen:fontPrint(police,PosX,(select-Partie)*50+PosYDep,Fichiers[select].name,rouge)
if pad:down() and not oldpad:down() then select = select + 1 end if pad:up() and not oldpad:up() then select = select - 1 end
if select > Partie + Saut - 1 and Partie + Saut - 1 ~= table.getn(Fichiers) then Partie = Partie + Saut elseif select < Partie then Partie = Partie - Saut end
if pad:triangle() and oldpad:triangle() ~= pad:triangle() then oldpad = pad select = 1 Partie = 1 if System.currentDirectory() ~= "ms0:/" then System.currentDirectory("..") Fichiers = System.listDirectory() end end
if pad:cross() and oldpad:cross() then
if Fichiers[select].directory then
System.currentDirectory(Fichiers[select].name) Fichiers = System.listDirectory() Partie = 1 select = 1 else extension = string.upper(string.sub(Fichiers[select].name,-3)) if extension == "TXT" then file = io.open("Fichiers[select].name","a") myText = System.startOSK("","Entrez votre texte") file:write(myText) file:close() endroit = "ecrire" end end end end
if endroit == "ecrire" then screen:blit(0,0,fond) y = 35 file = io.open("Fichiers[select].name","r") for line in file:lines() do y = y + 10 screen:fontPrint(lecture,60,y,line,noir) end file:close()
if pad:circle() and not oldpad:circle() then endroit = "charger" end end
oldpad = pad end end suppr.lua Code : police = Font.load("POLICE.TTF") police:setPixelSizes(40, 40) back = Image.load("img/fond.png") rouge = Color.new(255,0,0) blanc = Color.new(255,255,255) noir = Color.new(0,0,0)
Partie = 1 Saut = 4 select = 1 PosY = 120 Espace = 50 PosYDep = 30 PosX = 10
System.currentDirectory("ms0:/PSP/GAME/iNotes/Notes") Fichiers = System.listDirectory()
endroit = "charger"
function Suppr() while true do pad = Controls.read() screen:clear() screen:blit(0,0,back)
if endroit == "charger" then if pad:cross() and not oldpad:cross() then return end for i = Partie, Partie + Saut - 1 do screen:fontPrint(police,PosX,PosY,Fichiers[i].name,blanc) PosY = PosY + Espace if table.getn(Fichiers) == i then break end end
PosY = PosYDep
screen:fontPrint(police,PosX,(select-Partie)*50+PosYDep,Fichiers[select].name,rouge)
if pad:down() and not oldpad:down() then select = select + 1 end if pad:up() and not oldpad:up() then select = select - 1 end
if select > Partie + Saut - 1 and Partie + Saut - 1 ~= table.getn(Fichiers) then Partie = Partie + Saut elseif select < Partie then Partie = Partie - Saut end
if pad:triangle() and oldpad:triangle() ~= pad:triangle() then oldpad = pad select = 1 Partie = 1 if System.currentDirectory() ~= "ms0:/" then System.currentDirectory("..") Fichiers = System.listDirectory() end end
if pad:circle() and oldpad:circle() then
if Fichiers[select].directory then
System.currentDirectory(Fichiers[select].name) Fichiers = System.listDirectory() Partie = 1 select = 1 else extension = string.upper(string.sub(Fichiers[select].name,-3)) if extension == "TXT" then System.removeFile(Fichiers[select].name) end end end end
oldpad = pad end end credits.lua Code : background = Image.load("img/fond.png") police = Font.load("POLICE.TTF") police:setPixelSizes(40, 40) noir = Color.new(0,0,0) blanc = Color.new(255,255,255)
function Credits() while true do screen:clear() pad = Controls.read()
screen:blit(0,0,background)
screen:fontPrint(police,160,110,"iNotes",blanc) screen:fontPrint(police,85,160,"Code by arropsy1",noir) screen:fontPrint(police,150,210,"Graphs by",noir) screen:fontPrint(police,20,250,"Saliom & Badwayne",noir)
if pad:circle() and not oldpad:circle() then return end
oldpad = pad end end utilisation.lua Code : aide = Image.load("img/aide.jpg") function Utilisation()
pad = Controls.read() while true do screen:clear() screen:blit(0,0,aide)
if pad:circle() and not oldpad:circle() then return end
oldpad = pad end end Voilà merci de me répondre. EDIT: Merci -Immortal-
_________________
Artiste du mois de Décembre 2011 Click-iciMerci
Dernière édition par arropsy1 le 22 Déc 2011, 19:27, édité 3 fois.
|
| 22 Déc 2011, 14:00 |
|
 |
|
publicité
|
|
 |
|
Dev
Messages: 241 Localisation: 92
|
 Re: [Lua] Problème avec les dofile()
Pour utiliser les dofiles ainsi il faut faire comme ceci : menu.lua Code : function Menu()
--variable(s)
screen.waitVblankStart() screen.flip()
while true do --on ouvre la boucle screen:clear()
--code
screen.waitVblankStart() screen.flip() end En espérant t'avoir aidé ! 
_________________
|
| 22 Déc 2011, 15:32 |
|
 |
|
|
Page 1 sur 1 [ 2 messages ]
|
Qui est en ligne ? |
Utilisateurs parcourant actuellement ce forum : Aucun utilisateur inscrit |
|
Vous ne pouvez pas publier de nouveaux sujets dans ce forum Vous ne pouvez pas répondre aux sujets dans ce forum Vous ne pouvez pas éditer vos messages dans ce forum Vous ne pouvez pas supprimer vos messages dans ce forum Vous ne pouvez pas insérer de pièces jointes dans ce forum
|
|