Page 1 of 1

Adding a tint overlay (fade user message?) on player's screen

Posted: Tue Jun 30, 2015 9:35 pm
by Mahi
Say I want to make player's screen "bloody" by adding a red tint to it, how would this be done?

In eventscripts I would add a tint like so:

Code: Select all

es usermsg fade event_var(userid) 0 500 482 255 0 0 150

Posted: Tue Jun 30, 2015 10:32 pm
by satoon101
The Fade class has been a part of the messages package since its creation. I did test using the numbers you have, but I am receiving errors. So, I lowered the 500 and 482 down to 5 and 2, and it worked like a charm:

Syntax: Select all

from colors import RED
from events import Event
from messages import Fade
from players.helpers import index_from_userid

fade_message = Fade(duration=5, hold_time=2, color=RED.with_alpha(150))


@Event
def player_say(game_event):
fade_message.send(index_from_userid(game_event.get_int('userid')))

If you do not want any fade-in, fade-out, or modulate, do not pass any flags, as in the example above. If you wish to fade-out, use the following (fade-in and modulate are very similar):

Syntax: Select all

from colors import RED
from events import Event
from messages import Fade
from players.helpers import index_from_userid

fade_message = Fade(duration=5, hold_time=2, flags=Fade.FFADE_OUT, color=RED.with_alpha(150))


@Event
def player_say(game_event):
fade_message.send(index_from_userid(game_event.get_int('userid')))

Posted: Tue Jun 30, 2015 10:43 pm
by Mahi
satoon101 wrote:The Fade class has been a part of the messages package since its creation. I did test using the numbers you have, but I am receiving errors. So, I lowered the 500 and 482 down to 5 and 2, and it worked like a charm:

Syntax: Select all

from colors import RED
from events import Event
from messages import Fade
from players.helpers import index_from_userid

fade_message = Fade(duration=5, hold_time=2, color=RED.with_alpha(150))


@Event
def player_say(game_event):
fade_message.send(index_from_userid(game_event.get_int('userid')))

If you do not want any fade-in, fade-out, or modulate, do not pass any flags, as in the example above. If you wish to fade-out, use the following (fade-in and modulate are very similar):

Syntax: Select all

from colors import RED
from events import Event
from messages import Fade
from players.helpers import index_from_userid

fade_message = Fade(duration=5, hold_time=2, flags=Fade.FFADE_OUT, color=RED.with_alpha(150))


@Event
def player_say(game_event):
fade_message.send(index_from_userid(game_event.get_int('userid')))
Ah, didn't find the Fade class with GitHub's search function, must've failed something cause I find it now... But thank you very much, looks awesome! :)

Posted: Wed Jul 01, 2015 6:35 pm
by BackRaw