How i make when a tool hurt me, my screen turns blue?

Post Reply
User avatar
MineYoshi
Member
Posts: 5373
Joined: Wed Jul 08, 2015 13:20
Contact:

How i make when a tool hurt me, my screen turns blue?

by MineYoshi » Post

Only i want to change the color, that don't be red, that be blue or a random color!
How i do that?
Oi

User avatar
Calinou
Moderator
Posts: 3164
Joined: Mon Aug 01, 2011 14:26
GitHub: Calinou
IRC: Calinou
In-game: Calinou
Location: Troyes, France
Contact:

Re: How i make when a tool hurt me, my screen turns blue?

by Calinou » Post

Changing the hurt flash color/effect is currently not possible without modifying the engine.

User avatar
azekill_DIABLO
Member
Posts: 7497
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: How i make when a tool hurt me, my screen turns blue?

by azekill_DIABLO » Post

*cries*

User avatar
AiTechEye
Member
Posts: 861
Joined: Fri May 29, 2015 21:14
GitHub: AiTechEye
Location: ¯\_(ツ)_/¯

Re: How i make when a tool hurt me, my screen turns blue?

by AiTechEye » Post

Like this?

it replacing the red flash effect with randomly colors

Image

Code: Select all

minetest.register_on_player_hpchange(function(player, hp_change)
	if hp_change<0 then

		local name=player:get_player_name()
		minetest.after(0, function(name,player)
			local r,g,b=screencolor.rndhexcolor(),screencolor.rndhexcolor(),screencolor.rndhexcolor()

			screencolor.user[name]=player:hud_add({
				hud_elem_type = "image",
				text ="screencolor_scr.png^[colorize:#" .. r .. g .. b .. "aa",
				name = "rndcsc",
				scale = {x=-100, y=-100},
				position = {x=0, y=0},
				alignment = {x=1, y=1},
			})

		end,name,player)
		minetest.after(0.8, function(name,player)
			player:hud_remove(screencolor.user[name])
			screencolor.user[name]=nil
		end,name,player)
	end

end)


screencolor={user={}}

--screencolor.user[name] then id is stored as a global var if you want to use it to somthing


function screencolor.rndhexcolor()
	local a="0123456789ABCDEF"
	local a1=math.random(1,16)
	local a2=math.random(1,16)
	return string.sub(a,a1,a1) .. string.sub(a,a2,a2)
end
Attachments
screencolors.zip
(995 Bytes) Downloaded 28 times
screenshot_20160514sssa_223918.png
(692.41 KiB) Downloaded 1 time

User avatar
ExeterDad
Member
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A

Re: How i make when a tool hurt me, my screen turns blue?

by ExeterDad » Post

UjEdwin wrote:Like this?

it replacing the red flash effect with randomly colors[/code]
I am totally saving that snippet for later! Awesome!

User avatar
Minetestforfun
Member
Posts: 940
Joined: Tue Aug 05, 2014 14:09
GitHub: MinetestForFun
IRC: MinetestForFun
In-game: MinetestForFun
Location: On earth
Contact:

Re: How i make when a tool hurt me, my screen turns blue?

by Minetestforfun » Post

@UjEdwin
Exellent idea, thank you for the tip !

User avatar
AiTechEye
Member
Posts: 861
Joined: Fri May 29, 2015 21:14
GitHub: AiTechEye
Location: ¯\_(ツ)_/¯

Re: How i make when a tool hurt me, my screen turns blue?

by AiTechEye » Post

many things is possible in minetest, even people dont know it :-)

User avatar
azekill_DIABLO
Member
Posts: 7497
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: How i make when a tool hurt me, my screen turns blue?

by azekill_DIABLO » Post

UjEdwin wrote:many things is possible in minetest, even people dont know it :-)
this is true ;)

User avatar
MineYoshi
Member
Posts: 5373
Joined: Wed Jul 08, 2015 13:20
Contact:

Re: How i make when a tool hurt me, my screen turns blue?

by MineYoshi » Post

Yay!

For the positivism quotes!
Oi

User avatar
MineYoshi
Member
Posts: 5373
Joined: Wed Jul 08, 2015 13:20
Contact:

Re: How i make when a tool hurt me, my screen turns blue?

by MineYoshi » Post

A question, how to make exactly white?

I mean if you can setup what color turns the screen when you are in lava, how you can't do it with a tool?
Oi

User avatar
AiTechEye
Member
Posts: 861
Joined: Fri May 29, 2015 21:14
GitHub: AiTechEye
Location: ¯\_(ツ)_/¯

Re: How i make when a tool hurt me, my screen turns blue?

by AiTechEye » Post

you can do it with everything that works with the code :-)

the screencolor.rndhexcolor() makes a random code (0 to F)

image.png^add_effect_or_image

How hex/colors works:
the last 6 numbers is replaced with letters
0.1.2.3.4.5.6.7.8.9.10.11.12.13.14.15
0.1.2.3.4.5.6.7.8.9..A..B...C...D..E..F

so 3E = 3*14

red,green,blue,alpha
NN.NN.NN.NN
......................red....green...blue....alpha
3EFFBCFF = 3*14, 15*15,11*12, 15*15
so FFFFFFFF = full,full,full,ful = 100% white

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests