diff --git a/README.md b/README.md index 0157c9f..1df2ed7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # 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 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. diff --git a/init.lua b/init.lua index 1344919..7c1cd28 100644 --- a/init.lua +++ b/init.lua @@ -1,23 +1,10 @@ bounty = {} bounty.file = core.get_worldpath() .. '/bounty.txt' 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 --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) --end of example end @@ -46,6 +33,20 @@ bounty.save = function() 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) if bounty.data[player_name] then bounty.data[player_name] = bounty.data[player_name] + amount @@ -54,6 +55,7 @@ bounty.increase = function(player_name, amount) end bounty.save() bounty.notify(player_name, amount) + bounty.set_nametag_color(player_name) end bounty.decrease = function(player_name, amount) @@ -65,6 +67,7 @@ bounty.decrease = function(player_name, amount) end bounty.notify(player_name, -amount) bounty.save() + bounty.set_nametag_color(player_name) end bounty.register = function(player_name, amount)