Added colored nametags
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
# bounty
|
# bounty
|
||||||
|
|
||||||
|
Fork of [csirolli/luanti_bounty_mod](https://codeberg.org/csirolli/luanti_bounty_mod) with stylized nametags.
|
||||||
|
|
||||||
Bounty mod for MTG. Originally written by **Bas808** in May of 2014, modified by CSirolli in May of 2018. My GitHub repo was lost, so I had to start over in December of 2024. Original concept and code can be found here: https://forum.minetest.net/viewtopic.php?f=9&t=9355
|
Bounty mod for MTG. Originally written by **Bas808** in May of 2014, modified by CSirolli in May of 2018. My GitHub repo was lost, so I had to start over in December of 2024. Original concept and code can be found here: https://forum.minetest.net/viewtopic.php?f=9&t=9355
|
||||||
|
|
||||||
This mod can be used for placing bounties on players. Bounties are placed or removed in increments of 20 points. If a player with a bounty is killed, that player drops a reward, which the killer can collect.
|
This mod can be used for placing bounties on players. Bounties are placed or removed in increments of 20 points. If a player with a bounty is killed, that player drops a reward, which the killer can collect.
|
||||||
|
|||||||
31
init.lua
31
init.lua
@@ -1,23 +1,10 @@
|
|||||||
bounty = {}
|
bounty = {}
|
||||||
bounty.file = core.get_worldpath() .. '/bounty.txt'
|
bounty.file = core.get_worldpath() .. '/bounty.txt'
|
||||||
bounty.data = {}
|
bounty.data = {}
|
||||||
--bounty.prizes = false --determines if prizes or amount per points game-mechanic is used
|
|
||||||
if false then
|
|
||||||
bounty.prizes = 'default:steel_ingot'
|
|
||||||
bounty.points_per_prize = 100 --per 100 points you get a default:steel_ingot
|
|
||||||
else
|
|
||||||
bounty.prizes = {
|
|
||||||
[20] = 'default:wood 50', -- for bounties that are higher then 100 iron ingots are given
|
|
||||||
[50] = 'default:cobble 50', -- for bounties that are higher then 150 gold ingots are given
|
|
||||||
[70] = 'default:stone 40', -- for bounties that are higher then 150 gold ingots are given
|
|
||||||
[100] = 'default:steel_ingot 2', -- for bounties that are higher then 150 gold ingots are given
|
|
||||||
[200] = 'default:steel_ingot 5' -- etc...
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
bounty.penalize = function(player_name) --set the penalty
|
bounty.penalize = function(player_name) --set the penalty
|
||||||
--example of a penalty (revoke all privs ecept interact)
|
--example of a penalty (revoke all privs ecept interact)
|
||||||
core.set_player_privs(player_name, { shout = true })
|
--core.set_player_privs(player_name, { shout = true })
|
||||||
bounty.unregister(player_name)
|
bounty.unregister(player_name)
|
||||||
--end of example
|
--end of example
|
||||||
end
|
end
|
||||||
@@ -46,6 +33,20 @@ bounty.save = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
bounty.set_nametag_color = function(player_name)
|
||||||
|
local player = minetest.get_player_by_name(player_name)
|
||||||
|
local props = player:get_properties()
|
||||||
|
if bounty.data[player_name] > 100 then
|
||||||
|
player:set_properties({ nametag_color = "#ff0000" })
|
||||||
|
elseif bounty.data[player_name] > 50 then
|
||||||
|
player:set_properties({ nametag_color = "#ffa500" })
|
||||||
|
elseif bounty.data[player_name] > 0 then
|
||||||
|
player:set_properties({ nametag_color = "#ffff00" })
|
||||||
|
else
|
||||||
|
player:set_properties({ nametag_color = "#00ff00" })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
bounty.increase = function(player_name, amount)
|
bounty.increase = function(player_name, amount)
|
||||||
if bounty.data[player_name] then
|
if bounty.data[player_name] then
|
||||||
bounty.data[player_name] = bounty.data[player_name] + amount
|
bounty.data[player_name] = bounty.data[player_name] + amount
|
||||||
@@ -54,6 +55,7 @@ bounty.increase = function(player_name, amount)
|
|||||||
end
|
end
|
||||||
bounty.save()
|
bounty.save()
|
||||||
bounty.notify(player_name, amount)
|
bounty.notify(player_name, amount)
|
||||||
|
bounty.set_nametag_color(player_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
bounty.decrease = function(player_name, amount)
|
bounty.decrease = function(player_name, amount)
|
||||||
@@ -65,6 +67,7 @@ bounty.decrease = function(player_name, amount)
|
|||||||
end
|
end
|
||||||
bounty.notify(player_name, -amount)
|
bounty.notify(player_name, -amount)
|
||||||
bounty.save()
|
bounty.save()
|
||||||
|
bounty.set_nametag_color(player_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
bounty.register = function(player_name, amount)
|
bounty.register = function(player_name, amount)
|
||||||
|
|||||||
Reference in New Issue
Block a user