npc changes, mapgen changes

master
D00Med 2017-01-03 19:44:24 +10:00
parent 0fa07d1f92
commit 356105cc9a
2 changed files with 16 additions and 0 deletions

View File

@ -1488,6 +1488,14 @@ minetest.register_on_generated(function(minp, maxp)
local pos = {x = grass[n].x, y = grass[n].y, z = grass[n].z }
if minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name == "air" then
minetest.place_schematic(pos, minetest.get_modpath("hyrule_mapgen").."/schematics/pine_village.mts", random, {}, true)
local obj = minetest.env:add_entity({x=pos.x+4, y=pos.y+7, z=pos.z+5}, "mobs_npc:shopkeeper")
local obj = minetest.env:add_entity({x=pos.x+6, y=pos.y+3, z=pos.z+18}, "mobs_npc:npc_custom")
local npc = obj:get_luaentity()
npc.text = "I'll give you something nice if you find me a 'red potion'"
npc.reward_text = "*slurp* Here you go"
npc.item = "bucket:bucket_empty"
npc.reward_item = "witchcraft:potion_red"
npc.zdir = -1
end
end
end

View File

@ -259,11 +259,19 @@ mobs:register_mob("mobs_npc:npc_custom", {
end,
on_rightclick = function(self, clicker)
local pos = self.object:getpos()
if self.reward_item ~= nil and clicker:get_wielded_item():get_name() == self.reward_item then
self.item_ready = true
end
if self.item ~= nil and not self.inactive then
local xdir = self.xdir or 0
local zdir = self.zdir or 0
if self.item_ready then
minetest.env:add_item({x=pos.x+xdir, y=pos.y, z=pos.z+zdir}, self.item)
self.inactive = true
if self.reward_text ~= nil then
minetest.chat_send_player(clicker:get_player_name(), self.reward_text)
end
end
end
if self.text ~= nil and not self.spoken then
minetest.chat_send_player(clicker:get_player_name(), self.text)