Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Picking Words from List in a Text Box

Status
Not open for further replies.

Dazza203

Technical User
Dec 3, 2003
28
GB
Hi,

I have created a simple Hangman Game where at the beginning of each game a word is picked at random from a list of words stored in a text box in the cast. What I want to do though is create a separate text box in the cast with a list of clue words with each word where a clue will be provided on the stage as to what the word the user has to guess could be at the beginning of each came. I guess I could do this by creating another text box with a list of words but put the clues on the same lines as they are in the words text box and then using lingo to look up that line in the clue words text box depending on wot word is chooses in the actual words text box. Below is the frame script that I'm using at the beginning of the game that chooses a word from the text box at random that the user has to guess at the beginning of the game:

global gHangmanWord

on exitFrame me
gHangmanWord = getHangmanWord()
letterList = []
repeat with x = 1 to gHangmanWord.char.count
letterList.add(gHangmanWord.char[x])
end repeat
sendAllSprites(#assignLetter, letterList)
end

on getHangmanWord
pickText = member("Hangman Words").text
howManyLines = pickText.line.count
repeat with x = howManyLines down to 1
if pickText.line[x] = "" then delete pickText.line[x]
end repeat
thisOne = random(howManyLines)
return pickText.line[thisOne]
end

Any help with this would be appreciated.

Thanks,
Darren
 
Your member("Hangman Words") can contain both words and clues. e.g.

Word1, Some clue 1
Word2, Some clue 2


To get the word and corresponding clue:
--
wordAndClue = pickText.line[thisOne]
theWord = wordAndClue.word[1]
theClue = wordAndClue.word[2..(wordAndClue.word.count)]
--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top