supportedOrientations(LANDSCAPE_ANY)
function setup()
displayMode(FULLSCREEN_NO_BUTTONS)
clearLocalData() ; Data() ; suivant=true
hideKeyboard() ; str="" ; data="" ; ligne={}
debut=1 ; dx=0 ; dy=0 ; vitesse=1
dialogue={"Coucou c'est Halia"} ; tour="Halia"
liste= {
"animal","acteur","actrice","acronyme","adjectif","adverbe", "album","architecte","arme",
"article de loi","association","capitale","chanteur","chanteuse","chiffre","chose","continent",
"commande","couleur","dessert","devise","dictateur","dieu grec","élément chimique","équation",
"Europe","exact","expression","famille","famille animal","film","fleuve","fondateur","fruit",
"institution", "instrument de musique","inventeur","jeu de société","jeu vidéo","juron","légume",
"loisir","machine","marque de voiture","matière","médicament","mer","métier","meuble",
"modéle de voiture","nombre","océan","pays","pdg","peintre","planétes","pluriels","poi gps",
"politesse","prénom","président","pronom personnel","proverbe","race de chien","réalisateur",
"réalisatrice","reine","roi","sentiment","série tv","signe astrologique","sculpteur","sportif",
"sportive","sujet","top modéle","valeur","véhicule","verbe","ville","vin"
}
-- Commandes (vb) :
-- LISTER les couleurs
-- ECRIRE en Arial 12 points
-- EFFACE l'écran / l'historique
-- CITEZ moi une marque de voiture
-- DONNEZ moi l'heure
-- TRIER liste ALPHA
-- for i=1, #liste do lister(liste[i]) end
lister("fruit")
lister("chiffre")
lister("couleur")
--lld()
end
function Sto(str1,str2)
saveLocalData(str1,str2)
end
function Read(c)
local s=readLocalData(c)
local t={}
if s==nil then return "error"
else
for i in string.gmatch(s,"([^;]*);") do table.insert(t,i) end
return t
end
end
function draw()
background(42, 10, 219, 255) ; rectMode(CORNER) ; textMode(CORNER)
-- Affichage ligne de titre
font("even") ; fontSize(12) ; fill(255, 0, 228, 255)
text("( "..CurrentTouch.x.." ; "..CurrentTouch.y.." )",600,740)
text(os.date('%x').." "..os.date('%X'),800,740)
-- Affichage des menus en bas
font("ArialRoundedMTBold") ; fontSize(20)
fill(0, 247, 255, 255) ; text("CLAVIER",20,0)
fill(252, 8, 8, 255) ; text("SORTIE",920,0)
font("even") ; fontSize(12) ; fill(255, 0, 228, 255)
if keyboardBuffer() ~= nil then phrase=keyboardBuffer() end
ntour=1
for i=1, #dialogue do
fill(255,0,0)
if ntour==1 then
fill(132, 255, 0, 255) ; text("Halia > "..dialogue[i],20+dx,740-i*20+dy) ; ntour=2
elseif ntour==2 then
fill(244, 255, 0, 255) ; text("Invité > "..dialogue[i],20+dx,740-i*20+dy) ; ntour=1
end
end
if tour=="Invité" then resultats() ; tour="Halia" end
-- Invite de dialogue
tailledialogue=#dialogue
if tour=="Invité" then tour="Halia" else tour="Invité" end
fill(244, 255, 0, 255) ; text(tour.." > "..phrase,20+dx,720-tailledialogue*20+dy)
if tour=="Invité" then tour="Halia" else tour="Invité" end
end
function resultats()
mot=data ; t=Read(mot) ; nbitem=#t
tailledialogue=#dialogue
dialogue[tailledialogue+1]=mot
tailledialogue=tailledialogue+1
if t=="error" then dialogue[tailledialogue+1]="qu'est ce que c'est ?"
else
dialogue[tailledialogue+1]=mot
for i=1, nbitem, 2 do
dialogue[tailledialogue+1]=dialogue[tailledialogue+1].." / "..t[i]
dialogue[tailledialogue+1]=dialogue[tailledialogue+1].." "..t[i+1]
print("["..t[i].."]","["..t[i+1].."]")
end
display=false
end
end
function lister(nomliste)
lst=listLocalData() ; nbdef=#lst ; txt=""
for i=1, nbdef do
mot=lst[i] ; t=Read(mot) ; nbitem=#t
for j=1, nbitem, 2 do
if t[j+1]==nomliste then txt=txt.."ex;"..mot..";" end
end
end
print(nomliste,txt)
Sto(nomliste,txt)
end
function lld()
-- Vérifier les erreurs d'enregistrement ( manque de ; )
ld=listLocalData()
nbptvirgule=0
for a,b in pairs(ld) do
result=readLocalData(b)
for i=1,string.len(result) do
if string.sub(result,i,i)==";" then
nbptvirgule = nbptvirgule + 1
end
end
if nbptvirgule~=2 and nbptvirgule~=4 and nbptvirgule~=6 and
nbptvirgule~=8 and nbptvirgule~=16 then print(b,nbptvirgule)
end
nbptvirgule=0
end
end
function keyboard(key)
if key == BACKSPACE then
data = string.sub(data, 1, string.len(data) - 1)
elseif key == RETURN then
hideKeyboard() ; data = phrase
if data == nil then data = "" end
if tour=="Halia" then tour="Invité" else tour="Halia" end
end
end
function touched(t)
if t.state==BEGAN then
if CurrentTouch.y<30 then
if CurrentTouch.x>20 and CurrentTouch.x<120 then showKeyboard() end
if CurrentTouch.x>920 and CurrentTouch.x<1000 then close() end
end
elseif t.state==MOVING then dy=dy+t.deltaY*vitesse ; dx=dx+t.deltaX*vitesse
end
end
Data = class()
function Data:init(x)
-- definitions par groupe de 2 (tout en minuscule)
-- Sto("mot","lien1;liaison1;lien2;liaison2")
-- Uiliser plutôt la relation ascendante "est" qui signifie "appartient à" plutôt que "comporte"
-- Les traitements batch nocturnes consituent des listes de liaisons descendantes "comporte"
-- les liaisons "commandes" renvoient vers des fonctions codea
-- par ex : ecris moi en arial rouge 12 points
-- ecris moi -> la commande qui attend une fonte et/ou une couleur et/ou une taille
-- par ex : arrière plan en blanc sur fonte en noir
Sto("?","est;interrogation;")
Sto("!","est;exclamation;")
Sto("pomme","est;fruit;")
Sto("poire","est;fruit;")
Sto("Porsche","est;marque de voiture;")
Sto("portugal","est;pays;est;Europe;")
Sto("poséidon","est;dieu grec;sujet;mer;")
Sto("primate","est;mammifère placentaire;")
Sto("puissance","opérande;pow();commande;pow();")
Sto("prunesgta","est;fruit;")
Sto("quand","est;préposition interrogative;sujet;temps;")
Sto("quart","constante;1/4;valeur;0.25;")
Sto("quatorze","est;nombre;valeur;14;")
Sto("quatre","est;chiffre;valeur;4;")
Sto("quel","est;préposition interrogative;sujet;chose;")
Sto("quelle","est;préposition interrogative;sujet;chose;")
Sto("qui","est;pronom indéfini;est;préposition interrogative;sujet;personne;")
Sto("quiconque","est;pronom indéfini;")
Sto("quinze","est;nombre;valeur;15;")
Sto("racine","opérande;sqrt();commande;sqrt();")
Sto("racine carrée","opérande;sqrt();commande;sqrt();")
Sto("rambo","est;film;")
Sto("réceptionniste","est;métier;")
Sto("recevoir cinq sur cinq","expression;comprendre;")
Sto("réfrigérateur","est;chose;")
Sto("renault","est;marque de voiture;")
Sto("république tchéque","est;pays;est;Europe;")
Sto("rien","est;pronom indéfini;")
Sto("rocky","est;film;date de création;1976;acteur;Sylvester Stallone;")
Sto("rome","est;ville;")
Sto("rose","est;couleur;commande;rvb(253,108,158);")
Sto("rouge","est;couleur;commande;rvb(255,0,0);")
Sto("rouler","est;verbe;implique;mouvement;")
Sto("royaume-uni","est;pays;est;Europe;")
Sto("rubis","est;couleur;commande;rvb(224,17,95);")
Sto("russie","est;pays;est;Europe;")
Sto("france","est;pays;est;Europe;")
Sto("sa","est;adjectif possessif;")
Sto("saint-marin","est;pays;est;Europe;")
Sto("salade","est;légume;")
Sto("salut","est;politesse;")
Sto("saule","est;arbre feuillu;")
Sto("sauterne","est;vin;")
Sto("scrabble","est;jeu de société;")
Sto("se casser","expression;partir;")
Sto("seine","est;fleuve;")
Sto("seize","est;nombre;valeur;10;")
Sto("sept","est;chiffre;valeur;7;")
Sto("serbie","est;pays;est;Europe;")
Sto("serveur","est;métier;")
Sto("ses","est;adjectif possessif;")
Sto("six","est;chiffre;valeur;6;")
Sto("slovénie","est;pays;est;Europe;")
Sto("slovaquie","est;pays;est;Europe;")
Sto("slt","est;politesse;")
Sto("soeur","est;famille;sujet;femme;")
Sto("son","est;adjectif possessif;")
Sto("suéde","est;pays;est;Europe;")
Sto("suis","est;verbe;temps;présent;")
Sto("suisse","est;pays;est;Europe;")
Sto("sylvester stallone","est;acteur;")
Sto("ta","est;adjectif possessif;")
Sto("table","est;chose;")
Sto("tailler la zone","expression;partir;")
Sto("tarot","est;jeu de carte;")
Sto("tel","est;pronom indéfini;")
Sto("terre","est;planète;")
Sto("tes","est;adjectif possessif;")
Sto("tilleul","est;arbre feuillu;")
Sto("ton","est;adjectif possessif;")
Sto("tout","est;pronom indéfini;")
Sto("treize","est;nombre;valeur;13;")
Sto("tremble","est;arbre feuillu;")
Sto("trois","est;chiffre;valeur;3;")
Sto("tu","est;sujet;")
Sto("turquie","est;pays;est;Europe;")
Sto("turquoise","est;couleur;commande;rvb(37,253,233);")
Sto("twingo","est;Renault;est;modéle de voiture;")
Sto("ukraine","est;pays;est;Europe;")
Sto("un","est;pronom indéfini;est;article indéfini;est;chiffre;valeur;1;")
Sto("une","est;article indéfini;valeur;1;")
Sto("vatican","est;pays;est;Europe;")
Sto("vert","est;couleur;commande;rvb(0,255,0);")
Sto("vieux","est;adjectif;")
Sto("violet","est;couleur;commande;rvb(127,0,255);")
Sto("violon","est;instrument de musique;")
Sto("voiture","est;vehicule;but;rouler;")
Sto("vous","est;sujet;")
Sto("wesh","est;politesse;")
Sto("xeus","est;dieu grec;sujet;ciel;")
Sto("zéro","est;chiffre;valeur;0;")
Sto("zinzolin","est;couleur;commande;rvb(108,2,119);")
end
function Data:draw()
end
function Data:touched(touch)
end
hello,
my problem is in function : résultats()
dialogue[tailledialogue+1]=dialogue[tailledialogue+1]…" / “…t[i]
dialogue[tailledialogue+1]=dialogue[tailledialogue+1]…” "…t[i+1]
print(“[”…t[i]…“]”,“[”…t[i+1]…“]”)
why with “print” i can see my list
but with dialogue array, it doesn’t work
thanks a lot
@hpsoft The language is slowing me down a little, but when I run this, what I see with the print statements looks like what I see on the screen. I’m not sure what you should see. When I key in “rose”, this shows on the screen “rose / est couleur / commande rvb(253,108,158)” and the same thing seems to show with the print statements. What should appear on the screen when “rose” is keyed in.
thanks when you write “pomme” (apple) or “poire” by exemple, it works…
but when i test lister function, when i write “fruit” in prompt by exemple
the result is empty but print function works in parameters
what is strange, the lister chiffre works ?
@hpsoft When your program first starts, you print 3 lines, 1 for fruit, 1 for chiffre, and 1 for couleur. If I key in each of those words, I see a similar result from the print statements and also what show on the screen. You say when you key in fruit, you don’t see anything on the screen, but the print statements work.
Here is what I see when I key in fruit:
In the print window
fruit ex;pomme;ex;prunesgta;ex;poire;
On the screen
Invité > fruit
Halia > fruit / ex pomme / ex prunesgta / ex poire
@hpsoft your problem is with indexes. You should read lua doc section on the subject. This should work in lister function:
for i,v in paits(lst) do
-- your code
end
thanks
@dave1707 it’s strange it’s works at second execution of program
for “fruit” and “chiffre” but not for “couleur”
@Jmv38 i will try with pairs
it’s probably besser than for … do … end
yes. #lst for only in a very special case: index from 1 to n, with no omission. Doesnt count string keys!