Page 1 of 2
Hud Draw - Using Variables to change an element
Posted: Tue Mar 22, 2005 5:59 pm
by Ski
I am kind of new at this level of scripting.
What I am trying to do is create a "push meter". What I would like it to do is change based on a trigger. The trigger will control spawn points and what shows on the hud.
All I have so far is the hud that I want to use for the start of the map. I do not know how to script in the variable part of the script to change it. I would apperciate any help you all have to offer.
I want to change the loadingbar shader.
Here is what I have:
huddraw:
while (1)
{
huddraw_alpha 25 1
huddraw_align 25 left bottom
huddraw_rect 25 298 -110 180 16
huddraw_shader 25 "textures/hud/healthmeter"
huddraw_alpha 26 1
huddraw_align 26 left bottom
huddraw_rect 26 298 -110 90 16
huddraw_shader 26 "textures/mohmenu/loadingbar"
huddraw_alpha 27 1
huddraw_align 27 left bottom
huddraw_rect 27 296 -110 185 18
huddraw_shader 27 "textures/mohmenu/loadingbar_border"
huddraw_alpha 28 1
huddraw_align 28 center
huddraw_font 28 "facfont-20"
huddraw_color 28 0.70 0.60 0.05
huddraw_rect 28 -95 200 100 20
huddraw_string 28 "Axis"
huddraw_alpha 29 1
huddraw_align 29 center
huddraw_font 29 "facfont-20"
huddraw_color 29 0.70 0.60 0.05
huddraw_rect 29 140 200 100 20
huddraw_string 29 "Allies"
huddraw_alpha 30 1
huddraw_align 30 center
huddraw_font 30 "facfont-20"
huddraw_color 30 0 1 0
huddraw_rect 30 0 180 100 20
huddraw_string 30 "Push Meter"
wait 1
}
end
It puts my push meter on the screen, but now I need to figure out how to change it.
Thanks
Ski
Posted: Tue Mar 22, 2005 6:18 pm
by jv_map
You can use huddraw_shader with any variable for index and shader... what exactly is your problem?
Posted: Tue Mar 22, 2005 6:47 pm
by Ski
Not sure what you mean.
Maybe I didn't explain it good enough. The script above just places my push meter on the screen at the start of the map like I want it....
But as triggers get activated I want to change the huddraw_rect size of the loadingbar shader... say for example the allies advance and set off a spawn trigger... I want the shader to become smaller... 298 -110 80 16 opposite if the axis advance... 298 -110 100 16 it would become bigger.
I don't know how to setup a variable to do this.
My thought is something like the health bar does when you get shot... and then goes back when you pick up health.
But I have no clue how to set it up to work with a variable.
Thanks
Ski
Posted: Tue Mar 22, 2005 9:13 pm
by wacko
well, in ur script there ought to be a thread where the spawn points are reset. There u can set a variable level.barlength. It could be done by something like
Code: Select all
if (allies get further) //this is no working code of course
{
local.alliedprogress++
}
if (axis get further) //this is no working code of course
{
local.alliedprogress--
}
level.barlength = 90 + local.alliedprogress * 10
The variable local.alliedprogress would be 0 on startup and would raise when allies progress and get negative when axis become better. Something like that... Anyway, this variable u can use in the huddraw command like
Code: Select all
huddraw_rect 26 298 -110 level.barlength 16
Posted: Tue Mar 22, 2005 11:18 pm
by Ski
Could I use triggers to change the level.barlength??
I have triggers to change the spawn points. Can I add a line to the spawn change thread to set level.barlength + 10 or something
Ski
Posted: Tue Mar 22, 2005 11:26 pm
by wacko
Ski wrote:Could I use triggers to change the level.barlength??
I have triggers to change the spawn points. Can I add a line to the spawn change thread to set level.barlength + 10 or something
Ski
yes sure. just give it a try, the script won't bite

Posted: Wed Mar 23, 2005 10:34 am
by Grassy
Yeah as Wacko says, the looping thread can keep an eye on your spawn triggers. Do the triggers need to determine the team a player belongs to if they touch it? I am assuming they are trigger_multiples...
Posted: Wed Mar 23, 2005 2:45 pm
by Ski
Yes the triggers do determine the players team.
for example: here is one of the triggers
Code: Select all
///Spawn Trigger 1.. allies pushing axis back - 1st change
local.trig = spawn trigger_multiple "targetname" "allies1"
local.trig.origin = ( 1216 -211 -255 ) // position it
local.trig setsize ( 0 -5 0) ( 1 50 200) // give it some size
local.trig setthread spawnchange1
local.trig wait 1
local.trig delay 0 // How long before trig acts
//this is the spawnchange1 thread
/// allies pushing axis back 1st change
spawnchange1:
local.player = parm.other
if ( local.player.dmteam=="allies" )
{
$allied1 disablespawn
$allied2 disablespawn
$allied3 disablespawn
$allied4 disablespawn
$allied5 disablespawn
$allied6 enablespawn
$allied7 enablespawn
$allied8 enablespawn
$allied9 enablespawn
$axis1 disablespawn
$axis2 disablespawn
$axis3 disablespawn
$axis4 disablespawn
$axis5 disablespawn
$axis6 enablespawn
$axis7 enablespawn
$axis8 enablespawn
$axis9 enablespawn
wait 1
}
end
But I am completely lost trying to get this Huddraw working right... everything I have tried bombs.
Ski
Posted: Wed Mar 23, 2005 8:00 pm
by wacko
I was thinking of something like:
Code: Select all
spawnchange1:
local.player = parm.other
if ( local.player.dmteam=="allies" )
{
local.alliedprogress++
for (local.i = 1; local.i <= 5; local.i++)
{
$("allied" + local.i) disablespawn
$("allied" + (local.i + 5)) enablespawn
$("axis" + local.i) disablespawn
$("axis" + (local.i + 5)) enablespawn
}
wait 1
}
if ( local.player.dmteam=="axis" )
{
local.alliedprogress--
for (local.i = 1; local.i <= 5; local.i++)
{
$("allied" + local.i) enablespawn
$("allied" + (local.i + 5)) disablespawn
$("axis" + local.i) enablespawn
$("axis" + (local.i + 5)) disablespawn
}
wait 1
}
level.barlength = 90 + local.alliedprogress * 10
end
huddraw:
...
huddraw_rect 26 298 -110 level.barlength 16
...
end
Dunno, though, whether this fits in ur script's logic, so take this just as an idea

.
Posted: Thu Mar 24, 2005 6:00 am
by Grassy
The first problem I see is the multiple triggering of the trigger by players either standing on the trigger, or more than one player running through the trigger. How would you stop invalid increments? Disable the trigger until the axis trigger is set off?
Posted: Thu Mar 24, 2005 3:50 pm
by Ski
I have about 12 triggers all over the map... 6 our allied triggers and 6 our axis triggers... Wacko Im not sure what you have will work... but I sure do appreaciate it. I think I maybe starting to get the idea of all of this... I would have to change all my triggers to use what you have... but if it works it will be worth the time. One question I have tho... If I am understanding this correctly the script disables the 1st 5 spawns and enables all spawns after number 5, or is it enabling the next 5 spawns??? so after this is triggered spawns 6 thru 10 would work??
Thanks
Ski
Posted: Thu Mar 24, 2005 4:09 pm
by Ski
Wacko wrote:I was thinking of something like:
Code: Select all
spawnchange1:
local.player = parm.other
if ( local.player.dmteam=="allies" )
{
local.alliedprogress++
for (local.i = 1; local.i <= 5; local.i++)
{
$("allied" + local.i) disablespawn
$("allied" + (local.i + 5)) enablespawn
$("axis" + local.i) disablespawn
$("axis" + (local.i + 5)) enablespawn
}
wait 1
}
if ( local.player.dmteam=="axis" )
{
local.alliedprogress--
for (local.i = 1; local.i <= 5; local.i++)
{
$("allied" + local.i) enablespawn
$("allied" + (local.i + 5)) disablespawn
$("axis" + local.i) enablespawn
$("axis" + (local.i + 5)) disablespawn
}
wait 1
}
level.barlength = 90 + local.alliedprogress * 10
end
huddraw:
...
huddraw_rect 26 298 -110 level.barlength 16
...
end
Dunno, though, whether this fits in ur script's logic, so take this just as an idea

.
Well I tried to add the code above to my script just to test it out and the bar disappeared from the huddraw completly. When I activated the trigger it did not show either.
I tired to add the this line to the huddraw script...
level.barlength = 90 + local.alliedprogress * 10
like this
Code: Select all
huddraw:
while (1)
{
level.barlength = 90 + local.alliedprogress * 10
huddraw_alpha 25 1
huddraw_align 25 left bottom
huddraw_rect 25 298 -110 180 16
huddraw_shader 25 "textures/hud/healthmeter"
huddraw_alpha 26 1
huddraw_align 26 left bottom
huddraw_rect 26 298 -110 level.barlength 16
huddraw_shader 26 "textures/mohmenu/loadingbar"
huddraw_alpha 27 1
huddraw_align 27 left bottom
huddraw_rect 27 296 -110 185 18
huddraw_shader 27 "textures/mohmenu/loadingbar_border"
huddraw_alpha 28 1
huddraw_align 28 center
huddraw_font 28 "facfont-20"
huddraw_color 28 0.70 0.60 0.05
huddraw_rect 28 -95 200 100 20
huddraw_string 28 "Axis"
huddraw_alpha 29 1
huddraw_align 29 center
huddraw_font 29 "facfont-20"
huddraw_color 29 0.70 0.60 0.05
huddraw_rect 29 140 200 100 20
huddraw_string 29 "Allies"
huddraw_alpha 30 1
huddraw_align 30 center
huddraw_font 30 "facfont-20"
huddraw_color 30 0 1 0
huddraw_rect 30 0 180 100 20
huddraw_string 30 "Push Meter"
wait 1
}
end
But it did not work either... my thought was I needed to set the initial level.barlength in the hud so it would show before trigger acted.. but bar doesn't show. What's wrong with the huddraw portion of this??
Thanks
Ski
Posted: Thu Mar 24, 2005 6:40 pm
by wacko
I thought it to be like this:
Code: Select all
spawnchange1:
local.player = parm.other
if ( local.player.dmteam=="allies" )
{
local.alliedprogress++
for (local.i = 1; local.i <= 5; local.i++)
{
$("allied" + local.i) disablespawn
$("allied" + (local.i + 5)) enablespawn
$("axis" + local.i) disablespawn
$("axis" + (local.i + 5)) enablespawn
}
wait 1
}
if ( local.player.dmteam=="axis" )
{
local.alliedprogress--
for (local.i = 1; local.i <= 5; local.i++)
{
$("allied" + local.i) enablespawn
$("allied" + (local.i + 5)) disablespawn
$("axis" + local.i) enablespawn
$("axis" + (local.i + 5)) disablespawn
}
wait 1
}
level.barlength = 90 + local.alliedprogress * 10
end
huddraw:
while (1)
{
huddraw_alpha 25 1
huddraw_align 25 left bottom
huddraw_rect 25 298 -110 180 16
huddraw_shader 25 "textures/hud/healthmeter"
huddraw_alpha 26 1
huddraw_align 26 left bottom
huddraw_rect 26 298 -110 level.barlength 16
huddraw_shader 26 "textures/mohmenu/loadingbar"
huddraw_alpha 27 1
huddraw_align 27 left bottom
huddraw_rect 27 296 -110 185 18
huddraw_shader 27 "textures/mohmenu/loadingbar_border"
huddraw_alpha 28 1
huddraw_align 28 center
huddraw_font 28 "facfont-20"
huddraw_color 28 0.70 0.60 0.05
huddraw_rect 28 -95 200 100 20
huddraw_string 28 "Axis"
huddraw_alpha 29 1
huddraw_align 29 center
huddraw_font 29 "facfont-20"
huddraw_color 29 0.70 0.60 0.05
huddraw_rect 29 140 200 100 20
huddraw_string 29 "Allies"
huddraw_alpha 30 1
huddraw_align 30 center
huddraw_font 30 "facfont-20"
huddraw_color 30 0 1 0
huddraw_rect 30 0 180 100 20
huddraw_string 30 "Push Meter"
wait 1
}
end
But err I didn't test it, so there might be a typo
For ur 2nd try, I can tell u, that local.variable just works inside one thread, in another thread it would be 0 again. So u would have to change local.alliedprogress to level.alliedprogress to make it a variable accessible for all threads.
Posted: Thu Mar 24, 2005 9:49 pm
by Ski
Ok here is what I have now
For the Huddraw
Code: Select all
huddraw:
while (1)
{
local.viedisplay = level.alliedprogress * 10
local.barlength = 80 + local.viedisplay
huddraw_alpha 25 1
huddraw_align 25 left bottom
huddraw_rect 25 298 -110 180 16
huddraw_shader 25 "textures/hud/healthmeter"
huddraw_alpha 26 1
huddraw_align 26 left bottom
huddraw_rect 26 298 -110 local.barlength 16
huddraw_shader 26 "textures/mohmenu/loadingbar"
huddraw_alpha 27 1
huddraw_align 27 left bottom
huddraw_rect 27 296 -110 185 18
huddraw_shader 27 "textures/mohmenu/loadingbar_border"
huddraw_alpha 28 1
huddraw_align 28 center
huddraw_font 28 "facfont-20"
huddraw_color 28 0.70 0.60 0.05
huddraw_rect 28 -95 200 100 20
huddraw_string 28 "Axis"
huddraw_alpha 29 1
huddraw_align 29 center
huddraw_font 29 "facfont-20"
huddraw_color 29 0.70 0.60 0.05
huddraw_rect 29 140 200 100 20
huddraw_string 29 "Allies"
huddraw_alpha 30 1
huddraw_align 30 center
huddraw_font 30 "facfont-20"
huddraw_color 30 0 1 0
huddraw_rect 30 0 180 100 20
huddraw_string 30 "Push Meter"
wait 1
}
end
Which puts the meter up
In the spawns thread I added the line
level.alliedprogress = 1
to set it initally
Then in the spawntrigger1 I have this
Code: Select all
spawnchange1:
local.player = parm.other
if ( local.player.dmteam=="allies" )
{
level.alliedprogress++
for (local.i = 1; local.i <= 5; local.i++)
{
$("allied" + local.i) disablespawn
$("allied" + (local.i + 5)) enablespawn
$("axis" + local.i) disablespawn
$("axis" + (local.i + 5)) enablespawn
}
wait 1
}
if ( local.player.dmteam=="axis" )
{
level.alliedprogress--
for (local.i = 1; local.i <= 5; local.i++)
{
$("allied" + local.i) enablespawn
$("allied" + (local.i + 5)) disablespawn
$("axis" + local.i) enablespawn
$("axis" + (local.i + 5)) disablespawn
}
wait 1
}
end
With this setup I have the bar moving... but as someone previously pointed out as long as the trigger is being activated the bar keeps growing and growing.
1st question... how do I disable the trigger after it is activated once??
What I would like to do is take the thread above and break it apart.. take the 1st portion.. if allies trigger it moves the bar up and deactivates until the axis trigger is used... that in turn would turn the 1st trigger back on. Hope you know what I mean.... and can help me out.
Thanks
Ski
Posted: Thu Mar 24, 2005 9:54 pm
by Ski
Grassy wrote:The first problem I see is the multiple triggering of the trigger by players either standing on the trigger, or more than one player running through the trigger. How would you stop invalid increments? Disable the trigger until the axis trigger is set off?
Yes I think that is what I need to do... any suggestions??
Ski