Skip to content

Commit

Permalink
Converted to using a mesh instead of a flat texture
Browse files Browse the repository at this point in the history
  • Loading branch information
entuland committed May 10, 2018
1 parent 9591ba6 commit fd63162
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 20 deletions.
73 changes: 53 additions & 20 deletions init.lua
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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'},
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
60 changes: 60 additions & 0 deletions models/tpad-mesh.obj
Original file line number Diff line number Diff line change
@@ -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
Binary file removed textures/tpad-16.png
Binary file not shown.
Binary file removed textures/tpad-pix-16.png
Binary file not shown.
Binary file removed textures/tpad-pix-32.png
Binary file not shown.
Binary file added textures/tpad-texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fd63162

Please sign in to comment.