Author |
Topic: Ingame HUD |
r00t_ |
|
General Member Since: Dec 15, 2010 Posts: 51 Last: May 16, 2011 [view latest posts] |
|
|
|
liltc64 |
General Member Since: Feb 12, 2007 Posts: 906 Last: Oct 22, 2012 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Wednesday, Jan. 12, 2011 11:14 pm |
|
yes you could put a shader for a hud, but diffrent for a text.
Code: level.texthud = newHudElem();
level.texthud.x = 267;
level.texthud.y = 100;
level.texthud setText(game["text"]);
that will make a hud in the middle of your screen basicly with a text, but not done yet notice game["text"], you now have to make that hold a string.
Code: game["text"] = &"Hello I Am Your Text!";
precacheString(game["text"]);
now this would be different if you wanted a shader instead of, setText. you want setShader somthing like this
setShader("black", 640, 480);
the first perimeter is the Material Name the 2nd is Width and the 3rd is Height
but sadly does not end there yet for shaders, just like you had to do with the game["text"], you have to precache it. IMPORTANT: REMEMBER TO PRECACHE everything in your main function. so before any of your scripts basicly you want to precache it or else you will get an error.
now moving on the way to precache a shader is doing this.
precacheShader("black");
now keep in mind that White and Black are default shaders, but there are also plenty of default shaders but White and Black are used frequently and most the time already precached for you already. |
|
|
|
clanhelio |
General Member Since: Aug 30, 2008 Posts: 223 Last: Mar 24, 2011 [view latest posts] |
|
|
|
IzNoGoD |
General Member Since: Nov 29, 2008 Posts: 694 Last: Nov 10, 2012 [view latest posts] |
|
|
|
liltc64 |
General Member Since: Feb 12, 2007 Posts: 906 Last: Oct 22, 2012 [view latest posts] |
|
|
|
|
r00t_ |
|
General Member Since: Dec 15, 2010 Posts: 51 Last: May 16, 2011 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Tuesday, Jan. 18, 2011 12:03 am |
|
If i have a dynamic text i want to display, do i have to precache it everytime i change what the text is?
And, if i want to display the value of a variable in the text, how would i do it?
Like this?
Code: game["text"] = &"Money = " + self.money;
precacheString(game["text"]);
Or like this?
Code: game["text"] = &"Money = ", self.money;
precacheString(game["text"]); |
|
|
|
IzNoGoD |
General Member Since: Nov 29, 2008 Posts: 694 Last: Nov 10, 2012 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Tuesday, Jan. 18, 2011 12:57 am |
|
r00t_ writes...Quote: If i have a dynamic text i want to display, do i have to precache it everytime i change what the text is?
And, if i want to display the value of a variable in the text, how would i do it?
Like this?
Code: game["text"] = &"Money = " + self.money;
precacheString(game["text"]);
Or like this?
Code: game["text"] = &"Money = ", self.money;
precacheString(game["text"]);
Neither.
game["text"]=&"Money";
hud.label=game["money"];
hud.value=self.money;
(maybe it was setvalue... im not sure) |
|
|
|
liltc64 |
General Member Since: Feb 12, 2007 Posts: 906 Last: Oct 22, 2012 [view latest posts] |
|
|
|
|
r00t_ |
|
General Member Since: Dec 15, 2010 Posts: 51 Last: May 16, 2011 [view latest posts] |
|
|
Category: CoD2 Scripting Posted: Tuesday, Jan. 18, 2011 02:52 am |
|
IzNoGoD writes...Quote:
Neither.
game["text"]=&"Money";
hud.label=game["money"];
hud.value=self.money;
(maybe it was setvalue... im not sure)
I don't understand this at all.
All i want to do is make this appear on screen (somewhere in the lower left corner, for example):
YOU'RE MONEY: $500
And obviously have the 500 change when the player get's more money or loses money (the 500 would be a variable, obviously). If you already knew all this, then my bad, i just don't understand this explanation.. |
|
|
|
liltc64 |
General Member Since: Feb 12, 2007 Posts: 906 Last: Oct 22, 2012 [view latest posts] |
|
|
|
Category: CoD2 Scripting Posted: Tuesday, Jan. 18, 2011 07:08 am |
|
well first think... what is a hud? hud = heads up display. now what game modes that are in my reach that have huds? well all the gametype files have a hud, but for this instance you could look at the sd.gsc. now
Code: level.clock = newHudElem();
level.clock.horzAlign = "left";
level.clock.vertAlign = "top";
level.clock.x = 8;
level.clock.y = 2;
level.clock.font = "default";
level.clock.fontscale = 2;
level.clock setTimer(level.roundlength * 60);
that is what a hud looks like, this what shows the time limit on SD at the top left of your screen. now what iznogod showed you
Code: game["text"]=&"Money";
hud.label=game["text"];
now what you can do with that is.
Code: level.clock = newHudElem();
level.clock.horzAlign = "left";
level.clock.vertAlign = "top";
level.clock.x = 8;
level.clock.y = 2;
level.clock.font = "default";
level.clock.fontscale = 2;
level.label=game["text"]
level.clock setTimer(level.roundlength * 60);
and ofc Code: game["text"]=&"Money"; will go in your main() func. but what that code above will do is print the round length and a text saying Money. but you dont want setTimer you want to set an integer, wich self.money = int. so what you do is level.clock setValue(self.money); that way it will print how much money you have. but as well you want to look out for is
Code: level.clock = newHudElem();
ofc you want it to print what SELF has not level... so you want to change level.clock to self.clock (ps: you dont need to have it as clock you can change that to w.e) anyways that solves 1 problem to that. notice it says newHudElem(); that is only for level. for self. you want newClientHudElem(self); i hope this clears a few things up for you about huds. |
|
|
|