Start a new topic

Randomize Text

Hello,


I want to programm a little game on my Nextion. It is called "Never have I ever..." or in German " Ich habe noch nie...".

If I press the Button "New question" the code below is executed. It works fine, but is there a way that I don't have to make a if for all ? 

Like I have a list with the questions and when I press the Button, the textfield shows a random questions of my list??


Sorry for my bad Englisch...


Code:


randset 1,15

x.val=rand

if(x.val==1)

{

  t0.txt="eine Bollerwagentour gemacht"

}

if(x.val==2)

{

  t0.txt="Alkohol getrunken"

}

if(x.val==3)

{

  t0.txt="nackt einen Spaziergang gemacht"

}

if(x.val==4)

{

 t0.txt="gelogen"

}

if(x.val==5)

{

 t0.txt="betrogen"

}

if(x.val==6)

{

 t0.txt="gestohlen"

}

if(x.val==7)

{

 t0.txt="Drogen getestet"

}

if(x.val==8)

{

 t0.txt="Handschellen getragen"

}

if(x.val==9)

{

 t0.txt="geprügelt"

}

if(x.val==10)

{

 t0.txt="jemanden um Geld betrogen"

}

if(x.val==11)

{

 t0.txt="bei der Beichte gelogen"

}

if(x.val==12)

{

 t0.txt="Vandalismus betrieben"

}

if(x.val==13)

{

 t0.txt="meine Eltern beklaut"

}

if(x.val==14)

{

 t0.txt="jemanden gemobbt"

}

if(x.val==15)

{

 t0.txt="die Zeche geprellt"

}

1 Comment

 

Forum has been closed since the Nov. 15, 2017  23:59:59.

Please use new forum nextion.itead.cc