diff options
Diffstat (limited to 'clientmods/preview/init.lua')
-rw-r--r-- | clientmods/preview/init.lua | 52 |
1 files changed, 37 insertions, 15 deletions
diff --git a/clientmods/preview/init.lua b/clientmods/preview/init.lua index bb8d1d600..5777adcaf 100644 --- a/clientmods/preview/init.lua +++ b/clientmods/preview/init.lua @@ -1,19 +1,27 @@ -local modname = core.get_current_modname() or "??" +local modname = assert(core.get_current_modname()) local modstorage = core.get_mod_storage() local mod_channel -dofile("preview:example.lua") --- This is an example function to ensure it's working properly, should be removed before merge +dofile(core.get_modpath(modname) .. "example.lua") + core.register_on_shutdown(function() print("[PREVIEW] shutdown client") end) local id = nil -local server_info = core.get_server_info() -print("Server version: " .. server_info.protocol_version) -print("Server ip: " .. server_info.ip) -print("Server address: " .. server_info.address) -print("Server port: " .. server_info.port) +do + local server_info = core.get_server_info() + print("Server version: " .. server_info.protocol_version) + print("Server ip: " .. server_info.ip) + print("Server address: " .. server_info.address) + print("Server port: " .. server_info.port) + + print("CSM restrictions: " .. dump(core.get_csm_restrictions())) + + local l1, l2 = core.get_language() + print("Configured language: " .. l1 .. " / " .. l2) +end + mod_channel = core.mod_channel_join("experimental_preview") core.after(4, function() @@ -65,6 +73,26 @@ 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()) + + if not itemstack:is_empty() then + return false + end + + 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 +119,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) @@ -143,8 +166,7 @@ core.after(5, function() core.ui.minimap:show() end - print("[PREVIEW] Day count: " .. core.get_day_count() .. - " time of day " .. core.get_timeofday()) + print("[PREVIEW] Time of day " .. core.get_timeofday()) print("[PREVIEW] Node level: " .. core.get_node_level({x=0, y=20, z=0}) .. " max level " .. core.get_node_max_level({x=0, y=20, z=0})) |