### migration to mt 5.0/5.2 There are the issues Tignasse Verte mentionned: Adding `placer` in `register_functions.lua` (related commit for minenux are commit a996d5ac709446322d6c6261c21e5f0752a6aeeb ) and replacing the two occourances of `nodeupdate` with `minetest.check_for_falling`. Other changes are necessary because I changed (and had to change) quite a lot in `mg_villages` internally recently. If you want to get further with running the game under newer versions of MT, replace the versions of `cottages`, `handle_schematics` and `mg_villages` AdventureTest comes with with the newest versions. Then, remove the line `mg_villages.on_generated(minp,maxp,seed)` in `adventuretest/register_functions.lua`. This may have an impact on quests the old explorer is handling out, but if you ignore these for now, the world ought to be usable. Comment out the file/content of `mg/fill_chests.lua` for now as that requires a few adjustments for filling the chests with the right content, and that's a bit too much to write here in an inconvenient forum post. You won't see any villagers spawning because their spawn blocks are not placed. My first attempts there ended in a severe overcrowding of villagers. Needs finetuning/understanding what BrandonReese did to keep it balanced. But then, this seems to be an open issue on Github as well... Mobs will likely not work very well. A lot changed regarding them. They certainly could use an update as well - as could the goblins. I'm sure the witches from the same modder would feel welcome in the AdventureTest universe, too. ###### now the changes in fact: DFeniks wrote: 2020-01-07 10:02:08: ERROR[Main]: ServerError: AsyncErr: Lua: finishGenRuntime error from mod 'default' in callback item_OnPlace(): ...enturetest/mods/adventuretest/register_functions.lua:101: attempt to index local 'placer' (a nil value) Reason on server-side : Here are the changes made on server-side, concerning item_OnPlace, for the 5.X.X : https://dev.minetest.net/Changelog, 0.4.16 → 5.0.0 , Released March 4th 2019 / Server-side / User interface / Items Set placer to nil instead of a non-functional one in item_OnPlace (DTA7) Here is why, you may have a nil placer. One issue had been logged : https://github.com/minetest/minetest/issues/6487 place_node crashes the game because of nil player #6487 Here is the commit corresponding : https://github.com/minetest/minetest_game/pull/1907/commits/73c5339adb8ff93328f5439bf842767b71e0ce6c Add nil checks for placer #1907 Reason in the mod : For Adventure Test, in `dungeons.lua`, you have line 33 a `minetest.register_on_generated()`, in it, you have, line 161, a call of `minetest.place_node()`. In `register_functions.lua`, you have a `minetest.register_on_placenode(adventuretest_placenode)`, so the call of `place_node()` redirect to `adventuretest_placenode()`. In the commit, I have found an example of change (a nil check) that can be done in `adventuretest_placenode()`. What to do : Go to : games\adventuretest\mods\adventuretest There, change the file : `register_functions.lua` replace the line 101 (`if placer:is_player() then`) with : ``` if placer and placer:is_player() then ``` 0.4.16 → 5.0.0 : `nodeupdate()` was removed. Fix: replace with `minetest.check_for_falling`. In Adventuretest I have found 2 calls of `nodeupdate()` (may be there is more). When it have been called, I got a crash : `AsyncErr: ServerThread::run Lua: Runtime error from mod 'default' in callback LuaABM::trigger(): ...32\bin\..\games\adventuretest\mods\default/functions.lua:385: attempt to call global 'nodeupdate' (a nil value)` What to do : Change the file `games\adventuretest\mods\default\functions.lua` replace the line 385 (nodeupdate(p0)) with : `minetest.check_for_falling(p0)` Then, change the file `games\adventuretest\mods\doors\init.lua` replace the line 374 with : `minetest.check_for_falling({x = pos.x, y = pos.y + 1, z = pos.z})` ### Fiel of view for monsters vs characters From https://forum.minetest.net/viewtopic.php?p=182737#p182737 If it helps any, here is the in_fov code from mobs redo mod that works (self is mob, pos is player position and self.fov is set to 90, self.rotate is usually 0 for front facing mobs): CODE: SELECT ALL ``` in_fov = function(self,pos) -- checks if POS is in self's FOV local yaw = self.object:getyaw() + self.rotate local vx = math.sin(yaw) local vz = math.cos(yaw) local ds = math.sqrt(vx^2 + vz^2) local ps = math.sqrt(pos.x^2 + pos.z^2) local d = { x = vx / ds, z = vz / ds } local p = { x = pos.x / ps, z = pos.z / ps } local an = ( d.x * p.x ) + ( d.z * p.z ) a = math.deg( math.acos( an ) ) ``` Thank you everyone, especially TeTpaAka and Nore. All problems were at last solved, and the code now reports the angle difference between entities like it should! You get 0* when standing right in front of the mob, 90* when standing parallel to either side, 180* when standing behind... whereas flying up or down now accounts pitch correctly on top of that. Here is the final and fully functional version. I hope it will be helpful to more people than just me, if anyone ever needs a simple and efficient FOV scanner for Minetest. ``` local function in_fov (pos1, pos2, yaw, pitch, fov) local function yaw2vec (yaw, pitch) -- we must invert the yaw for x to keep the result from inverting when facing opposite directions (0* becoming 180*) return {x = math.sin(-yaw) * math.cos(pitch), y = math.sin(pitch), z = math.cos(yaw) * math.cos(pitch)} end local function dotproduct (v1, v2) return ((v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z)) end local function angle (v1, v2) return math.deg(math.acos(dotproduct(v1, v2) / (vector.length(v1) * vector.length(v2)))) end local v = vector.subtract(pos2, pos1) print(angle(yaw2vec(yaw, pitch), v)) end ``` here is the final version of the function which I'll be including in my mod, simplified to only 5 lines of code but with the same result: CODE: SELECT ALL ``` -- returns the angle difference between pos1 and pos2, as seen from pos1 at the specified yaw and pitch function pos_to_angle (pos1, pos2, yaw, pitch) -- note: we must invert the yaw for x in yaw_vec, to keep the result from inverting when facing opposite directions (0* becoming 180*) local yaw_vec = {x = -math.sin(yaw) * math.cos(pitch), y = math.sin(pitch), z = math.cos(yaw) * math.cos(pitch)} local pos_subtract = vector.subtract(pos2, pos1) local pos_dotproduct = (yaw_vec.x * pos_subtract.x) + (yaw_vec.y * pos_subtract.y) + (yaw_vec.z * pos_subtract.z) local angle = math.deg(math.acos(pos_dotproduct / (vector.length(yaw_vec) * vector.length(pos_subtract)))) return angle end ```