WellDoneSnake
Yoko Shimomura
Hi guys,
TL;DR
I made a script that awards players (who have a certain amount of rings) with an item. I wanted to have an extra visual cue that shows what item the player has received in the form if an icon to the top right corner of the screen.
However my knowledge of Lua scripting is limited at the moment. I'd like to know if there is a way to make this new HUD disappear after a few seconds in a fading like manner.
Extra questions:
- Is there a way to assign custom HUDs to the "hud.enable/hud.disable" functions?
- Can custom images HUDs disappear at all? (After being called forth. *Excluding mapload/mapchange*)
- Can you change the visibility of a custom HUD after it has already been set to have a visibility? E.g. If a custom HUD is already opaque once loaded, can it be made translucent via video flags.
--------------------------------------------------
Codes
--------------------------------------------------
*The emblem sound is placeholder, I thought it'd be nice to hear that you "something" as well.*
I've recently started to learn Lua and have been fiddling with other Lua scripts from releases in order to help me learn more about the programming language.
A few days ago I created a script that awards players who have a certain amount of rings on them (for example, if the player has less than 15 rings on them, they shall be rewarded with +10 rings upon touching a starpost).
*I used the starpost script from FuriousFox's "Bonus Stage wad" as a template*
Next I decided that the player should be given a visual cue for what they have been awarded with, upon touching a starpost.
I decided that I'll mimic the effect of the visual cue seen in the "Shadow the Hedgehog" video game when touching a checkpoint: 'where the item icon is displayed for a brief moment before fading away'.
As seen here (0:30 to 0:34).
After learning about drawing HUDs from Monster psychic cat's tutorial, I added a script that would show an icon which corresponds with the award that the player received after touching the starpost.
That's when I bumped into a dilemma.
I could make the visual cue appear but I couldn't think of a way to make it disappear soon after.
Because of this I spent quite some time trying to experiment with different functions, flags, etc. that I read about from SRB2's wiki pages.
But I had no luck, after taking a look at the "timer" scripts in FuriousFox's Bonus Stage wad and Inuyasha's "lua adventure items wad", I decided I would try to create a similar timer to those two scripts.
But unfortunately my knowledge on custom timers isn't that great, and I am unsure of what conditions to set in order to end/stop the the visual cues' appearance.
A few days ago I created a script that awards players who have a certain amount of rings on them (for example, if the player has less than 15 rings on them, they shall be rewarded with +10 rings upon touching a starpost).
*I used the starpost script from FuriousFox's "Bonus Stage wad" as a template*
Next I decided that the player should be given a visual cue for what they have been awarded with, upon touching a starpost.
I decided that I'll mimic the effect of the visual cue seen in the "Shadow the Hedgehog" video game when touching a checkpoint: 'where the item icon is displayed for a brief moment before fading away'.
As seen here (0:30 to 0:34).
After learning about drawing HUDs from Monster psychic cat's tutorial, I added a script that would show an icon which corresponds with the award that the player received after touching the starpost.
That's when I bumped into a dilemma.
I could make the visual cue appear but I couldn't think of a way to make it disappear soon after.
Because of this I spent quite some time trying to experiment with different functions, flags, etc. that I read about from SRB2's wiki pages.
But I had no luck, after taking a look at the "timer" scripts in FuriousFox's Bonus Stage wad and Inuyasha's "lua adventure items wad", I decided I would try to create a similar timer to those two scripts.
But unfortunately my knowledge on custom timers isn't that great, and I am unsure of what conditions to set in order to end/stop the the visual cues' appearance.
TL;DR
I made a script that awards players (who have a certain amount of rings) with an item. I wanted to have an extra visual cue that shows what item the player has received in the form if an icon to the top right corner of the screen.
However my knowledge of Lua scripting is limited at the moment. I'd like to know if there is a way to make this new HUD disappear after a few seconds in a fading like manner.
Extra questions:
- Is there a way to assign custom HUDs to the "hud.enable/hud.disable" functions?
- Can custom images HUDs disappear at all? (After being called forth. *Excluding mapload/mapchange*)
- Can you change the visibility of a custom HUD after it has already been set to have a visibility? E.g. If a custom HUD is already opaque once loaded, can it be made translucent via video flags.
--------------------------------------------------
Codes
--------------------------------------------------
1) 0 to 14 rings = +10 rings 2) 15 to 39 rings = +20 rings 3) 40 to 59 rings = whirlwind shield 4) 60+ rings = forcefield shield
Code:
local function ItemReward(giver, receiver)
if receiver.health <= 15 and receiver.player.starpostnum < giver.health
P_GivePlayerRings(receiver.player, 10)
S_StartSound(receiver.origin, 153, receiver.player)
elseif receiver.health > 15 and receiver.player.starpostnum < giver.health
and receiver.health <= 40
P_GivePlayerRings(receiver.player, 20)
S_StartSound(receiver.origin, 153, receiver.player)
elseif receiver.health > 40 and receiver.player.starpostnum < giver.health
and receiver.health <= 60 and receiver.player.powers[pw_shield] == SH_NONE
receiver.player.powers[pw_shield] = SH_JUMP
P_SpawnShieldOrb(receiver.player)
S_StartSound(receiver.origin, 153, receiver.player)
elseif receiver.health > 60 and receiver.player.starpostnum < giver.health
and receiver.player.powers[pw_shield] == SH_NONE
receiver.player.powers[pw_shield] = SH_FORCE|1
P_SpawnShieldOrb(receiver.player)
S_StartSound(receiver.origin, 153, receiver.player)
end
end
addHook("TouchSpecial", ItemReward, MT_STARPOST)
Same as the first if statement in the example above but the visual effect that I want to occur, happens:
Code:
local function ItemReward(giver, receiver)
if receiver.health < 15 and receiver.player.starpostnum < giver.health
P_GivePlayerRings(receiver.player, 10)
S_StartSound(receiver.origin, 153, receiver.player)
local function giftdraw(v, stplyr)
if stplyr.mo
v.draw(304, 23, v.cachePatch("SRBXB0"))
end
end
hud.add(giftdraw)
end
end
addHook("TouchSpecial", ItemReward, MT_STARPOST)