Game Development Community

Help with hud tutorial

by Scott Schaefer · in Torque Game Engine · 12/17/2001 (6:00 pm) · 8 replies

I must be the lone idiot with the questions ;)

I've been trying to figure out this ammo hud tutorial for two evenings now, with pathetically little results. It is helping me figure out how the engine works though :)

Anyway, I have the latest HEAD version and no real bug issues.

I can get the green box on my screen and get it to save in the playgui so when i restart it is still there. There is nothing in it though.

I think i'm doing something wrong with the gui editor.

BTW Is "guitextctrl" and "guimltextcontrol" the same thing?

I'm stumped......

Damn newbies, anyway.

Scott

#1
12/17/2001 (6:25 pm)
Newbies are welcome. We all started once.

No, the two controls you mentioned are different. You need to use the GuiTextCtrl to get the desired results.

I tried the tutorial yesterday and got it to work pretty easily. One cheat I used was to actually cut and paste the code directly from the examples to where they belong. I used Tribal IDE as an editor. It's faster and I'm a lousy typist. I've got a bad habit of getting in all the letters but getting the order wrong. And I don't like straining for the brackets and parentheses.
#2
12/18/2001 (2:37 am)
Check your console (hit ') and see if you are getting any errors when the code is called.
#3
12/18/2001 (10:03 pm)
thanks guys...

in the console i got a syntax error for this line (which happens to be line 81 of fps\server\scripts\weapon.cs).


function Ammo::onInventory(%this,%obj,%amount)


I also enjoy lazyness of tribal ide and "tutorial cut-n-paste" as long as i at least partially understand why
This line was a direct "rip" using this highly controversial technique :)

I just don't have the experience to spot the error here.
I'm still in the process of reading forums on this, but come on, who doesn't like shortcuts?

Scott
#4
12/19/2001 (3:09 am)
Post all of that function in here...some times it doesn't get the line the error is on correct.
#5
12/19/2001 (5:40 am)
Also be sure that the function above it has a matching number of brackets. Many times the culprit is the line above the one you are looking at.
#6
12/19/2001 (6:14 pm)
Okay i got it...

I really appreciated the help you guys and i'll post my solution so other fools like me who might run into this scripting 101 problem....

This is a step (from the tutorial) word for word:

then change the body of function WeaponImage::onMount(%this,%obj,%slot) to look like this:

// Images assume a false ammo state on load. We need to
// set the state according to the current inventory.
if (%obj.getInventory(%this.ammo)) {

%obj.setImageAmmo(%slot,true);
%currentAmmo = %obj.getInventory(%this.ammo);

} else {
%currentAmmo = 0;
}

%obj.client.setAmmoAmountHud(%currentAmmo);


I guess to all but the wettest behind the ears this would be simple. But some people might benefit from knowing you have to put a set of these brackets { and } around the whole body of the function as well. It is not shown with them is this example,yet in other examples in the same tutorial they exist. Trust me Tim, i'm not bitchin', i love the tutorial and thanks for the help, but i am rock solid proof some people need guidance through even the easiest of tasks.. :)

Thank you David and Tim for all of your help and of course the most excellent tutorial. The ammo hud is up and running and ready to be customized. Now it's time for the next tutorial ;)

Baby Steps....

Scott Schaefer
#7
12/19/2001 (8:09 pm)
Ahh...i didn't even think about that happening to someone...i guess I assumed they knew scripting since I said change the contents and all functions have to have {}...sorry about that.

-Tim aka Spock
#8
12/20/2001 (6:54 pm)
Actually, I think what happened was some data corruption when using the "controvesial" cut and paste method. :)

I think when i pasted the function i pasted over the end bracket.

I was learning how to use Max Payne's scripting when I stumbled upon the TGE. and sometimes i try to learn too much at once, and make stupid obvious mistakes.

Now i'm going to try the inventory tutorial!

Scott

BTW you were right on with your plan. These ARE the tutorials a lot of us want..

Thanks again