Skip to content

Commit

Permalink
support classes with a few mods
Browse files Browse the repository at this point in the history
  • Loading branch information
Elkien3 committed Dec 10, 2022
1 parent e49ee56 commit 03c41a6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 5 deletions.
8 changes: 8 additions & 0 deletions mods/cars/welding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ local welderdef = {
minetest.chat_send_player(name, "Only Police CEO and those with 'give' priv can make police cars.")
return
end
if class_get and not class_get(name, "machinist") and carname ~= "cars:police_sedan" then
minetest.chat_send_player(name, "Only machinists can craft cars")
return
end
worldedit.set(vector.subtract(nodepos, offset), vector.add(vector.subtract(nodepos, offset), size), "air")
local ent = minetest.add_entity(vector.add(vector.subtract(nodepos, offset), vector.multiply(size, .5)), carname, user:get_player_name())
ent:setyaw(minetest.dir_to_yaw(minetest.facedir_to_dir(node.param2))-math.pi)
Expand All @@ -68,6 +72,10 @@ local welderdef = {
local obj = pointed_thing.ref
if not obj or not obj:get_armor_groups().vehicle then return itemstack end
if obj:get_hp() >= obj:get_properties().hp_max then return itemstack end--todo add reassembling repair and only allow welding for hp above 50%
if class_get and not class_get(name, "machinist") and obj:get_hp() >= obj:get_properties().hp_max/2 then--only allow machinist to completly repair cars.
minetest.chat_send_player(name, "Only machinists can repair cars above 50%")
return
end
if default.player_attached[name] then return itemstack end
if cooldowns[name] then return itemstack end

Expand Down
4 changes: 2 additions & 2 deletions mods/farming/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ end


-- Growth Logic
local STAGE_LENGTH_AVG = 72000
local STAGE_LENGTH_AVG = 57600
local STAGE_LENGTH_AVG_ORIGINAL = STAGE_LENGTH_AVG
local STAGE_LENGTH_DEV = STAGE_LENGTH_AVG*.8
function farming_setspeed(factor)
Expand Down Expand Up @@ -468,7 +468,7 @@ end

-- Place Seeds on Soil
function farming.place_seed(itemstack, placer, pointed_thing, plantname)

if class_get and placer and player:get_player_name() and not class_get(player:get_player_name(), "farmer") then return end
local pt = pointed_thing

-- check if pointing at a node
Expand Down
8 changes: 7 additions & 1 deletion mods/hbhunger/hunger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,13 @@ function hbhunger.handle_node_actions(pos, oldnode, player, ext)
new = hbhunger.EXHAUST_MOVE
end
exhaus = exhaus + new
if exhaus > hbhunger.EXHAUST_LVL then
local exhaus_lvl
if class_get and class_get(name, "unclassed") then
exhaus_lvl = hbhunger.EXHAUST_LVL*1.5
else
exhaus_lvl = hbhunger.EXHAUST_LVL
end
if exhaus > exhaus_lvl then
exhaus = 0
local h = tonumber(hbhunger.hunger[name])
h = h - 1
Expand Down
6 changes: 5 additions & 1 deletion mods/hbhunger/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ minetest.register_globalstep(function(dtime)
-- lower satiation by 1 point after xx seconds
if timer2 > hbhunger.HUNGER_TICK then
if h > 0 then
h = h-1
if class_get and class_get(name, "unclassed") then
h = h-.75
else
h = h-1
end
hbhunger.hunger[name] = h
hbhunger.set_hunger_raw(player)
end
Expand Down
3 changes: 3 additions & 0 deletions mods/lockpicks/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ local newchestrightclick = function(pos, node, clicker, itemstack, pointed_thing
and not (def and def.tool_capabilities and def.tool_capabilities.groupcaps and def.tool_capabilities.groupcaps.locked) then
return itemstack
end
if class_get and not default.can_interact_with_node(clicker, pos) and not class_get(clicker:get_player_name(), "snooper") then
return itemstack
end
name = "default:chest_locked"
sound_open = "default_chest_open"
sound_close = "default_chest_close"
Expand Down
2 changes: 1 addition & 1 deletion mods/mobs_redo/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4755,7 +4755,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)

self._breed_countdown = nil

if breed and self.hornytimer == 0 then
if breed and self.hornytimer == 0 and (not class_get or class_get(clicker:get_player_name(), "farmer")) then
self.horny = true
self.food = 4
end
Expand Down
3 changes: 3 additions & 0 deletions mods/playertools/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ minetest.register_chatcommand("grief_check", {
if not minetest.setting_getbool("enable_rollback_recording") then
return false, "Rollback functions are disabled."
end
if class_get and not class_get(clicker:get_player_name(), "snooper") then
return false, "Only snooper class can grief check"
end
local range, hours, limit =
param:match("(%d+) *(%d*) *(%d*)")
range = tonumber(range) or 0
Expand Down

0 comments on commit 03c41a6

Please sign in to comment.