Link to home
Start Free TrialLog in
Avatar of enakok
enakok

asked on

lingo script

Im definitely new in director, but i already familiar with its environment co'z i take some of its tutorial. I have difficultly manipulating lingo script, im planning to make a game like "Who wants to be a millionnaire", i was able to randomize the questions, but i dont know how will that questions will be disregarded or will not be repeated if its already been asked or answer by the user????  
Avatar of enakok
enakok

ASKER

help me pls!!!
Just a first thought on it, but you could make an array or list of the questions and then remove that from the active list after the question has been used. Look in to manipulating lists with lingo.

Regards,
Peter Witham
ASKER CERTIFIED SOLUTION
Avatar of NovusAxis
NovusAxis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of enakok

ASKER

tnx novusAxis! i got a bit of idea from u but if its ok with u can u pls cite more example, i mean more detailed than the previous?  tnx! it can really help me if you do so!
You can also use a master list...

questions = ["q1", "q2", "q3"]

Then each time you need a question...

r = random(questions.count)
thisQuestion = questions[r]
questions.deleteAt(r)

This way they never repeat as each is removed once its used.
All the comments above all lead to basically the same idea -- use an array or list in Lingo terms and manipulate it accordingly, but obviously you don't have enough background about Lingo (and I believe programming in general).  I would suggest that you study about basic Lingo programming first so you can understand the suggestions and examples that we provide.  

Anyway, to directly answer your problem, here's a more detailed example of the above suggestions, this will display 5 questions 1 at a time in random order:

1. make a movie script and type this in (I hope you already know about cast members).  This will create a list named "qlist" containing questions 1 to 5.

---
global qlist

on startMovie
  initQuestion()
end

on initQuestion
  qlist=["question 1", "question 2", "question 3", "question 4", "question 5"]
end
---

2. make a text box and position it in the stage.  name this text cast member as "qholder"

3. put a button labelled "Question" in the stage and in the button put this script:

---
global qlist

on beginsprite me
  showQuestion()
end

on showQuestion me
  qp = random(qlist.count)
  member("qholder").text = qlist[qp]
  qlist.deleteAt(qp)
end

on mouseup me
  if qlist.count>1 then
    showQuestion()
  else
    member("qholder").text = "No more questions, press reset"
  end if
end
---

4. put another button labelled "Reset" in the stage and put this script:

---
on mouseup me
  initQuestion()
end
---

try this script and let us know if that's what you're looking for.  if it works, ask any part which you don't understand and I'll gladly explain it to you, just remember there's a help menu in director -- that's very useful.