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

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

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

by MineYoshi » Thu May 12, 2016 01:22

Only i want to change the color, that don't be red, that be blue or a random color!
How i do that?
Happy new Year 2020: let's all aim finally for a clear vision of what we want to make of Minetest!
 

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

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

by Calinou » Thu May 12, 2016 07:39

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

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

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

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

by AiTechEye » Sat May 14, 2016 20:44

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 26 times
screenshot_20160514sssa_223918.png
(692.41 KiB) Downloaded 1 time
 

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

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

by ExeterDad » Sat May 14, 2016 23:14

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: 936
Joined: Tue Aug 05, 2014 14:09
Location: On earth
GitHub: Darcidride
IRC: Darcidride + MinetestForFun
In-game: Darcidride + MinetestForFun
 

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

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

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

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

by MineYoshi » Wed May 18, 2016 21:41

Yay!

For the positivism quotes!
Happy new Year 2020: let's all aim finally for a clear vision of what we want to make of Minetest!
 

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

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

by MineYoshi » Mon May 23, 2016 22:59

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?
Happy new Year 2020: let's all aim finally for a clear vision of what we want to make of Minetest!
 

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

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

by AiTechEye » Tue May 24, 2016 16:50

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
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 4 guests