init; added sitting animation for some chairs, added inventory for lockers
This commit is contained in:
commit
4e053b6d48
62 changed files with 58620 additions and 0 deletions
232
init.lua
Normal file
232
init.lua
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
local cbox = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}}
|
||||
|
||||
local cboard_box = {{-0.5, -0.5, 0.45, 1.5, 0.5, 0.5}}
|
||||
|
||||
local chair_box = {{-0.4, -0.5, -0.2, 0.4, 0.2, 0.4},
|
||||
{-0.4, 0, 0.3, 0.4, 0.7, 0.4}}
|
||||
|
||||
local desk_box = {{-0.5, -0.5, -0.25, 0.5, 0.4, 0.5}}
|
||||
|
||||
local schair_box = {{-0.3, -0.5, -0.3, 0.3, 0, 0.3}}
|
||||
|
||||
local tdesk_box = {{-0.5, -0.5, -0.5, 1.5, 0.5, 0.5}}
|
||||
|
||||
local fe_box = {{-0.2, -0.5, 0.2, 0.2, 0.2, 0.5}}
|
||||
|
||||
local fel_box = {{-0.3, -0.5, 0.1, 0.3, 0.5, 0.5}}
|
||||
|
||||
local book_box = {{-0.5, -0.5, 0, 0.5, 0.5, 0.5}}
|
||||
|
||||
local poster_box = {{-0.3, -0.5, 0.48, 0.3, 0.5, 0.5}}
|
||||
|
||||
local clock_box = {{-0.4, -0.4, 0.4, 0.4, 0.4, 0.5}}
|
||||
|
||||
local bell_box = {{-0.3, -0.3, 0.4, 0.3, 0.3, 0.5}}
|
||||
|
||||
local map_box = {{-0.5, -0.5, 0.48, 1.5, 0.5, 0.5}}
|
||||
|
||||
local lockers_box = {{-0.5, -0.5, 0, 0.5, 1.5, 0.5}}
|
||||
|
||||
local exit_box = {{-0.25, 0.1, -0.1, 0.25, 0.5, 0.1}}
|
||||
|
||||
local light_box = {{-0.5, 0.48, -0.3, 0.5, 0.5, 0.3}}
|
||||
|
||||
local trash_box = {{-0.3, -0.5, -0.3, 0.3, 0.1, 0.3}}
|
||||
|
||||
local ceiling_box = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}}
|
||||
|
||||
local window_box = {{-0.5, -0.5, -0.1, 0.5, 0.5, 0.1}}
|
||||
|
||||
local door_box = {{-0.5, -0.5, -0.1, 0.5, 1.5, 0.1}}
|
||||
|
||||
local door2_box = {{-0.5, -0.5, 0, -0.3, 1.5, 1}}
|
||||
|
||||
local fountain_box = {{-0.3, -0.1, 0, 0.3, 0.5, 0.5}}
|
||||
|
||||
local bookshelf_box = {{-0.5, -0.5, 0, 0.5, 0.5, 0.5}}
|
||||
|
||||
local book_box = {{-0.3, -0.5, -0.3, 0.3, -0.3, 0.3}}
|
||||
|
||||
local book2_box = {{-0.4, -0.5, -0.3, 0.2, -0.4, 0.3}}
|
||||
|
||||
|
||||
local nodes = {--name, description, texture, model, selection_box/collision_box
|
||||
{"chalkboard", "Chaulkboard", "chalkboard", "chalkboard", cboard_box},
|
||||
{"chair", "Chair", "chair", "chair", chair_box},
|
||||
{"school_desk_chair", "School Desk Chair", "school_desk_chair", "school_desk_chair", schair_box},
|
||||
{"school_desk_chair2", "School Desk Chair 2", "school_desk_chair2", "school_desk_chair", schair_box},
|
||||
{"school_desk", "School Desk", "school_desk", "school_desk", desk_box},
|
||||
{"reception", "Reception", "reception", "reception", tdesk_box},
|
||||
{"teacher_desk", "Teacher Desk", "teacher_desk", "teacher_desk", tdesk_box},
|
||||
{"fire_extinguisher", "Fire Extinguisher", "fire_extinguisher", "fire_extinguisher", fe_box},
|
||||
{"fire_extinguisher_large", "Large Fire Extinguisher", "fire_extinguisher", "fire_extinguisher_large", fel_box},
|
||||
{"bookshelf", "Bookshelf", "bookshelf", "bookshelf", bookshelf_box},
|
||||
{"poster1", "Poster 1", "poster1", "poster", poster_box},
|
||||
{"poster2", "Poster 2", "poster2", "poster", poster_box},
|
||||
{"poster3", "Poster 3", "poster3", "poster", poster_box},
|
||||
{"poster4", "Poster 4", "poster4", "poster", poster_box},
|
||||
{"clock", "Clock", "clock", "clock", clock_box},
|
||||
{"fire_bell", "Fire Bell", "fire_bell", "fire_bell", bell_box},
|
||||
{"map", "Map", "map", "map", map_box},
|
||||
{"lockers", "Lockers", "lockers", "lockers", lockers_box},
|
||||
{"exit_sign", "Exit Sign", "exit", "exit", exit_box},
|
||||
{"light", "Light", "light", "light", light_box},
|
||||
{"trash_can", "Trash Can", "trash_can", "trash_can", trash_box},
|
||||
{"ceiling", "Ceiling/Floor", "ceiling", "ceiling", ceiling_box},
|
||||
{"bookshelf_full_1", "Bookshelf", "bookshelf_full_1", "bookshelf_full_1", bookshelf_box},
|
||||
{"bookshelf_full_2", "Bookshelf", "bookshelf_full_2", "bookshelf_full_2", bookshelf_box},
|
||||
{"bookshelf_full_3", "Bookshelf", "bookshelf_full_3", "bookshelf_full_3", bookshelf_box},
|
||||
{"window", "Window", "window", "window", window_box},
|
||||
{"door", "Door", "door", "door", door_box},
|
||||
{"door2", "Door", "door", "door2", door2_box},
|
||||
{"fountain", "Fountain", "fountain", "fountain", fountain_box},
|
||||
{"book_open", "Open Book", "book_open", "book_open", book_box},
|
||||
{"book_closed", "Closed Book", "book_closed", "book_closed", book2_box},
|
||||
}
|
||||
|
||||
for i in ipairs(nodes) do
|
||||
local nam = nodes[i][1]
|
||||
local des = nodes[i][2]
|
||||
local img = nodes[i][3]
|
||||
local mod = nodes[i][4]
|
||||
local box = nodes[i][5]
|
||||
|
||||
core.register_node("myschool:"..nam,{
|
||||
description = des,
|
||||
tiles = {"myschool_"..img..".png"},
|
||||
drawtype = "mesh",
|
||||
mesh = "myschool_"..mod..".obj",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky = 1, choppy = 1, oddly_breakable_by_hand = 1},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = box
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = box
|
||||
},
|
||||
})
|
||||
if core.get_modpath("lucky_block") then
|
||||
lucky_block:add_blocks({
|
||||
{"dro", {"myschool:"..nam}, 2},
|
||||
})
|
||||
end
|
||||
end
|
||||
minetest.override_item("myschool:exit_sign",{
|
||||
light_source = 3,})
|
||||
minetest.override_item("myschool:light",{
|
||||
light_source = 14,})
|
||||
minetest.override_item("myschool:window",{
|
||||
use_texture_alpha = "blend",})
|
||||
minetest.override_item("myschool:door",{
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
core.set_node(pos,{name="myschool:door2", param2 = node.param2})
|
||||
end})
|
||||
minetest.override_item("myschool:door2",{
|
||||
groups = {cracky = 1, choppy = 1, oddly_breakable_by_hand = 1, not_in_creative_inventory=1},
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
core.set_node(pos,{name="myschool:door", param2 = node.param2})
|
||||
end})
|
||||
|
||||
-- Hilfsfunktion: Klick von oben prüfen
|
||||
local function top_face(pointed_thing)
|
||||
if not pointed_thing then return false end
|
||||
return pointed_thing.above.y > pointed_thing.under.y
|
||||
end
|
||||
|
||||
-- Sitz-Logik: Alle Stühle nutzen die exakt gleiche Position
|
||||
local function myschool_sit(pos, node, clicker, pointed_thing)
|
||||
if not top_face(pointed_thing) then return end
|
||||
local player_name = clicker:get_player_name()
|
||||
|
||||
-- Einfacher Toggle: Wenn man bereits sitzt (egal wo), steht man auf.
|
||||
if default.player_attached[player_name] then
|
||||
clicker:set_physics_override({ speed = 1, jump = 1, gravity = 1 })
|
||||
clicker:set_eye_offset({x=0, y=0, z=0}, {x=0, y=0, z=0})
|
||||
-- Auf den Boden vor/auf den Stuhl setzen
|
||||
clicker:set_pos({x = pos.x, y = pos.y - 0.5, z = pos.z})
|
||||
default.player_attached[player_name] = false
|
||||
default.player_set_animation(clicker, "stand", 30)
|
||||
else
|
||||
-- Hinsetzen
|
||||
-- 1. Physik zuerst auf 0, um das "Gleiten" zu verhindern
|
||||
clicker:set_physics_override({ speed = 0, jump = 0, gravity = 0 })
|
||||
-- 2. Kamera-Höhe anpassen
|
||||
clicker:set_eye_offset({x=0, y=-7, z=2}, {x=0, y=0, z=0})
|
||||
-- 3. Teleport exakt in die Mitte (pos)
|
||||
clicker:set_pos({x = pos.x, y = pos.y, z = pos.z})
|
||||
|
||||
default.player_attached[player_name] = true
|
||||
default.player_set_animation(clicker, "sit", 30)
|
||||
|
||||
-- Rotation basierend auf facedir
|
||||
local yaw = 0
|
||||
if node.param2 == 0 then yaw = 3.15
|
||||
elseif node.param2 == 1 then yaw = 7.9
|
||||
elseif node.param2 == 2 then yaw = 6.28
|
||||
elseif node.param2 == 3 then yaw = 4.75 end
|
||||
clicker:set_look_yaw(yaw)
|
||||
end
|
||||
end
|
||||
|
||||
-- --- OVERRIDES ---
|
||||
|
||||
-- 1. Alle Stuhl-Typen (Chair, Desk Chair 1 & 2)
|
||||
local chairs = {"myschool:chair", "myschool:school_desk_chair", "myschool:school_desk_chair2"}
|
||||
for _, name in ipairs(chairs) do
|
||||
minetest.override_item(name, {
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
myschool_sit(pos, node, clicker, pointed_thing)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- 2. Lockers (Spinde) mit 3x3 Inventar
|
||||
minetest.override_item("myschool:lockers", {
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:get_inventory():set_size("main", 3 * 3)
|
||||
meta:set_string("infotext", "Locker")
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
local name = "nodemeta:" .. pos.x .. "," .. pos.y .. "," .. pos.z
|
||||
local fs = "size[8,9]" ..
|
||||
"list[" .. name .. ";main;2.5,0.5;3,3;]" ..
|
||||
"list[current_player;main;0,4.85;8,4;]" ..
|
||||
"listring[" .. name .. ";main]listring[current_player;main]"
|
||||
minetest.show_formspec(clicker:get_player_name(), "myschool:locker_fs", fs)
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
return minetest.get_meta(pos):get_inventory():is_empty("main")
|
||||
end,
|
||||
})
|
||||
|
||||
-- 3. Trash Can (Mülleimer)
|
||||
minetest.override_item("myschool:trash_can", {
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:get_inventory():set_size("trash", 1)
|
||||
meta:set_string("infotext", "Trash Can")
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
local name = "nodemeta:" .. pos.x .. "," .. pos.y .. "," .. pos.z
|
||||
local fs = "size[8,5]label[3.5,0;Trash Bin]" ..
|
||||
"list[" .. name .. ";trash;3.5,0.5;1,1;]" ..
|
||||
"list[current_player;main;0,1.5;8,4;]"
|
||||
minetest.show_formspec(clicker:get_player_name(), "myschool:trash_fs", fs)
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if listname == "trash" then
|
||||
minetest.get_meta(pos):get_inventory():set_stack(listname, index, nil)
|
||||
minetest.sound_play("default_dig_crumbly", {pos = pos, gain = 0.5})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- 4. Ceiling lässt kein Licht durch
|
||||
minetest.override_item("myschool:ceiling", {
|
||||
paramtype = "none",
|
||||
sunlight_propagates = false,
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue