aboutsummaryrefslogtreecommitdiff
path: root/clientmods/preview
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2019-11-09 00:22:42 +0100
committersfan5 <sfan5@live.de>2019-11-11 14:06:48 +0100
commitb57dc70769873e00ca7a7642862eb209a5528ce2 (patch)
treef0f79e77d7996469350033dc2fe1ef7319133c39 /clientmods/preview
parentb0260b5ec8e05e54928f9487bb39b4ff946951f9 (diff)
downloadminetest-b57dc70769873e00ca7a7642862eb209a5528ce2.tar.gz
minetest-b57dc70769873e00ca7a7642862eb209a5528ce2.tar.bz2
minetest-b57dc70769873e00ca7a7642862eb209a5528ce2.zip
[CSM] Expose more env functions
Diffstat (limited to 'clientmods/preview')
-rw-r--r--clientmods/preview/init.lua21
1 files changed, 16 insertions, 5 deletions
diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua
index c1358b1c1..96deae074 100644
--- a/clientmods/preview/init.lua
+++ b/clientmods/preview/init.lua
@@ -65,6 +65,22 @@ core.register_on_item_use(function(itemstack, pointed_thing)
print("The local player used an item!")
print("pointed_thing :" .. dump(pointed_thing))
print("item = " .. itemstack:get_name())
+
+ local pos = vector.add(core.localplayer:get_pos(), core.camera:get_offset())
+ local pos2 = vector.add(pos, vector.multiply(core.camera:get_look_dir(), 100))
+
+ local rc = core.raycast(pos, pos2)
+ local i = rc:next()
+ print("[PREVIEW] raycast next: " .. dump(i))
+ if i then
+ print("[PREVIEW] line of sight: " .. (core.line_of_sight(pos, i.above) and "yes" or "no"))
+
+ local n1 = core.find_nodes_in_area(pos, i.under, {"default:stone"})
+ local n2 = core.find_nodes_in_area_under_air(pos, i.under, {"default:stone"})
+ print(("[PREVIEW] found %s nodes, %s nodes under air"):format(
+ n1 and #n1 or "?", n2 and #n2 or "?"))
+ end
+
return false
end)
@@ -91,11 +107,6 @@ core.register_on_damage_taken(function(hp)
end)
-- This is an example function to ensure it's working properly, should be removed before merge
-core.register_globalstep(function(dtime)
- -- print("[PREVIEW] globalstep " .. dtime)
-end)
-
--- This is an example function to ensure it's working properly, should be removed before merge
core.register_chatcommand("dump", {
func = function(param)
return true, dump(_G)