Compare commits

...

3 Commits

Author SHA1 Message Date
mckaygerhard 95f3980694 Fix crashes with mobs below or above due division by zero
* removes a division by zero issue which returns nan for yaw
  in some places
2023-01-12 18:06:07 -04:00
mckaygerhard 8bdf40b849 allow both flours from farming plus and food to be accepted for bowl
* this happened in the bowl and flour quest/task
2023-01-12 17:43:05 -04:00
mckaygerhard b2feac105a Fix crash when using chat commands affect/removeaffects
* related to pull request https://github.com/Bremaweb/adventuretest/pull/38
* related to pull request https://codeberg.org/minenux/minetest-game-adventuretest/pulls/38
* related to pull request #38
2023-01-12 17:38:59 -04:00
4 changed files with 39 additions and 7 deletions

View File

@ -5,7 +5,9 @@ minetest.register_chatcommand("affect",{
privs = {affects=true},
func = function (name, param)
local aname, affectid = string.match(param, "([^ ]+) (.+)")
if ( affects.affectPlayer(aname,affectid) ) then
if ( aname == nil or aname == "" or affectid == nil or affectid == '' ) then
minetest.chat_send_player(name, "Syntax: affect <name> <affectid>")
elseif ( affects.affectPlayer(aname,affectid) ) then
minetest.chat_send_player(name,aname.." has been affected by "..affects._affects[affectid].name)
else
minetest.chat_send_player(name,"Unable to affect "..aname.." with "..affectid)

View File

@ -638,7 +638,14 @@ end
function mobs:face_pos(self,pos)
local s = self.object:getpos()
local vec = {x=pos.x-s.x, y=pos.y-s.y, z=pos.z-s.z}
local yaw = math.atan(vec.z/vec.x)+math.pi/2
local yaw = 0
if vec.x ~= 0 then
yaw=math.atan(vec.z/vec.x)+math.pi/2
else
if vec.z>0 then
yaw=math.pi
end
end
if self.drawtype == "side" then
yaw = yaw+(math.pi/2)
end

View File

@ -144,7 +144,14 @@ function mobs.on_step(self,dtime)
end
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
local yaw = math.atan(vec.z/vec.x)+math.pi/2
local yaw = 0
if vec.x ~= 0 then
yaw=math.atan(vec.z/vec.x)+math.pi/2
else
if vec.z>0 then
yaw=math.pi
end
end
if self.drawtype == "side" then
yaw = yaw+(math.pi/2)
end
@ -223,7 +230,13 @@ function mobs.on_step(self,dtime)
end
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
local yaw = math.atan(vec.z/vec.x)+math.pi/2
if vec.x ~= 0 then
yaw=math.atan(vec.z/vec.x)+math.pi/2
else
if vec.z>0 then
yaw=math.pi
end
end
if self.drawtype == "side" then
yaw = yaw+(math.pi/2)
end
@ -345,7 +358,13 @@ function mobs.on_step(self,dtime)
self.v_start = false
else
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
local yaw = math.atan(vec.z/vec.x)+math.pi/2
if vec.x ~= 0 then
yaw=math.atan(vec.z/vec.x)+math.pi/2
else
if vec.z>0 then
yaw=math.pi
end
end
if self.drawtype == "side" then
yaw = yaw+(math.pi/2)
end

View File

@ -3,8 +3,12 @@ quests.chest = {}
quests.chest.go = function(npc,player)
local inv = player:get_inventory()
local pos = npc.object:getpos()
if inv:contains_item("main","farming_plus:flour") and inv:contains_item("main","food:bowl") then
inv:remove_item("main","farming_plus:flour")
if (inv:contains_item("main","farming_plus:flour") or inv:contains_item("main","food:flour")) and inv:contains_item("main","food:bowl") then
if inv:contains_item("main","farming_plus:flour") then
inv:remove_item("main","farming_plus:flour")
else
inv:remove_item("main","food:flour")
end
inv:remove_item("main","food:bowl")
chat.local_chat(pos,"'Thank you very much, take this as a token of my appreciation!'",6)
local lp = player:getpos()