From fd63162e3a2e7f25695c616caec6579aaab17e53 Mon Sep 17 00:00:00 2001 From: entuland Date: Thu, 10 May 2018 18:56:49 +0200 Subject: [PATCH] Converted to using a mesh instead of a flat texture --- init.lua | 73 +++++++++++++++++++++++++++----------- models/tpad-mesh.obj | 60 +++++++++++++++++++++++++++++++ textures/tpad-16.png | Bin 287 -> 0 bytes textures/tpad-pix-16.png | Bin 820 -> 0 bytes textures/tpad-pix-32.png | Bin 2295 -> 0 bytes textures/tpad-texture.png | Bin 0 -> 4015 bytes 6 files changed, 113 insertions(+), 20 deletions(-) create mode 100644 models/tpad-mesh.obj delete mode 100644 textures/tpad-16.png delete mode 100644 textures/tpad-pix-16.png delete mode 100644 textures/tpad-pix-32.png create mode 100644 textures/tpad-texture.png diff --git a/init.lua b/init.lua index db2fd21..f262622 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,8 @@ tpad = {} tpad.version = "1.1" -tpad.tile_image = "tpad-pix-16.png" +tpad.texture = "tpad-texture.png" +tpad.mesh = "tpad-mesh.obj" +tpad.nodename = "tpad:tpad" -- load storage facilities and verify it dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/storage.lua") @@ -16,7 +18,7 @@ local waypoint_hud_ids = {} -- not-so-cheap recipe minetest.register_craft({ - output = 'tpad:tpad', + output = tpad.nodename, recipe = { {'group:wood', 'default:bronze_ingot', 'group:wood'}, {'default:bronze_ingot', 'group:wood', 'default:bronze_ingot'}, @@ -68,18 +70,44 @@ function tpad.hud_off(playername) end -- ======================================================================== --- callbacks bound in register_node("tpad:tpad") +-- callbacks bound in register_node() -- ======================================================================== -function tpad.on_construct(pos) - local meta = minetest.env:get_meta(pos) - meta:set_string("infotext", "Tpad Station - right click to interact") +function tpad.get_pos_from_pointed(pointed) + local node_above = minetest.get_node_or_nil(pointed.above) + local node_under = minetest.get_node_or_nil(pointed.under) + + if not node_above or not node_under then return end + + if node_under.name == tpad.nodename then + -- bail out cause on_place() gets triggered at every rightclick and leads to ghost pads + return + end + + local def_above = minetest.registered_nodes[node_above.name] + or minetest.nodedef_default + local def_under = minetest.registered_nodes[node_under.name] + or minetest.nodedef_default + + if not def_above.buildable_to and not def_under.buildable_to then return end + + if def_under.buildable_to then + return pointed.under + end + + return pointed.above end -function tpad.after_place_node(pos, placer) - local meta = minetest.env:get_meta(pos) - meta:set_string("owner", placer:get_player_name()) - tpad.set_pad_name(pos, "") +function tpad.on_place(itemstack, placer, pointed_thing) + local pos = tpad.get_pos_from_pointed(pointed_thing) + itemstack = minetest.rotate_node(itemstack, placer, pointed_thing) + if pos then + local meta = minetest.env:get_meta(pos) + meta:set_string("owner", placer:get_player_name()) + meta:set_string("infotext", "Tpad Station - right click to interact") + tpad.set_pad_name(pos, "") + end + return itemstack end function tpad.on_rightclick(clicked_pos, node, clicker) @@ -334,18 +362,23 @@ end -- register node and bind callbacks -- ======================================================================== -minetest.register_node("tpad:tpad", { - tiles = {tpad.tile_image}, - drawtype = "signlike", - paramtype = "light", - paramtype2 = "wallmounted", - walkable = false, +local collision_box = { + type = "fixed", + fixed = { + { -0.5, -0.5, -0.5, 0.5, -0.3, 0.5 }, + } +} + +minetest.register_node(tpad.nodename, { + drawtype = "mesh", + tiles = { tpad.texture }, + mesh = tpad.mesh, + paramtype2 = "facedir", + on_place = tpad.on_place, + collision_box = collision_box, + selection_box = collision_box, description = "Teleporter Pad", - inventory_image = tpad.tile_image, groups = {choppy = 2, dig_immediate = 2}, - selection_box = { type = "wallmounted"}, - on_construct = tpad.on_construct, - after_place_node = tpad.after_place_node, on_rightclick = tpad.on_rightclick, can_dig = tpad.can_dig, on_destruct = tpad.on_destruct, diff --git a/models/tpad-mesh.obj b/models/tpad-mesh.obj new file mode 100644 index 0000000..6c958f1 --- /dev/null +++ b/models/tpad-mesh.obj @@ -0,0 +1,60 @@ +# Blender v2.79 (sub 0) OBJ File: 'tpad.blend' +# www.blender.org +mtllib tpad-mesh.mtl +o Cube +v -0.500000 -0.500000 -0.500000 +v 0.500000 -0.500000 -0.500000 +v 0.500000 -0.500000 0.500000 +v -0.500000 -0.500000 0.500000 +v -0.429289 -0.300000 -0.429289 +v 0.429289 -0.300000 -0.429289 +v 0.429289 -0.300000 0.429289 +v -0.429289 -0.300000 0.429289 +v -0.500000 -0.380000 -0.500000 +v 0.500000 -0.380000 -0.499999 +v -0.500000 -0.380000 0.500000 +v 0.500000 -0.380000 0.500000 +vt 0.078125 0.421875 +vt 0.078125 0.000000 +vt 0.484375 0.000000 +vt 0.484375 0.421875 +vt 0.093750 0.515625 +vt 0.468750 0.515625 +vt 0.468750 0.890625 +vt 0.093750 0.890625 +vt -0.000000 0.484375 +vt 0.046875 0.484375 +vt 0.046875 0.921875 +vt -0.000000 0.921875 +vt 0.078125 0.984375 +vt 0.078125 0.937500 +vt 0.484375 0.937500 +vt 0.484375 0.984375 +vt 0.562500 0.921875 +vt 0.515625 0.921875 +vt 0.515625 0.484375 +vt 0.562500 0.484375 +vt 0.078125 0.468750 +vt 0.484375 0.468750 +vn 0.0000 -1.0000 0.0000 +vn 0.0000 1.0000 -0.0000 +vn 0.0000 0.0000 -1.0000 +vn 1.0000 -0.0000 0.0000 +vn -0.0000 -0.0000 1.0000 +vn -1.0000 0.0000 -0.0000 +vn 0.0000 0.6623 -0.7493 +vn -0.7493 0.6623 -0.0000 +vn 0.7493 0.6623 0.0000 +vn -0.0000 0.6623 0.7493 +usemtl Material +s off +f 1/1/1 2/2/1 3/3/1 4/4/1 +f 5/5/2 8/6/2 7/7/2 6/8/2 +f 1/9/3 9/10/3 10/11/3 2/12/3 +f 2/13/4 10/14/4 12/15/4 3/16/4 +f 3/17/5 12/18/5 11/19/5 4/20/5 +f 9/21/6 1/1/6 4/4/6 11/22/6 +f 5/5/7 6/8/7 10/11/7 9/10/7 +f 8/6/8 5/5/8 9/21/8 11/22/8 +f 6/8/9 7/7/9 12/15/9 10/14/9 +f 7/7/10 8/6/10 11/19/10 12/18/10 diff --git a/textures/tpad-16.png b/textures/tpad-16.png deleted file mode 100644 index fe4bcf8aba7e811360dd2b024a5564ea060b6784..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 287 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkENLn2C?^K)}k^GbkR1_tLKSH}?l zAS;FR6y2JY z0A>feN^JlD010qNS#tmY0CoTX0CoXRdnO0~000McNliru;sps37!y0Ueo6oU0>Mc{ zK~y-)b(6hM99I;@fA7uA+udP@A&XW{6`@#Ifhv(gfrOAOhY!)kMXZR>rCG&_(o;D0bT zH)oYnoSmJal%iIviMR3Ge=nw{rmQiB)zwu_PEJrt5k(P7DGRW*wRPjr^)NFtV*y^= z`vj+42BomgCZfL|+iLM->|=r;pi-%zlwx~(TL4G^KKuyBaoGLr0V0>fcDvYS6NG>) zLlg>3|MDvb2M1KERg5t(G4Z#8$;nCk@{0v923abB5M-}k^I-2Kj^m)UCXQorxf}}% z3s`GeUS6hFs|g9v*Vl*bc9CI--rFO4^@{mF|DfG&BZNQ*f#-R&+ikx8_BNeP2c;AM z&h+%OU0hsb^Y{cC$GAg7%>Vuy`}_NxpPzGhc*yDLDPb7m`#z%cIX~AeUw%DAtJSKy zS(XuoA$T6P*JJ+2=O86oYk(`iKoA5ZNkZfN8B%&=S%&9%NMj5~M@Pv1eq?Eo%gal& z)(j61UrQeu89{4}wH6^={QP^AN+q<`xUTDBj3H|@z;P%RiwJS`-84<{JP&|!xy->& z4;d&b68#1#C25)>cLoQ=#>NIe+{(pja%DrYWPNql}M_)7Yz09vCOlO%nZv%*6P<56>Up zOk$-{A)n9lUG*J2cK{&-#-?B`u3IF_A`p@&|B#)Xoqr?|a9x-6^>rGJ2Hz}QkeLW6 zb69Jz7>r2>{5y1VU*Wp$f4cy{{rh}st!=ehtgNii>-CUQa&d9N+S(dPl2EVL-(IF` y?C!$Y7_+mpHp?=swE#Trb_I_f!QHzz=zjqO@-%fqXt+lJ0000P diff --git a/textures/tpad-pix-32.png b/textures/tpad-pix-32.png deleted file mode 100644 index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