Updated platforms.
parent
285fa53219
commit
a230914245
|
@ -44,7 +44,7 @@ minetest.register_node('platformer:button', {
|
|||
local item = itemstack:get_name()
|
||||
local name = clicker:get_player_name()
|
||||
if item == 'tasks:configurator' then
|
||||
if owner == name or minetest.check_player_privs(clicker, {server = true}) then
|
||||
if owner == name and minetest.check_player_privs(clicker, {server = true}) then
|
||||
tasks.player_config[name] = pos
|
||||
local xp = meta:get_int('xp')
|
||||
local pos = meta:get_string('pos')
|
||||
|
@ -75,16 +75,19 @@ minetest.register_node('platformer:button', {
|
|||
minetest.show_formspec(name, 'platformer:button', button_formspec(xp, pos, desc))
|
||||
end
|
||||
elseif wield_name ~= 'creative:tool_breaking' then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local spawn = meta:get_string('pos')
|
||||
local spawn_pos = minetest.string_to_pos(spawn)
|
||||
if spawn_pos ~= nil then
|
||||
local xp = meta:get_int('xp')
|
||||
puncher:set_pos(spawn_pos)
|
||||
lobby.give_xp(puncher, xp)
|
||||
else
|
||||
local owner = meta:get_string('owner')
|
||||
minetest.chat_send_player(puncher:get_player_name(), 'Looks like '..owner..' misconfigured this button, sorry. Use /spawn to get back to the lobby.')
|
||||
local owner = meta:get_string('owner')
|
||||
if owner ~= '' then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local spawn = meta:get_string('pos')
|
||||
local spawn_pos = minetest.string_to_pos(spawn)
|
||||
if spawn_pos ~= nil then
|
||||
local xp = meta:get_int('xp')
|
||||
puncher:set_pos(spawn_pos)
|
||||
lobby.give_xp(puncher, xp)
|
||||
else
|
||||
|
||||
minetest.chat_send_player(puncher:get_player_name(), 'Looks like '..owner..' misconfigured this button, sorry. Use /spawn to get back to the lobby.')
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
|
|
@ -1,3 +1,120 @@
|
|||
minetest.register_entity('platformer:platform', {
|
||||
visual = 'mesh',
|
||||
mesh = 'platformer_platform_x1.obj',
|
||||
visual_size = {x = 10, y = 10},
|
||||
collisionbox = {-1, .25, -.5, 1, .5, .5},
|
||||
physical = true,
|
||||
textures = {'platformer_platform_xz.png'},
|
||||
|
||||
init = function(self, texture)
|
||||
self.data.texture = texture
|
||||
self.object:set_properties({textures = texture})
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
local rot = self.object:get_rotation()
|
||||
if rot.y == 0 then
|
||||
self.object:set_rotation({y= 3.1459, x= 0, z= 0})
|
||||
self.object:set_velocity({x= -1.5, y= 0, z= 0})
|
||||
elseif rot.y <= 3.146 and rot.y >= 3.145 then
|
||||
self.object:set_rotation({y= 0, x= 0, z= 0})
|
||||
self.object:set_velocity({x= 1.5, y= 0, z= 0})
|
||||
elseif rot.y <= 1.573 and rot.y >= 1.572 then
|
||||
self.object:set_rotation({y= -1.57295, x= 0, z= 0})
|
||||
self.object:set_velocity({x= 0, y= 0, z= -1.5})
|
||||
elseif rot.y <= -1.572 and rot.y >= -1.573 then
|
||||
self.object:set_rotation({y= 1.57295, x= 0, z= 0})
|
||||
self.object:set_velocity({x= 0, y= 0, z= 1.5})
|
||||
end
|
||||
end,
|
||||
|
||||
on_punch = function(self, puncher)
|
||||
local rot = self.object:get_rotation()
|
||||
if rot.y == 0 then
|
||||
self.object:set_velocity({x= 1.5, y= 0, z= 0})
|
||||
elseif rot.y <= 3.146 and rot.y >= 3.145 then
|
||||
self.object:set_velocity({x= -1.5, y= 0, z= 0})
|
||||
elseif rot.y <= 1.573 and rot.y >= 1.572 then
|
||||
self.object:set_velocity({x= 0, y= 0, z= 1.5})
|
||||
elseif rot.y <= -1.572 and rot.y >= -1.573 then
|
||||
self.object:set_velocity({x= 0, y= 0, z= -1.5})
|
||||
end
|
||||
end,
|
||||
|
||||
on_rightclick = function(self, clicker)
|
||||
local tool = clicker:get_wielded_item():to_string()
|
||||
if tool == 'creative:tool_breaking' then
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime, moveresult)
|
||||
--[[local pos = self.object:get_pos() -- Code doesn't reliably move player with the platform.
|
||||
print (dump(self.object:get_velocity()))
|
||||
local vel = vector.divide(self.object:get_velocity(), 2)
|
||||
print (dump(vel))
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local player_pos = player:get_pos()
|
||||
local p2p_distance = vector.distance(player_pos, pos)
|
||||
if p2p_distance < 2 and player_pos.y > pos.y then
|
||||
print 'moving player'
|
||||
player:add_velocity(vel)
|
||||
--player:set_attach(self.object)
|
||||
end
|
||||
end
|
||||
--]]
|
||||
if moveresult.collides then
|
||||
local rot = self.object:get_rotation()
|
||||
if rot.y == 0 then
|
||||
self.object:set_rotation({y= 3.1459, x= 0, z= 0})
|
||||
self.object:set_velocity({x= -1.5, y= 0, z= 0})
|
||||
elseif rot.y <= 3.146 and rot.y >= 3.145 then
|
||||
self.object:set_rotation({y= 0, x= 0, z= 0})
|
||||
self.object:set_velocity({x= 1.5, y= 0, z= 0})
|
||||
elseif rot.y <= 1.573 and rot.y >= 1.572 then
|
||||
self.object:set_rotation({y= -1.57295, x= 0, z= 0})
|
||||
self.object:set_velocity({x= 0, y= 0, z= -1.5})
|
||||
elseif rot.y <= -1.572 and rot.y >= -1.573 then
|
||||
self.object:set_rotation({y= 1.57295, x= 0, z= 0})
|
||||
self.object:set_velocity({x= 0, y= 0, z= 1.5})
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem('platformer:platform_placer', {
|
||||
description = 'Places moving platforms.',
|
||||
inventory_image = 'platformer_placer_xz.png',
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local pos = pointed_thing.above
|
||||
if not minetest.is_protected(pos, placer:get_player_name()) then
|
||||
local dir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
print (dir)
|
||||
if dir == 0 then
|
||||
local platform = minetest.add_entity(pos, 'platformer:platform')
|
||||
platform:set_rotation({y= 1.57295, x= 0, z= 0})
|
||||
platform:set_velocity({x= 0, y= 0, z= 1})
|
||||
platform:set_properties({collisionbox = {-.5, .25, -1, .5, .5, 1}})
|
||||
elseif dir == 1 then
|
||||
local platform = minetest.add_entity(pos, 'platformer:platform')
|
||||
platform:set_rotation({y= 0, x= 0, z= 0})
|
||||
platform:set_velocity({x= 1, y= 0, z= 0})
|
||||
elseif dir == 2 then
|
||||
local platform = minetest.add_entity(pos, 'platformer:platform')
|
||||
platform:set_rotation({y= -1.57295, x= 0, z= 0})
|
||||
platform:set_velocity({x= 0, y= 0, z= -1})
|
||||
platform:set_properties({collisionbox = {-.5, .25, -1, .5, .5, 1}})
|
||||
elseif dir == 3 then
|
||||
local platform = minetest.add_entity(pos, 'platformer:platform')
|
||||
platform:set_rotation({y= 3.1459, x= 0, z= 0})
|
||||
platform:set_velocity({x= -1, y= 0, z= 0})
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--All this code should be removed, once I figure out how to port the old items over to the new.
|
||||
|
||||
local x_box = {
|
||||
type = 'fixed',
|
||||
fixed = {
|
||||
|
@ -21,7 +138,7 @@ minetest.register_node('platformer:x1', {
|
|||
light_source = 2,
|
||||
selection_box = x_box,
|
||||
collision_box = x_box,
|
||||
groups = {breakable = 1},
|
||||
groups = {breakable = 1, not_in_creative_inventory=1},
|
||||
on_construct = function(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:start(1.5)
|
||||
|
@ -74,7 +191,7 @@ minetest.register_node('platformer:y1', {
|
|||
light_source = 2,
|
||||
selection_box = y_box,
|
||||
collision_box = y_box,
|
||||
groups = {breakable = 1},
|
||||
groups = {breakable = 1, not_in_creative_inventory=1},
|
||||
on_construct = function(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:start(1.5)
|
||||
|
@ -127,7 +244,7 @@ minetest.register_node('platformer:z1', {
|
|||
light_source = 2,
|
||||
selection_box = z_box,
|
||||
collision_box = z_box,
|
||||
groups = {breakable = 1},
|
||||
groups = {breakable = 1, not_in_creative_inventory=1},
|
||||
on_construct = function(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
timer:start(1.5)
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
Loading…
Reference in New Issue