81 lines
2.4 KiB
Lua
81 lines
2.4 KiB
Lua
--mobs_fallout v0.0.1
|
|
--maikerumine
|
|
--made for Extreme Survival game
|
|
|
|
--dofile(minetest.get_modpath("mobs_fallout").."/api.lua")
|
|
|
|
--CODING NOTES
|
|
|
|
--REF CODE FROM PMOBS by CProgrammerRU --https://github.com/CProgrammerRU/progress
|
|
--[[
|
|
-- right clicking with cooked meat will give npc more health
|
|
on_rightclick = function(self, clicker)
|
|
local item = clicker:get_wielded_item()
|
|
if item:get_name() == "mobs:meat" or item:get_name() == "farming:bread" then
|
|
local hp = self.object:get_hp()
|
|
if hp + 4 > self.hp_max then return end
|
|
if not minetest.setting_getbool("creative_mode") then
|
|
item:take_item()
|
|
clicker:set_wielded_item(item)
|
|
end
|
|
self.object:set_hp(hp+4)
|
|
|
|
|
|
-- right clicking with gold lump drops random item from mobs.npc_drops
|
|
elseif item:get_name() == "default:gold_lump" then
|
|
if not minetest.setting_getbool("creative_mode") then
|
|
item:take_item()
|
|
clicker:set_wielded_item(item)
|
|
end
|
|
local pos = self.object:getpos()
|
|
pos.y = pos.y + 0.5
|
|
minetest.add_item(pos, {name = mobs.npc_drops[math.random(1,#mobs.npc_drops)]})
|
|
else
|
|
if self.owner == "" then
|
|
self.owner = clicker:get_player_name()
|
|
else
|
|
local formspec = "size[8,4]"
|
|
formspec = formspec .. "textlist[2.85,0;2.1,0.5;dialog;What can I do for you?]"
|
|
formspec = formspec .. "button_exit[1,1;2,2;gfollow;follow]"
|
|
formspec = formspec .. "button_exit[5,1;2,2;gstand;stand]"
|
|
formspec = formspec .. "button_exit[0,2;4,4;gfandp;follow and protect]"
|
|
formspec = formspec .. "button_exit[4,2;4,4;gsandp;stand and protect]"
|
|
formspec = formspec .. "button_exit[1,2;2,2;ggohome; go home]"
|
|
formspec = formspec .. "button_exit[5,2;2,2;gsethome; sethome]"
|
|
minetest.show_formspec(clicker:get_player_name(), "order", formspec)
|
|
minetest.register_on_player_receive_fields(function(clicker, formname, fields)
|
|
if fields.gfollow then
|
|
self.order = "follow"
|
|
self.attacks_monsters = false
|
|
end
|
|
if fields.gstand then
|
|
self.order = "stand"
|
|
self.attacks_monsters = false
|
|
end
|
|
if fields.gfandp then
|
|
self.order = "follow"
|
|
self.attacks_monsters = true
|
|
end
|
|
if fields.gsandp then
|
|
self.order = "stand"
|
|
self.attacks_monsters = true
|
|
end
|
|
if fields.gsethome then
|
|
self.floats = self.object:getpos()
|
|
end
|
|
if fields.ggohome then
|
|
if self.floats then
|
|
self.order = "stand"
|
|
self.object:setpos(self.floats)
|
|
end
|
|
end
|
|
end)
|
|
|
|
end
|
|
end
|
|
end,
|
|
})
|
|
]]
|
|
|
|
|