Dice won't stop
DocJ
Member Posts: 66
Hi,
I'm sure there is a very obvious explanation for this, but being a rookie, I'm not seeing it. I am trying to make a die that will display text instead of numbers. TB Red Die is the name of my table with the words on it.
I think I have most of this right, but I'm definitely missing something. The words come up, but they won't stop. I'm getting a different word what seems like every 100th of a second. Just runs on a continuous loop. Thank you for looking, and possibly helping.
Doc
Here's what I have;
Display Text
TableCellValue(game.TB Red Die,random(1,6),1
Comments
https://www.dropbox.com/sh/iwrzazdeeedtxxo/AAD2Jju-MxwjPYx5CC0sYLf2a?dl=0
Done XD
Now you can check out whatever you did wrong!
(PS: there is nothing wrong with being a rookie.
I was a rookie once too, but if you have any questions, you can also just mail me!)
Nickname, thanks again for all you've done so far. Unfortunately, I'm still getting the same problem. I'm going to try and draw one from scratch. This way I'll be able to see if it's something else I did. I'll let you know how it works out.
Doc
That will display whatever value is in the first column of a random row of your table.
You haven't explained how you're doing any of this. Are you using Timers, loops, custom timers, some other rule condition(s)...?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Hi Tatiang, thanks for weighing in. I tried setting it up just like one of the video tutorials on tables I found on YouTube. On his video, he gets a new word with every click of the Play button on the stage. When I do the same thing, one hit of the Play button gets me a continuous loop of rapid random words.
So far I only have the tables for the dice. One for each since they contain different words. I tied a Display Text Rule to the table as shown in the video. So far, that's my only rule or behavior. I was thinking I might have to research using a trigger like a Touch of the iPad.
I'm going to try over again and see if it works differently. I'll keep you posted.
OK,
Tried this again. Here's what I did and what I got:
I created a table with 1 column and 6 rows of words. Labeled it TB Red Die
Added an Actor.
Dragged the Actor on to the Initial Scene
Under the Prototype Actor in the Backstage, I dragged the Display Text (with the green P) into the Backstage field
In the Expression Editor I added: tableCellValue(game.TB Red Die,1,1)
That gave me the word in the first row
I changed it to 2,1 and got the word in the 2nd Row, etc
When I changed it to; tableCellValue(game.TB Red Die,random(1,6),1)
I get one of the 6 words randomly, but very quickly and in a continuous loop
No other attributes were changed anywhere
You've posted two responses but still haven't explained how you're doing a "continuous loop." I know you're new to GameSalad which is fine but for me to help you I have to know exactly how you're doing this. Things don't just loop on their own... are you using a Timer? What does the rule look like (a screenshot would be really helpful at this point; you can upload it to a file-sharing site and then embed/post the link here) where the loop is happening?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Tatiang, everything I did, I listed. I literally made no other changes whatsoever. I will take a screenshot and post it here later. Thanks again for trying to help me. I would even gladly send you my file if you want to see it. I'm certainly not asking for anybody to do my work, I'm just offering that so your trained eyes can see if I inadvertently did something.
I will look into Dropbox in a bit. Thanks again.
Doc
Yes, please send me the file. You can do so via private message (PM) or by posting the download link here.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Here is the link to DropBox. The only thing that wouldn't go through is the GS file itself because it was 0 kb. I left out some other folders because there wasn't anything in them.
https://www.dropbox.com/sh/s854s21pfpc3xks/AAALfPIUoVYZktQU_uAUv975a?dl=0
I don't know what might cause your problem, but the only thing I can think of is that your version does this. My version doesn't and if I follow everything you do, it should not do what it does.
I believe that it is not your fault that this happens.
Maybe an "if mouse button is down" behavior works. If it loops when mouse position is down, you know something is wrong....
@DocJ I need the complete project folder. If you remove files/folders from it, I can't Preview it.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
You might also try this:
If Touch is Pressed
Change attribute game.row (integer) to random(1,tableRowCount(game.TB Red Die))
And then in the actor that is displaying a word, Display Text tableCellValue(game.TB Red Die,game.row,1)
That will pick a random row (and therefore word) each time you click the actor.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Tatiang and Nickname,that last code suggested worked
I used Mouse Button is Down to trigger the event.
The Change Attribute as suggested.
Adding in the Game attribute Row as an Integer
I've experimented by moving things around and deleting things, trying to see why and how it works.
I have a couple of questions if you don't mind.
To notify another forum member, use the '@' symbol before their username like this: @DocJ.
I don't mind questions... what are they?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
OK great! And thanks for the heads up on how to notify another member. I just assumed he got it because he was in on the thread.
What was the purpose of adding the Game Attribute "Row"?.........I tried deleting it. The game wouldn't work without it.
Why does the Rule Mouse Button only work when it's on the Background layer, and not the Red Dice layer? (I added the same tableCellValue expression for the Yellow Dice, but now I get random words for both at the same time).....
Ideally I would like to be able to touch one dice, have a value come up and stay on the screen (locked...no second chance), touch the next dice, etc...
So my thinking is this would have to be done by touching the Instance Actor and not the Background
Please, if you feel like I'm asking too many questions, feel free to say so. And again, thank you.
To lock a value in, create an actor attribute called something like self.locked (boolean). Right after the die value is chosen, change self.locked to true. In the rule for choosing that value add attribute self.locked is false as a condition.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Awesome explanation!! I can't wait to finish with patients and try this later.
I was watching a video in the Community Tutorials during my break and wish the version of GS I have had the ability to place the text like the Mac GS does (Relative to Actor or Scene). Hopefully they'll come out with that in future updates.
Thanks again. I'll let you know how it works out.
You're welcome. Let me know if you have other questions.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Tatiang, I'm sorry, I'm confused. I got rid of the Mouse Button rule in the Background layer. I added a Touch is Pressed to the Actor of each dice into the When section. In the Do section I added the tableCellValue expression you taught me.
Here's the weird part; when I preview it, nothing happens. When I change the Display Text to a brand new one with just the "Hello World" in it, it works. It doesn't, however, work with the Expression Editor values we have;
tableCellValue(game.TB Red Dice,game.row,1)
Does the referenced table have to be dragged down to the Backstage to have a tab next to the Prototype and Instance Actor?
I don't know what that means so my answer would be a tentative 'no'.
Make sure you are selecting both game.TB Red Dice and game.row from the Attribute browser and not just typing them in.
Can you post a link to download your project file? It may be something simple to fix. If you prefer, you can send me the link in a private message (PM).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Tatiang,
I tried what you suggested by changing the game.Row attribute from Integer 0 to Integer 1 (so the Table would have a row to read from). This worked, but unfortunately this only read row 1. I then changed the Expression Editor
from: Display Text tableCellValue(TB Red Dice,game.Row,1)
to: Display Text tableCellValue(TB Red Dice, random(1,6),1)
That seemed to do the trick.
I know you probably could spend hours every day just helping people....well let me say, it really is appreciated!!
Doc
You're welcome! It sounds like you figured it out but let us know if you have other questions.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Yeah, I spoke too soon. I messed something up....searching to find out what. I'll find out what the heck I did wrong.