Help needed, count won't display in message
by Rayna · in General Discussion · 09/10/2008 (7:59 pm) · 9 replies
Okay, so what I'd like to do is to have a count of items that have been placed in the scene to be sent to the client message HUD after they pick up one from the scene. I might want to make it display after a certain number, but that will have to wait until I get this working.
The block of code looks like this:
The line does execute and print to the HUD, however the actual count is omitted. Any suggestions as to why it won't add the count to the message? And I do have a datablock for this item, and the victory condition is executed when all of the items have been found, so I know it's counting, just not displaying.
Thanks in advance.
The block of code looks like this:
Quote:
%potCount = Pots.getCount();
if(%potCount > 0) {
messageClient(%col.client, 'MsgItemPickup', '\c0There are still %1 pots left to find.', %this.potCount);
return;
}
The line does execute and print to the HUD, however the actual count is omitted. Any suggestions as to why it won't add the count to the message? And I do have a datablock for this item, and the victory condition is executed when all of the items have been found, so I know it's counting, just not displaying.
Thanks in advance.
#2
%this.potCount = 0; when the player was created into the scene, but maybe that is the wrong place to put that?
Thank you very much again. *crosses fingers* =)
09/12/2008 (10:04 am)
Thank you very much for the feedback. I will certainly give this a try in a few minutes. I had set up %this.potCount = 0; when the player was created into the scene, but maybe that is the wrong place to put that?
Thank you very much again. *crosses fingers* =)
#3
Good luck :)
09/12/2008 (10:08 am)
It's a fine place to put it, but be aware that %this.potCount and %potCount are not the same variable. Even in a function that belongs to that object. To reference the potCount in %this, you must use %this.potCount. Good luck :)
#4
Thank you again for the help though. If you happen to think of anything else, please let me know. It may help me to pinpoint where the problem is. I do appreciate the help. =)
09/12/2008 (11:43 am)
I'm still getting the line printed out as, "There are still (space here) pots left to find.", without the count. I did try this and also with the variable at the end as well, but ended up with the same result. It's strange though, the logic seems to be correct. I'm going to look around to see if I can find anything else going on. It's probably something really minor and simple that I'm over looking.Thank you again for the help though. If you happen to think of anything else, please let me know. It may help me to pinpoint where the problem is. I do appreciate the help. =)
#5
09/12/2008 (12:18 pm)
It was actually something that I overlooked. You need to use double quotes to make strings combine. Use the example I gave, but use double quotes instead of single quotes.messageClient(%col.client, 'MsgItemPickup', "There are still" SPC %potCount SPC "left to find.")
#6
I literally did the jig when the message popped up correctly, hehe. I am grateful for the help. This has been a little issue I've been tinkering with for nearly 5 weeks, and I'm so glad that it's alright now.
You've made my day today, thank you again!
09/12/2008 (12:29 pm)
That was it! THANK YOU VERY MUCH!! I literally did the jig when the message popped up correctly, hehe. I am grateful for the help. This has been a little issue I've been tinkering with for nearly 5 weeks, and I'm so glad that it's alright now.
You've made my day today, thank you again!
#7
I'll admit. I also do jigs when I figure out a problem that's been bugging me for a long time. I will sometimes even dance around my house. My wife is so used to it, she'll get up and dance with me.
Glad I could help :)
09/12/2008 (12:51 pm)
Quote:
I literally did the jig when the message popped up correctly, hehe.
I'll admit. I also do jigs when I figure out a problem that's been bugging me for a long time. I will sometimes even dance around my house. My wife is so used to it, she'll get up and dance with me.
Glad I could help :)
#8
09/12/2008 (1:08 pm)
Haha! My husband thinks I'm nuts when I suddenly jump up and dance around the house, but I know what you mean - it is a well deserved stress reliever. I knew the problem was going to be something very simple that I was overlooking. I'm glad you were here to help point that out. I've only been using TGE for about six weeks now, but I'm sure with more practice I will get better. I've never programmed using scripts like this before, so it's been an adventure!
#9
Keep going in Script. You'll learn to love it if you don't already. I love the adventures I have with Torque :)
09/12/2008 (1:16 pm)
I'm glad I'm not the only one. :)Keep going in Script. You'll learn to love it if you don't already. I love the adventures I have with Torque :)
Torque 3D Owner Avid Gamer
try
or if the function does work like format() just change %this.potCount to %potCount.
*SPC is a keyword in TorqueScript that injects a space into a string it is combining. @ is another keyword (keycharacter?) that simply combines the strings without a space.