diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-11-02 11:28:23 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-11-02 11:28:23 +0100 |
commit | c6418e2d87299d97e86a90c8b6d0ab6b9a815317 (patch) | |
tree | 98264ef00e6d8216464f69557bca057825f227bd | |
download | randomblocks_client-c6418e2d87299d97e86a90c8b6d0ab6b9a815317.tar.xz |
Initial Commit
-rw-r--r-- | init.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..b5202b0 --- /dev/null +++ b/init.lua @@ -0,0 +1,20 @@ +local channel = minetest.mod_channel_join("randomblocks") + +local last_pos + +local function get_pointed_thing() + local pos = minetest.camera:get_pos() + local pos2 = vector.add(pos, vector.multiply(minetest.camera:get_look_dir(), 100)) + local ray = minetest.raycast(pos, pos2, true, true) + return ray:next() +end + +minetest.register_globalstep(function() + local pointed_thing = get_pointed_thing() + if not pointed_thing or pointed_thing.type ~= "node" then return end + local pos = pointed_thing.under + if last_pos and not vector.equals(pos, last_pos) then + channel:send_all(minetest.pos_to_string(last_pos)) + end + last_pos = pos +end) |