]> git.lizzy.rs Git - Crafter.git/commitdiff
Add in damage color texture modifier to mob api
authoroilboi <47129783+oilboi@users.noreply.github.com>
Tue, 19 May 2020 14:57:19 +0000 (10:57 -0400)
committeroilboi <47129783+oilboi@users.noreply.github.com>
Tue, 19 May 2020 14:57:19 +0000 (10:57 -0400)
mods/mob/api/api_hook.lua
mods/mob/api/interaction.lua
mods/mob/init.lua

index a0017c4e93daf50dd91039d38a9b47a1144d8bd8..2ceaef7ac192e371e908e74bf41e184432850fd4 100644 (file)
@@ -108,6 +108,7 @@ mob_register.die_in_light_level = def.die_in_light_level
 
 mob_register.current_animation = 0
 mob_register.hurt_color_timer = 0
+mob_register.damage_color = def.damage_color or "red"
 
 mob_register.mob = true
 
index f276aefaa77b429291193a3e04de0b01819d7604..e2dbfdcd1afb80579564b7ecf5c7281b6bd0cecd 100644 (file)
@@ -109,7 +109,7 @@ mobs.create_interaction_functions = function(def,mob_register)
                local hp = hp-hurt
 
                if (self.punched_timer <= 0 and hp > 1) and not self.dead then
-                       self.object:set_texture_mod("^[colorize:red:130")
+                       self.object:set_texture_mod("^[colorize:"..self.damage_color..":130")
                        self.hurt_color_timer = 0.25
                        if puncher ~= self.object then
                                self.punched_timer = 0.8
@@ -148,7 +148,7 @@ mobs.create_interaction_functions = function(def,mob_register)
                        self.object:add_velocity(dir)
                        self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir)
                elseif (self.punched_timer <= 0 and self.death_animation_timer == 0) then
-                       self.object:set_texture_mod("^[colorize:red:130")
+                       self.object:set_texture_mod("^[colorize:"..self.damage_color..":130")
                        self.hurt_color_timer = 0.25
                        if puncher ~= self.object then
                                self.punched_timer = 0.8
index 92479360debf11aaeb96d153c8953aed8973b3b6..3539599c6e2a6ca56c5538450a9902584f67ce4f 100644 (file)
@@ -445,6 +445,8 @@ mobs.register_mob(
         state = 0,
         view_distance = 20,
         item_drop = "mob:cooked_porkchop",
+
+        damage_color = "blue",
          
         standing_frame = {x=0,y=0},
         moving_frame = {x=0,y=40},