forked from your-land/yl_cinema
add a fixed (non-rotating) screen option
This commit is contained in:
parent
8be2422ff8
commit
8ae2d03929
@ -22,20 +22,51 @@ local bigscreen_entity_definition = {
|
||||
textures = {"yl_cinema_block_bigscreen.png^yl_cinema_icon_movie_inv.png"},
|
||||
_yl_cinema_stored_movie = "",
|
||||
on_blast = function()
|
||||
|
||||
return false, false, {}
|
||||
end
|
||||
return false, false, {}
|
||||
end
|
||||
}
|
||||
|
||||
minetest.register_entity(bigscreen_entity_name, bigscreen_entity_definition)
|
||||
|
||||
|
||||
local flatscreen_entity_name = "yl_cinema:movie_flatscreen"
|
||||
local flatscreen_entity_initial_properties = {}
|
||||
local flatscreen_entity_definition = {
|
||||
initial_properties = flatscreen_entity_initial_properties,
|
||||
visual = "mesh",
|
||||
mesh = "yl_cinema_unit_plane.obj",
|
||||
backface_culling = false, -- make visible from both sides
|
||||
visual_size = {
|
||||
-- 1 unit in world coords is 10 units in model coords
|
||||
x = screen_width * 10,
|
||||
y = 1,
|
||||
z = screen_height * 10,
|
||||
},
|
||||
glow = 15,
|
||||
nametag = "",
|
||||
nametag_color = "#ffcc00",
|
||||
nametag_bgcolor = "#000000",
|
||||
collisionbox = {0},
|
||||
physical = false,
|
||||
textures = {"yl_cinema_block_bigscreen.png^yl_cinema_icon_movie_inv.png"},
|
||||
_yl_cinema_stored_movie = "",
|
||||
on_blast = function()
|
||||
return false, false, {}
|
||||
end
|
||||
}
|
||||
|
||||
minetest.register_entity(flatscreen_entity_name, flatscreen_entity_definition)
|
||||
|
||||
|
||||
-- Helper
|
||||
|
||||
local function find_entity(pos)
|
||||
local v = vector.new(0, 3.5, 0)
|
||||
local center_pos = vector.add(pos, v)
|
||||
for _, obj in pairs(minetest.get_objects_inside_radius(center_pos, 0.5)) do
|
||||
if obj and obj:get_luaentity() and (obj:get_luaentity().name == bigscreen_entity_name) then
|
||||
if obj and obj:get_luaentity() and
|
||||
(obj:get_luaentity().name == bigscreen_entity_name or
|
||||
obj:get_luaentity().name == flatscreen_entity_name) then
|
||||
return obj
|
||||
end
|
||||
end
|
||||
@ -109,18 +140,42 @@ local function get_formspec(pos)
|
||||
return table.concat(formspec, "")
|
||||
end
|
||||
|
||||
local function on_construct_node(pos)
|
||||
local function spawn_bigscreen(pos)
|
||||
local v = vector.new(0, 3.5, 0)
|
||||
local center_pos = vector.add(pos, v)
|
||||
|
||||
minetest.add_entity(center_pos, bigscreen_entity_name)
|
||||
end
|
||||
|
||||
local function spawn_flatscreen(pos, rotation)
|
||||
local v = vector.new(0, 3.5, 0)
|
||||
local center_pos = vector.add(pos, v)
|
||||
|
||||
local screen = minetest.add_entity(center_pos, flatscreen_entity_name)
|
||||
if screen then
|
||||
screen:set_rotation(vector.new(math.pi/2.0, rotation, 0))
|
||||
end
|
||||
end
|
||||
|
||||
local function on_construct_base_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local formspec = get_formspec(pos)
|
||||
meta:set_string("formspec", formspec)
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("movie", 1)
|
||||
end
|
||||
|
||||
minetest.add_entity(center_pos, bigscreen_entity_name)
|
||||
local function on_construct_bigscreen_node(pos)
|
||||
on_construct_base_node(pos)
|
||||
spawn_bigscreen(pos)
|
||||
end
|
||||
|
||||
local function on_construct_flatscreen_node(pos)
|
||||
on_construct_base_node(pos)
|
||||
|
||||
local node = minetest.get_node(pos)
|
||||
spawn_flatscreen(pos, node.param2 * math.pi/2)
|
||||
end
|
||||
|
||||
local function on_destruct_node(pos)
|
||||
@ -199,7 +254,7 @@ end
|
||||
|
||||
yl_cinema.bigscreen_block_name = "yl_cinema:bigscreen_base"
|
||||
local bigscreen_block_definition = {
|
||||
description = "Cinema Base",
|
||||
description = "Cinema Base with rotating screen",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
@ -212,7 +267,7 @@ local bigscreen_block_definition = {
|
||||
"yl_cinema_block_bigscreen.png", "yl_cinema_block_bigscreen.png", "yl_cinema_block_bigscreen.png",
|
||||
"yl_cinema_block_bigscreen.png"},
|
||||
can_dig = can_dig_node,
|
||||
on_construct = on_construct_node,
|
||||
on_construct = on_construct_bigscreen_node,
|
||||
on_destruct = on_destruct_node,
|
||||
on_blast = on_blast_node,
|
||||
on_receive_fields = on_receive_fields_node,
|
||||
@ -220,7 +275,37 @@ local bigscreen_block_definition = {
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take_node,
|
||||
allow_metadata_inventory_move = function()
|
||||
return
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
minetest.register_node(yl_cinema.bigscreen_block_name, bigscreen_block_definition)
|
||||
|
||||
|
||||
yl_cinema.flatscreen_block_name = "yl_cinema:flatscreen_base"
|
||||
local flatscreen_block_definition = {
|
||||
description = "Cinema Base with fixed screen",
|
||||
paramtype2 = "4dir",
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {{-0.5, -0.5, -0.5, 0.5, -0.4, 0.5}}
|
||||
},
|
||||
groups = {
|
||||
cracky = 3
|
||||
},
|
||||
tiles = {"yl_cinema_block_bigscreen.png^yl_cinema_icon_movie_inv.png", "yl_cinema_block_bigscreen.png",
|
||||
"yl_cinema_block_bigscreen.png", "yl_cinema_block_bigscreen.png", "yl_cinema_block_bigscreen.png",
|
||||
"yl_cinema_block_bigscreen.png"},
|
||||
can_dig = can_dig_node,
|
||||
on_construct = on_construct_flatscreen_node,
|
||||
on_destruct = on_destruct_node,
|
||||
on_blast = on_blast_node,
|
||||
on_receive_fields = on_receive_fields_node,
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put_node,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take_node,
|
||||
allow_metadata_inventory_move = function()
|
||||
return
|
||||
end,
|
||||
}
|
||||
|
||||
minetest.register_node(yl_cinema.flatscreen_block_name, flatscreen_block_definition)
|
||||
|
16
models/yl_cinema_unit_plane.obj
Normal file
16
models/yl_cinema_unit_plane.obj
Normal file
@ -0,0 +1,16 @@
|
||||
# Blender 3.3.6
|
||||
# www.blender.org
|
||||
mtllib unit_plane.mtl
|
||||
o Plane
|
||||
v -0.500000 0.000000 0.500000
|
||||
v 0.500000 0.000000 0.500000
|
||||
v -0.500000 0.000000 -0.500000
|
||||
v 0.500000 0.000000 -0.500000
|
||||
vn -0.0000 1.0000 -0.0000
|
||||
vt 0.999900 0.999900
|
||||
vt 0.000100 0.999900
|
||||
vt 0.999900 0.000100
|
||||
vt 0.000100 0.000100
|
||||
s 0
|
||||
f 2/2/1 3/3/1 1/1/1
|
||||
f 2/2/1 4/4/1 3/3/1
|
Loading…
Reference in New Issue
Block a user