Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
Ledragon
- Posts: 7
- Joined: Fri Jul 31, 2009 8:44 am
-
Contact:
Post
by Ledragon » Fri Jul 31, 2009 9:00 am
Please help. I'm new to Rev
I want my script to display random text on my stack! There are graphics on it. It looks like a couple of buttons: when pressing the right one, it tells some random message, when pressing the wrong one, it tells another random message.
I know how to display a random javascript message, but this is not an HTML.
So the question is:
how to make that random text messages display on a graphic (a png image).
I do not want to use the "answer" command, because it brings another window!
Thanks beforehand
-
Janschenkel
- VIP Livecode Opensource Backer

- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
-
Contact:
Post
by Janschenkel » Fri Jul 31, 2009 1:11 pm
Rather than a graphic or image, why not use a field control?
Code: Select all
put "Hello, world!" into field "MyRandomMessage"
show field "MyRandomMessage"
If you want to add some styling information, you can also use the field control's built-in htmlText property
Code: Select all
put "<p><b>Hello, <i>world</i>!</b></p>" into theHtmlText
set the htmlText of field "MyRandomMessage" to theHtmlText
show field "MyRandomMessage"
Jan Schenkel.
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Fri Jul 31, 2009 1:14 pm
Dear Ledragon,
Create a transparent field on top of the image object. Keep your collection of sentences somewhere in a field or in a custom property. Let's assume you use a field in this case. Then use the following script in your button:
Code: Select all
on mouseUp
put any line of fld "Collection" into fld "Transparent Field"
end mouseUp
That's it.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
Ledragon
- Posts: 7
- Joined: Fri Jul 31, 2009 8:44 am
-
Contact:
Post
by Ledragon » Fri Jul 31, 2009 2:46 pm
Thanks a lot! I did non imagine it would be so easy!
However, my text is in Armenian, and on input, it changes the characters.
In other words, there is a font problem. I suppose it may bring problems on deployment on different operating systems as well.
So I need to declare a font I suppose and somehow put that font into the application.
Is it possible? Or how can I handle this in other way?
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Fri Jul 31, 2009 2:56 pm
Hi Ledragon,
You *might* try the following:
Code: Select all
on mouseUp
put any line of the unicodeText of fld "Collection" into myUnicode
set the unicodeText of fld "Transparent Field" to myUnicode
end mouseUp
This is just a guess, though. Does this work for you?
Best,
Mark
Edit: I added a NULL at the end of the line, but this is not necessary.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
Ledragon
- Posts: 7
- Joined: Fri Jul 31, 2009 8:44 am
-
Contact:
Post
by Ledragon » Fri Jul 31, 2009 3:56 pm
Thanks Mark!
I found out that this is an Armenian font problem. Some are unicode compatible but there can be problems on viewing them in different OS.
Instead I decided to convert all my text to images, collect those text-images into a separate substack and call a random one on click!
So, thank you very much for your efforts to help me.
-
Ledragon
- Posts: 7
- Joined: Fri Jul 31, 2009 8:44 am
-
Contact:
Post
by Ledragon » Sat Aug 01, 2009 9:55 am
Dear Mark,
Thank you for useful tips.
However, I'm still stack with my script.
I want a random image (which is a text converted to image) of stack x to be shown on stack y on click
and there is a button which removes that text-image and replaces it with another image (some kind of relaunch button "play again", the principle is hide and show the image).
I made the whole application (it's a game for little children, called in which my hand) but only with 3 possible images, like "play again" (hides the message "you won" and the message "you lost"), the "you won" message hiding the other two messages and so on. So on show of one image the others are hidden.
But now I want to put more winner and looser messages (messages are images). So on winning it displays a random "you won" message and on loosing it displays a random "you lost" message.
I thought that separating these win-and-lost images in different invisible stacks or cards will help. However, I was unable to make the picture of one stack or card show on the main one.
Can you please give a hint?
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Sat Aug 01, 2009 10:14 am
Hi Ledragon,
You might try the following:
Code: Select all
if theAnswerIsCorrect is true then
set the icon of btn "The Message" to the short id of any img of stack "Stack with Right Messages"
else
set the icon of btn "The Message" to the short id of any img of stack "Stack with Wrong Messages"
end if
This script needs a transparent button, called "The Message". You don't need to show and hide images or put images on top of each other. You only need to set the icon of the button. If you don't want to show any message at all, use
Code: Select all
set the icon of btn "The Message" to 0
and if the buttons gets in the way, use the show and hide commands to show or hide it as needed.
Best regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
Ledragon
- Posts: 7
- Joined: Fri Jul 31, 2009 8:44 am
-
Contact:
Post
by Ledragon » Sat Aug 01, 2009 11:53 am
if iwin = 1 then
set the icon of btn "Message" to the short id of any img of stack "Winner"
else
set the icon of btn "Message" to the short id of any img of stack "Looser"
end if
However, when the script is launched, it brings a random image from any image in the project. It does not differentiate between stacks!
When I put the id-s instead of names (like id 1009), it brought an error telling there was no such a stack
Is there some kind of a bug? Or is something wrong with my file?
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Sat Aug 01, 2009 11:56 am
Hi Ledragon,
This isn't a bug, this is a slightly impractical feature :-) Just change the id of all images in your two stacks. You can even write a script for this.
Code: Select all
repeat with x = 1 to number of images
set the id of img x to (the id of img x + 10000)
end repeat
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
Ledragon
- Posts: 7
- Joined: Fri Jul 31, 2009 8:44 am
-
Contact:
Post
by Ledragon » Sun Aug 02, 2009 10:19 am
Mark you are the best! Thank you very much for all. I finally made it. It's great to see that your creation works, whatever it is.
Thank you