Massive simplification removing multiple doors feature and opting for large customisable interiors instead
This commit is contained in:
parent
ef89222d7e
commit
c2f94417d7
106
api.lua
106
api.lua
@ -5,9 +5,14 @@
|
||||
-- Exterior registering (tardis/exterior_api.lua)
|
||||
|
||||
-- Does include:
|
||||
-- Get exterior position
|
||||
-- Place Tardis interior
|
||||
-- Rebuild Tardis interior
|
||||
-- Locate Tardis
|
||||
-- Is this node a Time Rotor?
|
||||
-- Switch a Time Rotor on/off
|
||||
-- Lock/Unlock Tardis exit door
|
||||
-- Toggle antigrav system
|
||||
|
||||
--Planned:
|
||||
-- Summon Tardis API
|
||||
@ -27,7 +32,7 @@ end
|
||||
-- Returns the interior type of a player's Tardis
|
||||
function drwho_tardis.get:interior_type(name)
|
||||
local user = _drwho_tardis.get_user(name)
|
||||
local type = user.interior_rooms.console.type or "old"
|
||||
local type = user.console_room.type or "old"
|
||||
return type
|
||||
end
|
||||
|
||||
@ -54,7 +59,8 @@ end
|
||||
|
||||
-- Returns the current power levels of a player's Tardis
|
||||
function drwho_tardis.get:power(name)
|
||||
return false, "This function has not been made yet", nil
|
||||
local user = _drwho_tardis.get_user(name)
|
||||
return true, user.power, nil
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------
|
||||
@ -69,72 +75,42 @@ function _drwho_tardis:place_tardis_interior(name, type, pos)
|
||||
local user = _drwho_tardis.get_user(name) -- get user data
|
||||
if type == "custom" then
|
||||
-- Assume that the given pos is where the door is going to be
|
||||
user.interior_rooms.console.type = type -- Save the fact their interior is custom
|
||||
user.interior_rooms.console.door_pos_table = {door_0 = pos} -- Remember the door position
|
||||
user.interior_rooms.console.door_offset_table = {door_0={x=0,y=0,z=0}} -- door offset is 0
|
||||
user.console_room.type = type -- Save the fact their interior is custom
|
||||
user.console_room.door_pos_table = {door_0 = pos} -- Remember the door position
|
||||
user.console_room.door_offset_table = {door_0={x=0,y=0,z=0}} -- door offset is 0
|
||||
user.in_pos = pos -- save new interior position
|
||||
_drwho_tardis.save_user(name, user) -- save user data
|
||||
return true, "", {door_0 = pos} -- success, message, door_pos_table
|
||||
end
|
||||
pos.y = _drwho_tardis.interiorDepth -- set the y pos of the interior
|
||||
local door_0_offset = {x=0,y=0,z=0}
|
||||
local door_offset_table = {}
|
||||
local door_pos_table = {}
|
||||
local exit_door_offset = {x=0,y=0,z=0}
|
||||
|
||||
if _drwho_tardis.rooms[type] then
|
||||
minetest.place_schematic(pos, _drwho_tardis.rooms[type].path) --minetest.get_modpath("drwho_tardis") .. "/schems/console_room.mts"
|
||||
door_0_offset = _drwho_tardis.rooms[type].door_0_offset -- = {x=7,y=2,z=16}
|
||||
local d0_pos = vector.add(pos, door_0_offset) -- Schematic adjustments so that the player gets teleported right in front of the door
|
||||
door_pos_table = { door_0 = d0_pos, door_1=nil, door_2=nil }
|
||||
door_offset_table = { door_0 = door_0_offset, door_1=nil, door_2=nil }
|
||||
|
||||
if _drwho_tardis.rooms[type].door_1_offset then
|
||||
local d1_pos = vector.add(pos, _drwho_tardis.rooms[type].door_1_offset)
|
||||
door_offset_table.door_1 = _drwho_tardis.rooms[type].door_1_offset
|
||||
door_pos_table.door_1 = d1_pos
|
||||
end
|
||||
if _drwho_tardis.rooms[type].door_2_offset then
|
||||
local d2_pos = vector.add(pos, _drwho_tardis.rooms[type].door_2_offset)
|
||||
door_offset_table.door_1 = _drwho_tardis.rooms[type].door_1_offset
|
||||
door_pos_table.door_2 = d2_pos
|
||||
end
|
||||
exit_door_offset = _drwho_tardis.rooms[type].exit_door_offset -- = {x=7,y=2,z=16}
|
||||
local exit_door_pos = vector.add(pos, exit_door_offset) -- Schematic adjustments so that the player gets teleported right in front of the door
|
||||
user.console_room.type = type -- Save what type of interior they have
|
||||
user.console_room.exit_door_pos = exit_door_pos -- Remember the door position
|
||||
user.console_room.exit_door_offset = exit_door_offset -- Remember the door offset
|
||||
user.console_room.anchor_pos = pos -- Remember the schematic place anchor pos
|
||||
user.in_pos = exit_door_pos -- save new interior position
|
||||
_drwho_tardis.save_user(name, user) -- save user data
|
||||
return true, "", exit_door_pos -- success, message, door position
|
||||
else
|
||||
return false, "Invalid interior room type! Use /tardis_int to change it.", type -- success, errmsg, int_type
|
||||
end
|
||||
user.interior_rooms.console.type = type -- Save what type of interior they have
|
||||
user.interior_rooms.console.door_pos_table = door_pos_table -- Remember the door positions
|
||||
user.interior_rooms.console.door_offset_table = door_offset_table -- Remember the door offsets
|
||||
user.interior_rooms.console.anchor_pos = pos -- Remember the schematic place anchor pos
|
||||
user.in_pos = door_pos_table.door_0 -- save new interior position
|
||||
_drwho_tardis.save_user(name, user) -- save user data
|
||||
--minetest.log("api.lua 105: "..minetest.serialize(door_pos_table))
|
||||
return true, "", door_pos_table -- success, message, door_pos_table
|
||||
end
|
||||
end
|
||||
|
||||
-- id is the username of the player who owns the Tardis
|
||||
function _drwho_tardis:init_interior_doors(id, door_pos_table)
|
||||
function _drwho_tardis:init_interior_door(id, exit_door_pos)
|
||||
|
||||
local d0meta = minetest.get_meta(door_pos_table.door_0)
|
||||
local d0timer = minetest.get_node_timer(door_pos_table.door_0)
|
||||
d0timer:start(0.2) --start door timer (in case it doesn't start on construct)
|
||||
d0meta:set_string("id", id) --set door id
|
||||
d0meta:set_string("type", "exit") -- set door type
|
||||
-- Some interiors have extra doors
|
||||
if door_pos_table.door_1 then
|
||||
local d1meta = minetest.get_meta(door_pos_table.door_1)
|
||||
local d1timer = minetest.get_node_timer(door_pos_table.door_1)
|
||||
d1meta:set_string("id", id)
|
||||
d1meta:set_string("type", "door_1")
|
||||
d1timer:start(0.2)
|
||||
end
|
||||
if door_pos_table.door_2 then
|
||||
local d2meta = minetest.get_meta(door_pos_table.door_2)
|
||||
local d2timer = minetest.get_node_timer(door_pos_table.door_2)
|
||||
d2meta:set_string("id", id)
|
||||
d2meta:set_string("type", "door_2")
|
||||
d2timer:start(0.2)
|
||||
end
|
||||
return true, door_pos_table
|
||||
local d_meta = minetest.get_meta(exit_door_pos)
|
||||
local d_timer = minetest.get_node_timer(exit_door_pos)
|
||||
d_timer:start(0.2) --start door timer (in case it doesn't start on construct)
|
||||
d_meta:set_string("id", id) --set door id
|
||||
d_meta:set_string("type", "exit") -- set door type
|
||||
return true, exit_door_pos
|
||||
end
|
||||
|
||||
-- [PRIVATE] Rebuilds a player's Tardis (rebuild_tardis)
|
||||
@ -147,32 +123,32 @@ function _drwho_tardis:rebuild_tardis_interior(name)
|
||||
return false, "You don't have a Tardis!" -- success, errmsg
|
||||
end
|
||||
|
||||
local type = user.interior_rooms.console.type
|
||||
local type = user.console_room.type
|
||||
if type=="" or type==nil then type = "default" end -- defaults
|
||||
local door_offset_table = table.copy(user.interior_rooms.console.door_offset_table)
|
||||
if door_offset_table == nil or door_offset_table == "" or door_offset_table == {} then
|
||||
door_offset_table = {door_0=_drwho_tardis.rooms[type].door_0_offset, door_1 = _drwho_tardis.rooms[type].door_1_offset, door_2 = _drwho_tardis.rooms[type].door_2_offset}
|
||||
user.interior_rooms.console.door_offset_table = door_offset_table
|
||||
local exit_door_offset = table.copy(user.console_room.exit_door_offset)
|
||||
if exit_door_offset == nil or exit_door_offset == "" or exit_door_offset == {} then
|
||||
exit_door_offset = _drwho_tardis.rooms[type].exit_door_offset
|
||||
user.console_room.exit_door_offset = exit_door_offset
|
||||
end
|
||||
local door_0_offset = door_offset_table.door_0
|
||||
if door_0_offset=="" or door_0_offset==nil then door_0_offset = {x=7,y=2,z=16} end -- defaults
|
||||
local exit_door_offset = user.console_room.exit_door_offset
|
||||
if exit_door_offset=="" or exit_door_offset==nil then exit_door_offset = {x=7,y=2,z=16} end -- defaults
|
||||
|
||||
-- This ensures that the old and new line up properly
|
||||
local anchor_pos = vector.subtract(in_pos, door_0_offset)
|
||||
local success, msg, door_pos_table = _drwho_tardis:place_tardis_interior(name, type, anchor_pos)
|
||||
local anchor_pos = vector.subtract(in_pos, exit_door_offset)
|
||||
local success, msg, exit_door_pos = _drwho_tardis:place_tardis_interior(name, type, anchor_pos)
|
||||
|
||||
if success == false then
|
||||
_drwho_tardis.save_user(name, user) -- save user data
|
||||
return false, msg, door_pos_table -- door_pos_table is actually the type in this situation after returned by the place API function
|
||||
return false, msg, exit_door_pos -- exit_door_pos is actually the type in this situation after returned by the place API function
|
||||
end
|
||||
|
||||
-- Interior door stuff
|
||||
_drwho_tardis:init_interior_doors(name, door_pos_table)
|
||||
_drwho_tardis:init_interior_door(name, exit_door_pos)
|
||||
|
||||
-- Clear Time Rotor pos because that doesn't exist anymore
|
||||
_drwho_tardis.update_one_value(name, "r_pos", "")
|
||||
|
||||
return true, "", door_pos_table -- success!
|
||||
return true, "", exit_door_pos -- success!
|
||||
end
|
||||
|
||||
-- Check if the Time Rotor is there or not
|
||||
|
34
init.lua
34
init.lua
@ -92,22 +92,20 @@ minetest.register_chatcommand("ext_list", {
|
||||
})
|
||||
|
||||
-- Fix interior doors
|
||||
minetest.register_chatcommand("reset_in_doors", {
|
||||
minetest.register_chatcommand("reset_door", {
|
||||
params = "",
|
||||
description = S("Resets your Tardis interior console doors and fixes their timers"),
|
||||
description = S("Resets your Tardis interior console door and fixes it's timer"),
|
||||
privs = {},
|
||||
func = function(name)
|
||||
local user = _drwho_tardis.get_user(name)
|
||||
local door_pos_table = user.interior_rooms.console.door_pos_table
|
||||
if not door_pos_table or door_pos_table == "" or door_pos_table == {} then
|
||||
door_pos_table = {}
|
||||
door_pos_table.door_0 = user.in_pos
|
||||
user.interior_rooms.console.door_pos_table = door_pos_table
|
||||
local exit_door_pos = user.console_room.exit_door_pos
|
||||
if not exit_door_pos or exit_door_pos == "" or exit_door_pos == {} then
|
||||
exit_door_pos = user.in_pos
|
||||
user.console_room.exit_door_pos = exit_door_pos
|
||||
end
|
||||
_drwho_tardis.save_user(name, user) -- save user data
|
||||
--minetest.log("init.lua line 116: "..minetest.serialize(door_pos_table))
|
||||
_drwho_tardis:init_interior_doors(name, door_pos_table)
|
||||
minetest.chat_send_player(name, S("interior doors are now reset"))
|
||||
_drwho_tardis:init_interior_door(name, exit_door_pos)
|
||||
minetest.chat_send_player(name, S("interior door is now reset"))
|
||||
end
|
||||
})
|
||||
|
||||
@ -200,24 +198,18 @@ minetest.register_chatcommand("rebuild_tardis", {
|
||||
func = function(name)
|
||||
local user = _drwho_tardis.get_user(name) -- get user data
|
||||
-- This uses a private API function
|
||||
local success, errmsg, door_pos_table = _drwho_tardis:rebuild_tardis_interior(name)
|
||||
local success, errmsg, exit_door_pos = _drwho_tardis:rebuild_tardis_interior(name)
|
||||
local _, __, pos = drwho_tardis.get:tardis_ext_position(name) -- public function
|
||||
local in_pos = user.in_pos
|
||||
user.interior_rooms.console.door_pos_table = door_pos_table
|
||||
local in_pos = table.copy(user.in_pos)
|
||||
user.console_room.exit_door_pos = exit_door_pos
|
||||
_drwho_tardis.save_user(name, user) -- save user data
|
||||
|
||||
if success then
|
||||
minetest.chat_send_player(name, S("Tardis interior rebuilt!"))
|
||||
minetest.chat_send_player(name, S("type: @1", user.interior_rooms.console.type))
|
||||
minetest.chat_send_player(name, S("type: @1", user.console_room.type))
|
||||
minetest.chat_send_player(name, S("owner: @1", name))
|
||||
minetest.chat_send_player(name, S("exterior location: @1, @2, @3 [X,Y,Z]", pos.x, pos.y, pos.z))
|
||||
minetest.chat_send_player(name, S("interior door 0 (exit) location: @1, @2, @3 [X,Y,Z]", in_pos.x, in_pos.y, in_pos.z))
|
||||
if door_pos_table.door_1 then
|
||||
minetest.chat_send_player(name, S("interior door 1 location: @1, @2, @3 [X,Y,Z]", door_pos_table.door_1.x, door_pos_table.door_1.y, door_pos_table.door_1.z))
|
||||
end
|
||||
if door_pos_table.door_2 then
|
||||
minetest.chat_send_player(name, S("interior door 2 location: @1, @2, @3 [X,Y,Z]", door_pos_table.door_2.x, door_pos_table.door_2.y, door_pos_table.door_2.z))
|
||||
end
|
||||
minetest.chat_send_player(name, S("interior exit door location: @1, @2, @3 [X,Y,Z]", in_pos.x, in_pos.y, in_pos.z))
|
||||
else minetest.chat_send_player(name, S("Error message: @1", errmsg)) end
|
||||
end
|
||||
})
|
||||
|
@ -35,36 +35,28 @@ elseif _drwho_tardis.GAMETYPE == "rp" then
|
||||
_drwho_tardis.interiorDepth = -10000
|
||||
end
|
||||
|
||||
-- Interior rooms, console or otherwise
|
||||
-- door_0_offset is from where the schem is placed to where the exit door is
|
||||
-- requires is a list of mods whose nodes are used in the interior, and may be used to ensure there are no unknown nodes. Although default interiors should strive to only use nodes from this mod.
|
||||
-- door_<1 or 2>_offset is defined if that room has other Tardis doors which can lead somewhere else.
|
||||
-- pre-built interior console rooms.
|
||||
-- exit_door_offset is from where the schem is placed to where the exit door is
|
||||
-- requires is a list of mods whose nodes are used in the interior, and may be used to ensure there are no unknown nodes.
|
||||
-- Although default interiors should strive to only use nodes from this mod.
|
||||
_drwho_tardis.rooms = {
|
||||
old = {
|
||||
type = "old",
|
||||
room_type = "console",
|
||||
path = minetest.get_modpath("drwho_tardis").."/schems/tardis_console_room_old.mts",
|
||||
door_0_offset = {x=7,y=2,z=16},
|
||||
door_1_offset = nil,
|
||||
door_2_offset = nil,
|
||||
exit_door_offset = {x=7,y=2,z=16},
|
||||
requires = {"drwho_tardis"},
|
||||
},
|
||||
default = {
|
||||
type = "default",
|
||||
room_type = "console",
|
||||
-- size is 22x22x22
|
||||
path = minetest.get_modpath("drwho_tardis").."/schems/tardis_console_room_default.mts",
|
||||
door_0_offset = {x=11,y=5,z=19}, -- exit door
|
||||
door_1_offset = {x=19,y=6,z=11}, -- door on the left
|
||||
door_2_offset = {x=3,y=6,z=11}, -- door on the right
|
||||
exit_door_offset = {x=11,y=5,z=19},
|
||||
requires = {"drwho_tardis"},
|
||||
},
|
||||
--[[green = {
|
||||
type = "green",
|
||||
room_type = "console",
|
||||
path = minetest.get_modpath("drwho_tardis").."/schems/tardis_console_room_green.mts",
|
||||
door_0_offset = {x=6,y=2,z=11},
|
||||
door_1_offset = nil,
|
||||
door_2_offset = nil,
|
||||
exit_door_offset = {x=6,y=2,z=11},
|
||||
requires = {"drwho_tardis", "scifi_nodes"},
|
||||
},--]]
|
||||
}
|
||||
@ -160,50 +152,16 @@ function _drwho_tardis.init_new_user(user_name, user)
|
||||
user.exterior_skin = "drwho_tardis:tardis_blue" -- The outside of the Tardis. Previously 'look'
|
||||
|
||||
|
||||
-- seemingly complex data table of all the Tardis interior rooms
|
||||
-- We need to know:
|
||||
-- the type, that identifies what schematic was used to place it
|
||||
-- where each door is for when they get teleported to those doors
|
||||
-- the difference in position between where we placed the schematic and where the doors are
|
||||
-- where we placed the schematic (anchor_pos)
|
||||
-- door_0 is always the door to exit that particular room / the Tardis itself.
|
||||
-- door_1 and door_2 only exist in the console room and go to room_1 or room_2 respectively.
|
||||
user.interior_rooms = {
|
||||
console = {
|
||||
type = minetest.settings:get('drwho_tardis.default_interior') or 'default',
|
||||
door_pos_table = { -- set when the interior is placed. Contains vectors of where the Console Room's doors are.
|
||||
door_0 = "", -- door to exit the Tardis
|
||||
door_1 = "", -- door leading to room_1
|
||||
door_2 = "", -- door leading to room_2
|
||||
},
|
||||
door_offset_table = { -- Difference between the anchor_pos when placing the console room and the doors
|
||||
door_0 = "", -- door to exit the Tardis
|
||||
door_1 = "", -- door leading to room_1
|
||||
door_2 = "", -- door leading to room_2
|
||||
},
|
||||
anchor_pos = vector.new(0, 0, 0) -- previously console_place_pos. The position given to the place interior schematic function.
|
||||
},
|
||||
room_1 = {
|
||||
type = "",
|
||||
door_pos_table = {
|
||||
door_0 = "", -- door to go to console room
|
||||
},
|
||||
door_offset_table = { -- Difference between the anchor_pos when placing the console room and the doors
|
||||
door_0 = "", -- door to go to console room
|
||||
},
|
||||
anchor_pos = vector.new(0, 0, 0) -- The position given to the place interior schematic function.
|
||||
},
|
||||
room_2 = {
|
||||
type = "",
|
||||
door_pos_table = {
|
||||
door_0 = "", -- door to go to console room
|
||||
},
|
||||
door_offset_table = { -- Difference between the anchor_pos when placing the console room and the doors
|
||||
door_0 = "", -- door to go to console room
|
||||
},
|
||||
anchor_pos = vector.new(0, 0, 0) -- The position given to the place interior schematic function.
|
||||
},
|
||||
}
|
||||
-- the type, that identifies what schematic was used to place it
|
||||
-- the difference in position between where we placed the schematic and where the door is
|
||||
-- where we placed the schematic (anchor_pos)
|
||||
user.console_room = {
|
||||
type = minetest.settings:get('drwho_tardis.default_interior') or 'default',
|
||||
exit_door_pos = "",
|
||||
exit_door_offset = "",
|
||||
anchor_pos = vector.new(0, 0, 0) -- previously console_place_pos. The position given to the place interior schematic function.
|
||||
},
|
||||
|
||||
|
||||
-- Save it
|
||||
@ -245,19 +203,12 @@ function _drwho_tardis.migrate_user_data(user_name, user)
|
||||
|
||||
user.exterior_skin = data:get_string(id.."look")
|
||||
|
||||
|
||||
-- seemingly complex data table of all the Tardis interior rooms
|
||||
-- for explanation see comment in init_new_user
|
||||
user.interior_rooms = {
|
||||
console = {
|
||||
type = data:get_string(id.."type"),
|
||||
door_pos_table = minetest.deserialize(data:get_string(id.."door_pos_table")),
|
||||
door_offset_table = minetest.deserialize(data:get_string(id.."door_offset_table")),
|
||||
anchor_pos = minetest.deserialize(data:get_string(id.."console_place_pos")),
|
||||
},
|
||||
-- room_1 and room_2 did not exist pre-1.3.0
|
||||
}
|
||||
|
||||
user.console_room = {
|
||||
type = data:get_string(id.."type"),
|
||||
exit_door_pos = minetest.deserialize(data:get_string(id.."door_pos_table")).door_0,
|
||||
exit_door_offset = minetest.deserialize(data:get_string(id.."door_offset_table")).door_0,
|
||||
anchor_pos = minetest.deserialize(data:get_string(id.."console_place_pos")),
|
||||
},
|
||||
|
||||
-- Remember that their data has been migrated
|
||||
data:set_string(id.."data_migrated", "yes")
|
||||
@ -388,7 +339,7 @@ _drwho_tardis.drwho_items = {
|
||||
azbantium_shard = "drwho_tardis:azbantium_shard",
|
||||
dalekanium_ingot = "drwho_tardis:dalekanium_ingot",
|
||||
-- Nodes crafted:
|
||||
tardis = "drwho_tardis:tardis_blue", -- default Tardis is now the blue one
|
||||
tardis = "drwho_tardis:tardis_blue",
|
||||
lab = "drwho_tardis:lab",
|
||||
vortex_manipulator = "drwho_tardis:vortex_manipulator",
|
||||
rassilon_gauntlet = "drwho_tardis:rassilon_gauntlet",
|
||||
|
@ -24,11 +24,10 @@ local function tardis_on_place(pos, placer, itemstack, pointed_thing)
|
||||
_drwho_tardis.save_user(name, user) -- save user data
|
||||
local room = minetest.settings:get('drwho_tardis.default_interior')
|
||||
if _drwho_tardis.rooms[room] then room = room else room = "default" end
|
||||
local _, msg, door_pos_table = _drwho_tardis:place_tardis_interior(name, room, pos)
|
||||
local _, msg, exit_door_pos = _drwho_tardis:place_tardis_interior(name, room, pos)
|
||||
minetest.chat_send_player(name, S("After you walk inside your Tardis, if the cave generation has broken through it, you will have to run the chat command /rebuild_tardis. Make sure you are somewhere where you won't get blocked out of it though."))
|
||||
|
||||
-- Interior door stuff
|
||||
_drwho_tardis:init_interior_doors(name, door_pos_table)
|
||||
_drwho_tardis:init_interior_door(name, exit_door_pos)
|
||||
|
||||
meta:set_string("id", name) -- set exterior id
|
||||
timer:start(0.2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user