https://www.youtube.com/watch?v=KfL1VCv2 ( ͡° ͜ʖ ͡°)
BIN
blends/Bamboo.blend
Normal file
BIN
blends/Bed.blend
Normal file
BIN
blends/Bed.blend1
Normal file
BIN
blends/Bed_in_use.blend
Normal file
BIN
blends/Bed_in_use.blend1
Normal file
BIN
blends/Bed_render.blend
Normal file
BIN
blends/Cactus.blend
Normal file
BIN
blends/Dresser.blend
Normal file
BIN
blends/base_armour.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
blends/base_armour_straps.png
Normal file
After Width: | Height: | Size: 227 B |
BIN
blends/character.blend
Normal file
BIN
blends/character.blend1
Normal file
BIN
blends/character1.blend
Normal file
BIN
blends/chest_locked.blend
Normal file
BIN
blends/chest_unlocked.blend
Normal file
BIN
blends/door_closed_3px.blend
Normal file
BIN
blends/door_open_3px.blend
Normal file
BIN
blends/dummy.blend
Normal file
BIN
blends/mirror.blend
Normal file
BIN
menu/header.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
menu/icon.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
1
minetest.conf
Normal file
@ -0,0 +1 @@
|
||||
secure.enable_security = false
|
2
mods/beds/depends.txt
Normal file
@ -0,0 +1,2 @@
|
||||
core
|
||||
wardrobe
|
528
mods/beds/init.lua
Normal file
@ -0,0 +1,528 @@
|
||||
-- beds Jordach / Solar Plains edition
|
||||
|
||||
-- namespace this badboy
|
||||
|
||||
beds = {}
|
||||
|
||||
--[[
|
||||
|
||||
Notes:
|
||||
|
||||
Times returned from "minetest.get_timeofday()"
|
||||
|
||||
0 is 12:00 AM
|
||||
0.23 is 5:30 AM
|
||||
0.25 is 6:00 AM
|
||||
|
||||
0.5 is 12:00 PM
|
||||
0.75 is 18:00 or 6:00 PM
|
||||
0.79 is 19:00 or 7:00 PM
|
||||
|
||||
]]--
|
||||
|
||||
-- time to set the "alarm clock" for sleeping players; use table above for more information.
|
||||
|
||||
local wake_time = 0.24
|
||||
|
||||
-- percent needed (of players sleeping) to pass the night
|
||||
-- set this to 1 if you need all players sleeping
|
||||
-- default setting is 25% of all players.
|
||||
|
||||
local percent_needed = 0.25
|
||||
|
||||
-- enable closing of eyes while sleeping;
|
||||
-- requires Solar Plains' Wardrobe mod.
|
||||
-- by default this setting is true.
|
||||
-- set to false to disable it.
|
||||
|
||||
beds.use_wardrobe_support = false
|
||||
|
||||
-- enable waking players from their beds when the morning arrives
|
||||
-- after the sleep vote has completed
|
||||
-- true by default; use false to disable
|
||||
-- this can be enabled for players who whish to AFK for periods
|
||||
-- of time.
|
||||
|
||||
beds.wake_sleeping_players = true
|
||||
|
||||
|
||||
-- how long before the pass night check runs again:
|
||||
-- 30 seconds by default;
|
||||
|
||||
local pass_night_timer = 30
|
||||
|
||||
-- enable a wakeup jingle and seasonal specific jingles.
|
||||
-- true by default; enabled globally by default,
|
||||
-- players can opt out at anytime using a button in the formspec.
|
||||
-- player attribute is beds_enable_jingle
|
||||
-- usable settings are true, false
|
||||
-- Note: Players must opt into it, but the server can disable the feature if required.
|
||||
|
||||
local enable_morning_jingle = true
|
||||
|
||||
-- make it gentle; not too loud
|
||||
-- default setting is 0.25
|
||||
-- acceptable settings range from 0 -> 1, including floating point numbers.
|
||||
|
||||
local jingle_volume = 0.25
|
||||
|
||||
-- sleeping players represented as:
|
||||
-- player_sleeping[player_name] = true
|
||||
-- and the following;
|
||||
-- player_sleeping[player_name] = false
|
||||
|
||||
local player_sleeping = {}
|
||||
|
||||
-- storage for what bed the player initially slept in (for swapping between models)
|
||||
|
||||
-- beds are represented as:
|
||||
-- player_bed_swap[player_name] = "beds:red_empty" (note: node is an example;)
|
||||
-- this will be updated everytime the player lays in a bed, and should be expected to be that
|
||||
-- bed the player has recently slept / lay'd in.
|
||||
|
||||
local player_bed_swap = {}
|
||||
|
||||
-- param works the same as above, stores a number instead of a string
|
||||
|
||||
local player_bed_param = {}
|
||||
|
||||
-- utilities;
|
||||
|
||||
local pi = math.pi
|
||||
|
||||
|
||||
local function get_nodedef_field(nodename, fieldname) -- gets a feature of a block, eg walkable, or waving and so on
|
||||
-- usage: "node:name", "walkable"
|
||||
|
||||
if not minetest.registered_nodes[nodename] then
|
||||
|
||||
return nil
|
||||
|
||||
end
|
||||
|
||||
return minetest.registered_nodes[nodename][fieldname]
|
||||
|
||||
end
|
||||
|
||||
function beds.get_yaw_from_facedir(pos) -- turns facedir into a useful yaw direction for players or for nodes wanting that facedir number
|
||||
|
||||
local n = minetest.get_node(pos).param2
|
||||
|
||||
if n == 1 then
|
||||
return pi / 2, n
|
||||
--return 1.5708, n
|
||||
elseif n == 3 then
|
||||
--return -pi / 2, n
|
||||
return 4.71239, n
|
||||
elseif n == 0 then
|
||||
return pi, n
|
||||
--return 3.14159, n
|
||||
else
|
||||
-- there's a rotation bug with using -pi
|
||||
return 0, n
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function beds.play_jingle(player) --players who don't sleep don't get the jingle
|
||||
|
||||
-- check for seasonal and special days on the calendar here;
|
||||
-- currently TODO
|
||||
|
||||
if player:get_attribute("beds_enable_jingle") == "true" and enable_morning_jingle then
|
||||
|
||||
local jingle = minetest.sound_play("beds_morning_1", {
|
||||
|
||||
to_player = player:get_player_name(),
|
||||
gain = jingle_volume,
|
||||
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- formspec to display the button to leave the bed;
|
||||
|
||||
local function beds_formspec(player)
|
||||
|
||||
local jingle_image_state = ""
|
||||
local jingle_image_state_push = ""
|
||||
|
||||
if player:get_attribute("beds_enable_jingle") == "true" then
|
||||
|
||||
jingle_image_state = "beds_sound_enabled.png"
|
||||
jingle_image_state_push = "beds_sound_enabled_push.png"
|
||||
|
||||
else
|
||||
|
||||
jingle_image_state = "beds_sound_disabled.png"
|
||||
jingle_image_state_push = "beds_sound_disabled_push.png"
|
||||
|
||||
end
|
||||
|
||||
local formspec = "size[8.15,3]" ..
|
||||
"button[2.93,2.5;2.15,1;beds_exit;Get out of bed.]"..
|
||||
--"button[6.75,-0.3;1.5,1;beds_chat_snd;Send]"..
|
||||
"field[0.35,0;8.15,1;beds_chat;;]"..
|
||||
"image_button[7.35,2.5;1,1;"..jingle_image_state..";beds_ui_jingle;;true;false;"..jingle_image_state_push.."]"
|
||||
|
||||
return formspec
|
||||
|
||||
end
|
||||
|
||||
function beds.pass_night() -- wakes players when called and sets it to morning.
|
||||
minetest.set_timeofday(wake_time)
|
||||
|
||||
minetest.after(2, function()
|
||||
|
||||
if beds.wake_sleeping_players then
|
||||
|
||||
beds.wake_players()
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
function beds.wake_players() -- only to be used within a globalstep!!!
|
||||
|
||||
players = minetest.get_connected_players()
|
||||
|
||||
for key, pl in pairs(players) do
|
||||
|
||||
local pname = pl:get_player_name()
|
||||
|
||||
if player_sleeping[pname] == true then -- look for players who are actually sleeping
|
||||
|
||||
local pos2 = pl:get_pos()
|
||||
|
||||
minetest.set_node(pos2, {name=player_bed_swap[pname], param1=0, param2=player_bed_param[pname]})
|
||||
|
||||
local pos = minetest.string_to_pos(pl:get_attribute("beds_spawn"))
|
||||
|
||||
if pos == nil then return end -- unlikely, but this is Minetest
|
||||
|
||||
player_sleeping[pname] = false
|
||||
|
||||
pl:set_pos(pos)
|
||||
pl:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||
|
||||
wardrobe.apply_to_player(pl)
|
||||
|
||||
beds.play_jingle(pl)
|
||||
|
||||
minetest.close_formspec(pl:get_player_name(), "beds_ui")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function beds.wake_specific_player(player) -- for those sleepy people (or leaving the formspec early!)
|
||||
|
||||
local pos = minetest.string_to_pos(player:get_attribute("beds_spawn"))
|
||||
|
||||
if pos == nil then return end -- unlikely, but this is Minetest
|
||||
|
||||
local pname = player:get_player_name()
|
||||
|
||||
player_sleeping[pname] = false
|
||||
|
||||
local pos2 = player:get_pos()
|
||||
|
||||
minetest.set_node(pos2, {name=player_bed_swap[pname], param1=0, param2=player_bed_param[pname]})
|
||||
|
||||
player:set_pos(pos)
|
||||
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||
--local hud_f = player:hud_get_flags()
|
||||
--hud_f.wielditem = true
|
||||
wardrobe.apply_to_player(player)
|
||||
minetest.close_formspec(pname, "beds_ui")
|
||||
end
|
||||
|
||||
function beds.set_respawn_point(pos, player, param)
|
||||
|
||||
--[[
|
||||
facedir 0 is +x and -x (left and right)
|
||||
facedir 1 is +z and -z (left and right)
|
||||
facedir 2 is +x and -x (left and right)
|
||||
facedir 3 is +z and -z (left and right)
|
||||
|
||||
these are relative to each facedir; keep this in mind.
|
||||
]]--
|
||||
|
||||
local pname = player:get_player_name()
|
||||
|
||||
minetest.chat_send_player(player:get_player_name(), "Spawnpoint set!")
|
||||
local p = {x=pos.x, y=pos.y, z=pos.z}
|
||||
local air = {x=pos.x, y=pos.y, z=pos.z}
|
||||
|
||||
local nname = minetest.get_node(p).name
|
||||
|
||||
if param == 0 or param == 2 then -- bed headrest and footer are pointing and north and south
|
||||
p = {x=pos.x-1, y=pos.y-1, z=pos.z}
|
||||
air = {x=pos.x-1, y=pos.y, z=pos.z}
|
||||
|
||||
nname = minetest.get_node(p).name
|
||||
|
||||
if get_nodedef_field(nname, "walkable") == true and minetest.get_node(air).name == "air" then
|
||||
p = {x=pos.x-1, y=pos.y+0.25, z=pos.z}
|
||||
player:set_attribute("beds_spawn", minetest.pos_to_string(p))
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
p = {x=pos.x+1, y=pos.y-1, z=pos.z}
|
||||
air = {x=pos.x+1, y=pos.y, z=pos.z}
|
||||
|
||||
nname = minetest.get_node(p).name
|
||||
|
||||
if get_nodedef_field(nname, "walkable") == true and minetest.get_node(air).name == "air" then
|
||||
p = {x=pos.x+1, y=pos.y+0.25, z=pos.z}
|
||||
player:set_attribute("beds_spawn", minetest.pos_to_string(p))
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- failure to set a spawn on either side of the bed:
|
||||
|
||||
p = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||
player:set_attribute("beds_spawn", minetest.pos_to_string(p))
|
||||
|
||||
return
|
||||
|
||||
elseif param == 1 or param == 3 then -- bed headrest and footer are pointing east and west
|
||||
|
||||
p = {x=pos.x, y=pos.y-1, z=pos.z-1}
|
||||
air = {x=pos.x, y=pos.y, z=pos.z-1}
|
||||
|
||||
nname = minetest.get_node(p).name
|
||||
|
||||
if get_nodedef_field(nname, "walkable") == true and minetest.get_node(air).name == "air" then
|
||||
p = {x=pos.x, y=pos.y+0.25, z=pos.z-1}
|
||||
player:set_attribute("beds_spawn", minetest.pos_to_string(p))
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
p = {x=pos.x, y=pos.y-1, z=pos.z+1}
|
||||
air = {x=pos.x, y=pos.y, z=pos.z+1}
|
||||
|
||||
nname = minetest.get_node(p).name
|
||||
|
||||
if get_nodedef_field(nname, "walkable") == true and minetest.get_node(air).name == "air" then
|
||||
p = {x=pos.x, y=pos.y+0.25, z=pos.z+1}
|
||||
player:set_attribute("beds_spawn", minetest.pos_to_string(p))
|
||||
return
|
||||
end
|
||||
|
||||
-- failure to set a spawn on either side of the bed:
|
||||
|
||||
p = {x=pos.x, y=pos.y+1, z=pos.z}
|
||||
player:set_attribute("beds_spawn", minetest.pos_to_string(p))
|
||||
|
||||
return
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- make any node be a bed;
|
||||
|
||||
function beds.sleep(pos, player, height_offset, bed_node_norm, bed_node_slp) -- height_offset is used to determine where the damn pillow is
|
||||
-- bed_node_norm is a playerless bed, bed_node_slp is a bed with a player in.
|
||||
-- bed_node_norm gets stored as a
|
||||
|
||||
local yaw, param = beds.get_yaw_from_facedir(pos)
|
||||
|
||||
local pname = player:get_player_name()
|
||||
|
||||
beds.set_respawn_point(pos, player, param)
|
||||
|
||||
player_sleeping[pname] = true
|
||||
player_bed_swap[pname] = bed_node_norm
|
||||
|
||||
|
||||
minetest.show_formspec(pname, "beds_ui", beds_formspec(player))
|
||||
|
||||
-- set player animation and stuffs
|
||||
|
||||
|
||||
local hud_f = player:hud_get_flags()
|
||||
|
||||
player_bed_param[pname] = param
|
||||
|
||||
minetest.set_node(pos, {name=bed_node_slp, param1=0, param2=player_bed_param[pname]})
|
||||
|
||||
player:set_look_horizontal(yaw)
|
||||
player:set_look_vertical(-0.261799)
|
||||
--player:set_look_vertical(0)
|
||||
player:setpos({x=pos.x, y=pos.y, z=pos.z})
|
||||
player:set_eye_offset({x=0, y=-14, z=0}, {x=0, y=0, z=0})
|
||||
hud_f.wielditem = false
|
||||
wardrobe.close_eyes(player)
|
||||
player:set_animation({ x= 226, y=228, }, 0, false, false)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- register node
|
||||
|
||||
minetest.register_node("beds:red", {
|
||||
description = "Bed",
|
||||
tiles = {"beds_red.png"},
|
||||
drawtype = "mesh",
|
||||
paramtype = "light",
|
||||
mesh = "bed.b3d",
|
||||
groups = {snappy=3},
|
||||
paramtype2 = "facedir",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -1.25, 0.5, 0.1, 0.5},
|
||||
}
|
||||
},
|
||||
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.55, -0.5, -1.5, 0.55, 0.25, 0.55},
|
||||
},
|
||||
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
beds.sleep(pos, clicker, 0.4, "beds:red", "beds:red_active") -- take a guess what this does, right?
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_node("beds:red_active", {
|
||||
description = "Bed",
|
||||
tiles = {"beds_red.png"},
|
||||
drawtype = "mesh",
|
||||
paramtype = "light",
|
||||
mesh = "bed_active.b3d",
|
||||
groups = {snappy=3},
|
||||
drop = "beds:red",
|
||||
paramtype2 = "facedir",
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -1.25, 0.5, 0.1, 0.5},
|
||||
}
|
||||
},
|
||||
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.55, -0.5, -1.5, 0.55, 0.25, 0.55},
|
||||
},
|
||||
})
|
||||
|
||||
local function sleep_logic()
|
||||
|
||||
-- wait until the time is past 7PM and is before 5:45AM
|
||||
|
||||
local ctime = minetest.get_timeofday()
|
||||
|
||||
if ctime < 0.23 or ctime > 0.79 then
|
||||
|
||||
local numplayers = minetest.get_connected_players()
|
||||
|
||||
local slp_pl = 0
|
||||
|
||||
for key, pl in pairs(numplayers) do
|
||||
|
||||
local pname = pl:get_player_name()
|
||||
|
||||
if player_sleeping[pname] == true then
|
||||
|
||||
slp_pl = slp_pl + 1 -- count the number of sleepers
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local player_perc = #numplayers * percent_needed
|
||||
|
||||
if player_perc < slp_pl then
|
||||
|
||||
beds.pass_night()
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
minetest.after(pass_night_timer, sleep_logic)
|
||||
end
|
||||
|
||||
minetest.register_on_respawnplayer(function(player)
|
||||
|
||||
local pos = minetest.string_to_pos(player:get_attribute("beds_spawn"))
|
||||
|
||||
if pos == nil then return false end
|
||||
|
||||
local pname = player:get_player_name()
|
||||
|
||||
player_sleeping[pname] = false
|
||||
|
||||
player:set_pos(pos)
|
||||
|
||||
return true
|
||||
|
||||
end)
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
if formname ~= "beds_ui" then return end
|
||||
|
||||
if fields.key_enter_field or fields.beds_chat_snd then
|
||||
|
||||
local pname = player:get_player_name()
|
||||
|
||||
minetest.chat_send_all("<"..pname.."> ".. fields.beds_chat)
|
||||
|
||||
minetest.after(0.05, minetest.show_formspec, pname, "beds_ui", beds_formspec(player))
|
||||
|
||||
return
|
||||
|
||||
end
|
||||
|
||||
if fields.beds_ui_jingle then
|
||||
|
||||
local pname = player:get_player_name()
|
||||
|
||||
if player:get_attribute("beds_enable_jingle") ~= "true" then
|
||||
|
||||
player:set_attribute("beds_enable_jingle", "true")
|
||||
minetest.chat_send_player(pname, "Morning jingle is enabled.")
|
||||
else
|
||||
|
||||
player:set_attribute("beds_enable_jingle", "false")
|
||||
minetest.chat_send_player(pname, "Morning jingle is disabled.")
|
||||
end
|
||||
|
||||
minetest.after(0.05, minetest.show_formspec, pname, "beds_ui", beds_formspec(player))
|
||||
|
||||
return
|
||||
|
||||
end
|
||||
|
||||
if fields.quit or fields.beds_exit then
|
||||
|
||||
beds.wake_specific_player(player)
|
||||
|
||||
end
|
||||
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
|
||||
-- safety first; don't want returning players to be sleepwalking now, do we
|
||||
|
||||
local pname = player:get_player_name()
|
||||
|
||||
player_sleeping[pname] = false
|
||||
|
||||
end)
|
||||
|
||||
minetest.after(pass_night_timer, sleep_logic)
|
BIN
mods/beds/models/bed.b3d
Normal file
BIN
mods/beds/models/bed_active.b3d
Normal file
BIN
mods/beds/sounds/beds_morning_1.ogg
Normal file
BIN
mods/beds/textures/beds_red.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
mods/beds/textures/beds_sound_disabled.png
Normal file
After Width: | Height: | Size: 371 B |
BIN
mods/beds/textures/beds_sound_disabled_push.png
Normal file
After Width: | Height: | Size: 392 B |
BIN
mods/beds/textures/beds_sound_enabled.png
Normal file
After Width: | Height: | Size: 202 B |
BIN
mods/beds/textures/beds_sound_enabled_push.png
Normal file
After Width: | Height: | Size: 272 B |
157
mods/book/init.lua
Normal file
@ -0,0 +1,157 @@
|
||||
-- register the global variable.
|
||||
|
||||
book = {}
|
||||
|
||||
book.fs_esc = minetest.formspec_escape()
|
||||
|
||||
-- basic settings
|
||||
|
||||
-- default book size is A4 (portrait) in Formspec inventory slots with rounding.
|
||||
|
||||
book.formspec_size = "size[8,11]"
|
||||
|
||||
-- book background; each book can have their own or copy the default
|
||||
-- for Solar Plains this applies to all "books"
|
||||
-- Player written books will probably resemble a notepad
|
||||
|
||||
book.bg_img_basic = "background[-0.45,-0.5;8.9,12.25;book_bg_basic.png]"
|
||||
|
||||
book.bg_img_wardrobe = "background[-0.45,-0.5;8.9,12;book_bg_wardrobe.png]"
|
||||
|
||||
book.bg_img_colours = "background[-0.45,-0.5;8.9,12;book_bg_.png]"
|
||||
|
||||
book.bg_img_market = "background[-0.45,-0.5;8.9,12;book_bg_basic.png]"
|
||||
|
||||
book.solar_plains_img = "image[-0.1,0.2;11,11;intro_title.png]"
|
||||
|
||||
-- page up and page down buttons;
|
||||
|
||||
-- image_button[<X>,<Y>;<W>,<H>;<texture name>;<name>;<label>;<noclip>;<drawborder>;<pressed texture name>]`
|
||||
|
||||
book.page_down = "image_button[6.85,10;1,1;book_pg_right.png;book_pg_up;;true;false;book_pg_right_pressed.png]"
|
||||
book.page_up = "image_button[0.35,10;1,1;book_pg_left.png;book_pg_down;;true;false;book_pg_left_pressed.png]"
|
||||
|
||||
-- position for label positioning margins
|
||||
|
||||
book.left_margin = "0.35,"
|
||||
book.centered = "3.35,"
|
||||
|
||||
-- register book types;
|
||||
|
||||
book.basics = {}
|
||||
|
||||
book.wardrobe = {}
|
||||
|
||||
book.common_colours = {}
|
||||
|
||||
book.market = {}
|
||||
|
||||
-- book page tables
|
||||
|
||||
book.basics.page = {}
|
||||
|
||||
book.wardrobe.page = {}
|
||||
|
||||
book.common_colours.page = {}
|
||||
|
||||
book.market.page = {}
|
||||
|
||||
-- book
|
||||
|
||||
book.basics.page[1] = book.formspec_size .. book.bg_img_basic .. book.page_down .. book.page_up ..
|
||||
book.solar_plains_img
|
||||
|
||||
book.basics.page[2] = book.formspec_size .. book.bg_img_basic .. book.page_down .. book.page_up
|
||||
|
||||
function book.display_formspec_basic(itemstack, user)
|
||||
|
||||
local meta = itemstack:get_meta()
|
||||
|
||||
local page = meta:get_int("book_page")
|
||||
|
||||
if page == nil or page == 0 then
|
||||
|
||||
page = 1
|
||||
|
||||
meta:set_int("book_page", 1)
|
||||
user:set_wielded_item(itemstack)
|
||||
end
|
||||
|
||||
print (meta:get_int("book_page") .. " meta display_form")
|
||||
minetest.show_formspec(user:get_player_name(), "book:open", book.basics.page[page])
|
||||
|
||||
return itemstack
|
||||
end
|
||||
|
||||
-- register book items
|
||||
|
||||
minetest.register_craftitem("book:basics", {
|
||||
inventory_image = "book_tutorial.png",
|
||||
stack_max = 1,
|
||||
description = "Tutorial Book",
|
||||
|
||||
on_place = function(itemstack, user)
|
||||
|
||||
return book.display_formspec_basic(itemstack, user)
|
||||
|
||||
end,
|
||||
|
||||
on_secondary_use = function(itemstack, user)
|
||||
|
||||
return book.display_formspec_basic(itemstack, user)
|
||||
|
||||
end,
|
||||
})
|
||||
|
||||
-- minetest.register_craftitem("book:wardrobe", {
|
||||
|
||||
-- })
|
||||
|
||||
-- minetest.register_craftitem("book:colours", {
|
||||
|
||||
-- })
|
||||
|
||||
-- minetest.register_craftitem("book:market", {
|
||||
|
||||
-- })
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
--if formname ~= "book:open" then return end
|
||||
|
||||
local item = player:get_wielded_item()
|
||||
|
||||
if item:get_name() == "book:basics" then
|
||||
|
||||
local meta = item:get_meta()
|
||||
|
||||
local page = meta:get_int("book_page")
|
||||
|
||||
if fields.book_pg_up then
|
||||
|
||||
if page ~= #book.basics.page then
|
||||
page = page + 1
|
||||
meta:set_int("book_page", page)
|
||||
end
|
||||
|
||||
player:set_wielded_item(item)
|
||||
|
||||
minetest.show_formspec(player:get_player_name(), "book:open", book.basics.page[page])
|
||||
end
|
||||
|
||||
if fields.book_pg_down then
|
||||
|
||||
if page ~= 1 then
|
||||
page = page - 1
|
||||
meta:set_int("book_page", page)
|
||||
end
|
||||
|
||||
player:set_wielded_item(item)
|
||||
|
||||
minetest.show_formspec(player:get_player_name(), "book:open", book.basics.page[page])
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end)
|
BIN
mods/book/textures/book_bg_basic.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
mods/book/textures/book_bg_basic.xcf
Normal file
BIN
mods/book/textures/book_pg_left.png
Normal file
After Width: | Height: | Size: 168 B |
BIN
mods/book/textures/book_pg_left_pressed.png
Normal file
After Width: | Height: | Size: 237 B |
BIN
mods/book/textures/book_pg_right.png
Normal file
After Width: | Height: | Size: 248 B |
BIN
mods/book/textures/book_pg_right_pressed.png
Normal file
After Width: | Height: | Size: 247 B |
BIN
mods/book/textures/book_tutorial.png
Normal file
After Width: | Height: | Size: 233 B |
153
mods/bucket/init.lua
Normal file
@ -0,0 +1,153 @@
|
||||
bucket = {}
|
||||
|
||||
bucket.place = {} -- list of liquids to place
|
||||
|
||||
bucket.fill = {} -- list of liquids to loop over and set to air
|
||||
|
||||
bucket.name = {} -- list of bucket names to return after using the empty bucket
|
||||
|
||||
|
||||
function bucket.give_filled(user, ltype)
|
||||
|
||||
local inv = user:get_inventory()
|
||||
|
||||
if inv:room_for_item("main", {name = ltype}) then
|
||||
inv:add_item("main", ltype)
|
||||
else
|
||||
local pos = user:getpos()
|
||||
pos.y = math.floor(pos.y + 0.5)
|
||||
core.add_item(pos, ltype)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
minetest.register_craftitem("bucket:bucket", {
|
||||
description = "Empty Bucket",
|
||||
inventory_image = "bucket_bucket.png",
|
||||
liquids_pointable = true,
|
||||
stack_max = 99,
|
||||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
|
||||
local pos = pointed_thing.under
|
||||
|
||||
if minetest.is_protected(pos, user:get_player_name()) then
|
||||
minetest.record_protection_violation(pos, user:get_player_name())
|
||||
return itemstack
|
||||
end
|
||||
|
||||
local stack_count = user:get_wielded_item():get_count()
|
||||
local return_item = itemstack
|
||||
|
||||
for i = 1, bucket.count do
|
||||
|
||||
if minetest.get_node(pos).name == bucket.fill[i] then
|
||||
|
||||
return_item = bucket.name[i] .. " 1"
|
||||
|
||||
if user:get_wielded_item():get_count() > 1 then
|
||||
|
||||
bucket.give_filled(user, bucket.name[i])
|
||||
|
||||
return_item = "bucket:bucket " .. tostring(stack_count - 1)
|
||||
|
||||
end
|
||||
|
||||
minetest.add_node(pos, {name = "air"})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
return ItemStack(return_item)
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- how to register a filled bucket:
|
||||
|
||||
--[[
|
||||
name (string) refers to the item name of the bucket, eg:
|
||||
"lava", "water", "decay_water", the after result will look like this, eg:
|
||||
"bucket:lava", "bucket:water", "bucket:decay_water"
|
||||
|
||||
image (string) refers to the inventory image used to display the bucket, eg:
|
||||
"bucket_water.png" or "bucket_empty.png^water_overlay.png"
|
||||
|
||||
liquid_source (string) is the node name of the liquid source block that the
|
||||
empty bucket should pick up, eg:
|
||||
"core:water_source", "core:lava_source", "core:acid_source"
|
||||
|
||||
desc (string) is the description of the filled bucket, eg:
|
||||
"Lava Bucket", "Bucket of Water", "Bucket of Lava"
|
||||
|
||||
to_place (string) is the node name of the water source that the bucket should place,
|
||||
eg: "core:water_source" "core:lava_source"
|
||||
|
||||
]]--
|
||||
|
||||
|
||||
bucket.count = 0
|
||||
|
||||
function bucket.register_bucket(name, image, liquid_source, desc, to_place)
|
||||
|
||||
bucket.count = bucket.count + 1
|
||||
|
||||
bucket.fill[bucket.count] = liquid_source
|
||||
|
||||
bucket.place[bucket.count] = to_place
|
||||
|
||||
--bucket.name[bucket.count] = "bucket:"..name.."_bucket",
|
||||
bucket.name[bucket.count] = "bucket:bucket_" .. name,
|
||||
|
||||
--minetest.register_craftitem("bucket:"..name.."_bucket", {
|
||||
minetest.register_craftitem("bucket:bucket_" .. name, {
|
||||
description = desc,
|
||||
inventory_image = image,
|
||||
stack_max = 1,
|
||||
liquids_pointable = true,
|
||||
|
||||
on_place = function(itemstack, user, pointed_thing)
|
||||
|
||||
if pointed_thing.type ~= "node" then
|
||||
return
|
||||
end
|
||||
|
||||
local node = minetest.get_node_or_nil(pointed_thing.under)
|
||||
local npos
|
||||
local nodedef = minetest.registered_nodes[node.name]
|
||||
|
||||
if nodedef and nodedef.on_rightclick and not user:get_player_control().sneak then
|
||||
return nodedef.on_rightclick(pointed_thing.under, node, user, itemstack)
|
||||
end
|
||||
|
||||
if nodedef and nodedef.buildable_to then
|
||||
npos = pointed_thing.under
|
||||
else
|
||||
npos = pointed_thing.above
|
||||
node = minetest.get_node_or_nil(pointed_thing.above)
|
||||
|
||||
local above_node = minetest.registered_nodes[node.name]
|
||||
|
||||
if not above_node.buildable_to then
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.is_protected(npos, user:get_player_name()) then
|
||||
minetest.record_protection_violation(npos, user:get_player_name())
|
||||
return itemstack
|
||||
end
|
||||
|
||||
minetest.add_node(npos, {name = to_place})
|
||||
|
||||
return ItemStack("bucket:bucket 1")
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
bucket.register_bucket("water", "bucket_water.png", "core:water_source", "Bucket of Water", "core:water_source")
|
BIN
mods/bucket/textures/bucket_bucket.png
Normal file
After Width: | Height: | Size: 246 B |
BIN
mods/bucket/textures/bucket_lava.png
Normal file
After Width: | Height: | Size: 337 B |
BIN
mods/bucket/textures/bucket_water.png
Normal file
After Width: | Height: | Size: 331 B |
136
mods/core/abm_timer.lua
Normal file
@ -0,0 +1,136 @@
|
||||
-- solar fields core/abm_timer.lua
|
||||
|
||||
-- used for: saplings, grass spread, decay, etc
|
||||
|
||||
|
||||
-- grass spread
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"core:dirt"},
|
||||
neighbors = {"core:grass"},
|
||||
interval = 180,
|
||||
chance = 3,
|
||||
action = function(pos)
|
||||
pos.y = pos.y + 1
|
||||
if not minetest.get_node_light(pos) then
|
||||
return
|
||||
end
|
||||
if minetest.get_node_light(pos) > 9 then
|
||||
pos.y = pos.y - 1
|
||||
minetest.add_node(pos,{name="core:grass"})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- grass decay
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"core:grass"},
|
||||
interval = 120,
|
||||
chance = 2,
|
||||
action = function(pos)
|
||||
pos.y = pos.y + 1
|
||||
if not minetest.get_node_light(pos) then
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.get_node_light(pos) < 1 then
|
||||
pos.y = pos.y - 1
|
||||
minetest.add_node(pos,{name="core:dirt"})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"core:grass_snow"},
|
||||
interval = 120,
|
||||
chance = 2,
|
||||
action = function(pos)
|
||||
pos.y = pos.y + 1
|
||||
if not minetest.get_node_or_nil(pos) then
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.get_node_or_nil(pos).name ~= "core:snow" then
|
||||
pos.y = pos.y - 1
|
||||
minetest.add_node(pos,{name="core:dirt"})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- saplings
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"core:oak_sapling"},
|
||||
interval = 100, --100
|
||||
chance = 3,
|
||||
action = function(pos, node)
|
||||
|
||||
local nu = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
local is_soil = minetest.get_item_group(nu, "soil")
|
||||
|
||||
if is_soil == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.remove_node({x=pos.x, y=pos.y, z=pos.z})
|
||||
mcore.grow_tree(pos, false, "core:oak_log", "core:oak_leaves", nil, nil)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"core:birch_sapling"},
|
||||
interval = 90, --90
|
||||
chance = 3,
|
||||
action = function(pos, node)
|
||||
|
||||
local nu = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
local is_soil = minetest.get_item_group(nu, "soil")
|
||||
|
||||
if is_soil == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.remove_node({x=pos.x, y=pos.y, z=pos.z})
|
||||
mcore.grow_tree(pos, false, "core:birch_log", "core:birch_leaves", nil, nil)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"core:cherry_sapling"},
|
||||
interval = 80, --80
|
||||
chance = 3,
|
||||
action = function(pos, node)
|
||||
|
||||
local nu = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
local is_soil = minetest.get_item_group(nu, "soil")
|
||||
|
||||
if is_soil == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
minetest.remove_node({x=pos.x, y=pos.y, z=pos.z})
|
||||
mcore.grow_tree(pos, false, "core:cherry_log", "core:cherry_leaves", "core:fallen_cherry_leaves", 1.25)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"core:pine_sapling"},
|
||||
interval = 70, --70
|
||||
chance = 3,
|
||||
action = function(pos, node)
|
||||
|
||||
local nu = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
local is_soil = minetest.get_item_group(nu, "soil")
|
||||
|
||||
if is_soil == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.remove_node({x=pos.x, y=pos.y, z=pos.z})
|
||||
mcore.grow_pine(pos, false)
|
||||
end,
|
||||
})
|
||||
|
1403
mods/core/blocks.lua
Normal file
455
mods/core/crafting.lua
Normal file
@ -0,0 +1,455 @@
|
||||
-- tools;
|
||||
|
||||
-------------------------------------------
|
||||
|
||||
-- wooden tier;
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:wooden_pickaxe",
|
||||
recipe = {
|
||||
{"group:planks", "group:planks", "group:planks"},
|
||||
{"", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:wooden_shovel",
|
||||
recipe = {
|
||||
{"", "group:planks", ""},
|
||||
{"", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:wooden_axe",
|
||||
recipe = {
|
||||
{"group:planks", "group:planks", ""},
|
||||
{"group:planks", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:wooden_sword",
|
||||
recipe = {
|
||||
{"", "group:planks", ""},
|
||||
{"", "group:planks", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
-- stone tier;
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:stone_pickaxe",
|
||||
recipe = {
|
||||
{"group:stone", "group:stone", "group:stone"},
|
||||
{"", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:stone_shovel",
|
||||
recipe = {
|
||||
{"", "group:stone", ""},
|
||||
{"", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:stone_axe",
|
||||
recipe = {
|
||||
{"group:stone", "group:stone", ""},
|
||||
{"group:stone", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:stone_sword",
|
||||
recipe = {
|
||||
{"", "group:stone", ""},
|
||||
{"", "group:stone", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
-- iron tier;
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:iron_pickaxe",
|
||||
recipe = {
|
||||
{"core:iron_ingot", "core:iron_ingot", "core:iron_ingot"},
|
||||
{"", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:iron_shovel",
|
||||
recipe = {
|
||||
{"", "core:iron_ingot", ""},
|
||||
{"", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:iron_axe",
|
||||
recipe = {
|
||||
{"core:iron_ingot", "core:iron_ingot", ""},
|
||||
{"core:iron_ingot", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:iron_sword",
|
||||
recipe = {
|
||||
{"", "core:iron_ingot", ""},
|
||||
{"", "core:iron_ingot", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
-- ironze tier;
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:ironze_pickaxe",
|
||||
recipe = {
|
||||
{"core:ironze_ingot", "core:ironze_ingot", "core:ironze_ingot"},
|
||||
{"", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:ironze_shovel",
|
||||
recipe = {
|
||||
{"", "core:ironze_ingot", ""},
|
||||
{"", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:ironze_axe",
|
||||
recipe = {
|
||||
{"core:ironze_ingot", "core:ironze_ingot", ""},
|
||||
{"core:ironze_ingot", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:ironze_sword",
|
||||
recipe = {
|
||||
{"", "core:ironze_ingot", ""},
|
||||
{"", "core:ironze_ingot", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
-- mese tier;
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:mese_pickaxe",
|
||||
recipe = {
|
||||
{"core:mese_crystal", "core:mese_crystal", "core:mese_crystal"},
|
||||
{"", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:mese_shovel",
|
||||
recipe = {
|
||||
{"", "core:mese_crystal", ""},
|
||||
{"", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:mese_axe",
|
||||
recipe = {
|
||||
{"core:mese_crystal", "core:mese_crystal", ""},
|
||||
{"core:mese_crystal", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:mese_sword",
|
||||
recipe = {
|
||||
{"", "core:mese_crystal", ""},
|
||||
{"", "core:mese_crystal", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
-- diamond tier;
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:diamond_pickaxe",
|
||||
recipe = {
|
||||
{"core:diamond", "core:diamond", "core:diamond"},
|
||||
{"", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:diamond_shovel",
|
||||
recipe = {
|
||||
{"", "core:diamond", ""},
|
||||
{"", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:diamond_axe",
|
||||
recipe = {
|
||||
{"core:diamond", "core:diamond", ""},
|
||||
{"core:diamond", "group:stick", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:diamond_sword",
|
||||
recipe = {
|
||||
{"", "core:diamond", ""},
|
||||
{"", "core:diamond", ""},
|
||||
{"", "group:stick", ""},
|
||||
}
|
||||
})
|
||||
|
||||
-- blocks;
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:torch 6",
|
||||
recipe = {
|
||||
{"core:coal_lump"},
|
||||
{"group:stick"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:chest",
|
||||
recipe = {
|
||||
{"group:planks", "group:planks", "group:planks"},
|
||||
{"group:planks", "", "group:planks"},
|
||||
{"group:planks", "group:planks", "group:planks"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:furnace",
|
||||
recipe = {
|
||||
{"group:stone", "group:stone", "group:stone"},
|
||||
{"group:stone", "", "group:stone"},
|
||||
{"group:stone", "group:stone", "group:stone"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:chest_locked",
|
||||
recipe = {
|
||||
{"group:planks", "group:planks", "group:planks"},
|
||||
{"group:planks", "core:iron_ingot", "group:planks"},
|
||||
{"group:planks", "group:planks", "group:planks"},
|
||||
}
|
||||
})
|
||||
|
||||
-- alloy ironze
|
||||
|
||||
minetest.register_craft({
|
||||
output = "core:uncooked_ironze_ingot 2",
|
||||
recipe = {
|
||||
{"core:iron_ingot", "core:copper_ingot"},
|
||||
{"core:copper_ingot", "core:copper_ingot"},
|
||||
}
|
||||
})
|
||||
|
||||
-----------------------------------
|
||||
|
||||
-- planks
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "core:oak_planks 6",
|
||||
recipe = {
|
||||
"core:oak_log",
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "core:pine_planks 6",
|
||||
recipe = {
|
||||
"core:pine_log",
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "core:birch_planks 6",
|
||||
recipe = {
|
||||
"core:birch_log",
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "core:cherry_planks 6",
|
||||
recipe = {
|
||||
"core:cherry_log",
|
||||
},
|
||||
})
|
||||
|
||||
-- sticks
|
||||
|
||||
minetest.register_craftitem("core:stick", {
|
||||
description = "A Stick",
|
||||
inventory_image = "core_stick.png",
|
||||
groups = {furnace_fuel=1, stick=1},
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "core:stick 8",
|
||||
recipe = {
|
||||
"group:planks",
|
||||
},
|
||||
})
|
||||
|
||||
----------
|
||||
|
||||
-- ores
|
||||
|
||||
minetest.register_craftitem("core:coal_lump", {
|
||||
description = "Lump of Coal",
|
||||
inventory_image = "core_coal_lump.png",
|
||||
groups = {coal=1, furnace_fuel=1},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "core:stone",
|
||||
recipe = "core:cobble",
|
||||
})
|
||||
|
||||
-- ingots :)
|
||||
|
||||
minetest.register_craftitem("core:copper_ingot", {
|
||||
description = "Copper Ingot",
|
||||
inventory_image = "core_copper_ingot.png",
|
||||
groups = {cooking_multiplier=1}, -- note: used for cooking ore in furnace, not crafting!
|
||||
})
|
||||
|
||||
minetest.register_craftitem("core:iron_ingot", {
|
||||
description = "Iron Ingot",
|
||||
inventory_image = "core_iron_ingot.png",
|
||||
groups = {cooking_multiplier=1}, -- note: used for cooking ore in furnace, not crafting!
|
||||
})
|
||||
|
||||
minetest.register_craftitem("core:uncooked_ironze_ingot", {
|
||||
description = "Uncooked Ironze Ingot...what?!",
|
||||
inventory_image = "core_ironze_uncooked_ingot.png",
|
||||
groups = {cooking_multiplier=1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("core:ironze_ingot", {
|
||||
description = "Ironze Ingot...WHAT?!",
|
||||
inventory_image = "core_ironze_ingot.png",
|
||||
groups = {cooking_multiplier=1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("core:silver_ingot", {
|
||||
description = "Silver Ingot",
|
||||
inventory_image = "core_silver_ingot.png",
|
||||
groups = {cooking_multiplier=1}, -- note: used for cooking ore in furnace, not crafting!
|
||||
})
|
||||
|
||||
minetest.register_craftitem("core:gold_ingot", {
|
||||
description = "Gold Ingot",
|
||||
inventory_image = "core_gold_ingot.png",
|
||||
groups = {cooking_multiplier=1}, -- note: used for cooking ore in furnace, not crafting!
|
||||
})
|
||||
|
||||
-- ingot and gem cooking
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "core:copper_ingot",
|
||||
recipe = "core:copper_ore",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "core:iron_ingot",
|
||||
recipe = "core:iron_ore",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "core:ironze_ingot",
|
||||
recipe = "core:uncooked_ironze_ingot",
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "core:silver_ingot",
|
||||
recipe = "core:silver_ore",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "core:gold_ingot",
|
||||
recipe = "core:gold_ore",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "core:mese_crystal",
|
||||
recipe = "core:mese_ore",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "core:diamond",
|
||||
recipe = "core:diamond_ore",
|
||||
})
|
||||
|
||||
-- gemstones and crystals
|
||||
|
||||
minetest.register_craftitem("core:mese_crystal", {
|
||||
description = "MESE Crystal",
|
||||
inventory_image = "core_mese_crystal.png",
|
||||
groups = {cooking_multiplier=1}, -- note: used for cooking ore in furnace, not crafting!
|
||||
})
|
||||
|
||||
minetest.register_craftitem("core:diamond", {
|
||||
description = "Diamond",
|
||||
inventory_image = "core_diamond.png",
|
||||
groups = {cooking_multiplier=1}, -- note: used for cooking ore in furnace, not crafting!
|
||||
})
|
||||
|
||||
-- fuels
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "core:coal_lump",
|
||||
burntime = 40,
|
||||
})
|
||||
|
97
mods/core/init.lua
Normal file
@ -0,0 +1,97 @@
|
||||
--configuration options
|
||||
|
||||
give_initial_stuff = {}
|
||||
|
||||
-- dofiles for loading files required by "core"
|
||||
dofile(minetest.get_modpath("core").."/mapgen.lua")
|
||||
dofile(minetest.get_modpath("core").."/blocks.lua")
|
||||
dofile(minetest.get_modpath("core").."/player.lua")
|
||||
dofile(minetest.get_modpath("core").."/tools.lua")
|
||||
dofile(minetest.get_modpath("core").."/crafting.lua")
|
||||
dofile(minetest.get_modpath("core").."/abm_timer.lua")
|
||||
|
||||
|
||||
--dofile(minetest.get_modpath("core").."/")
|
||||
--dofile(minetest.get_modpath("core").."/")
|
||||
--dofile(minetest.get_modpath("core").."/")
|
||||
|
||||
-- base mapgen requirements
|
||||
|
||||
minetest.register_alias("mapgen_stone", "core:stone")
|
||||
minetest.register_alias("mapgen_dirt", "core:dirt")
|
||||
minetest.register_alias("mapgen_dirt_with_grass", "core:grass")
|
||||
minetest.register_alias("mapgen_sand", "core:sand")
|
||||
minetest.register_alias("mapgen_water_source", "core:water_source")
|
||||
minetest.register_alias("mapgen_river_water_source", "core:water_source")
|
||||
minetest.register_alias("mapgen_lava_source", "core:lava_source")
|
||||
minetest.register_alias("mapgen_gravel", "core:gravel")
|
||||
minetest.register_alias("mapgen_desert_stone", "core:sandstone")
|
||||
minetest.register_alias("mapgen_desert_sand", "core:sand")
|
||||
minetest.register_alias("mapgen_dirt_with_snow", "core:grass_snow")
|
||||
minetest.register_alias("mapgen_snowblock", "core:snowblock")
|
||||
minetest.register_alias("mapgen_snow", "core:snow")
|
||||
minetest.register_alias("mapgen_ice", "core:ice")
|
||||
minetest.register_alias("mapgen_sandstone", "core:sandstone")
|
||||
|
||||
-- Flora
|
||||
|
||||
minetest.register_alias("mapgen_tree", "core:oak_tree")
|
||||
minetest.register_alias("mapgen_leaves", "core:oak_leaves")
|
||||
minetest.register_alias("mapgen_apple", "core:apple")
|
||||
minetest.register_alias("mapgen_jungletree", "core:jungletree")
|
||||
minetest.register_alias("mapgen_jungleleaves", "core:jungleleaves")
|
||||
minetest.register_alias("mapgen_junglegrass", "core:junglegrass")
|
||||
minetest.register_alias("mapgen_pine_tree", "core:pine_tree")
|
||||
minetest.register_alias("mapgen_pine_needles", "core:pine_needles")
|
||||
|
||||
-- Dungeons
|
||||
|
||||
minetest.register_alias("mapgen_cobble", "core:cobble")
|
||||
minetest.register_alias("mapgen_stair_cobble", "stairs:stair_cobble")
|
||||
minetest.register_alias("mapgen_mossycobble", "core:mossycobble")
|
||||
minetest.register_alias("mapgen_sandstonebrick", "core:sandstonebrick")
|
||||
minetest.register_alias("mapgen_stair_sandstonebrick", "stairs:stair_sandstonebrick")
|
||||
|
||||
-- add unbreakable starter tools (they break in 32k uses)
|
||||
|
||||
local stuff_string = "core:wooden_pickaxe,core:wooden_sword,core:wooden_axe,core:wooden_shovel"
|
||||
|
||||
give_initial_stuff = {
|
||||
items = {}
|
||||
}
|
||||
|
||||
function give_initial_stuff.give(player)
|
||||
minetest.log("action",
|
||||
"Giving starter wooden tools to new player " .. player:get_player_name())
|
||||
local inv = player:get_inventory()
|
||||
for _, stack in ipairs(give_initial_stuff.items) do
|
||||
inv:add_item("main", stack)
|
||||
end
|
||||
end
|
||||
|
||||
function give_initial_stuff.add(stack)
|
||||
give_initial_stuff.items[#give_initial_stuff.items + 1] = ItemStack(stack)
|
||||
end
|
||||
|
||||
function give_initial_stuff.clear()
|
||||
give_initial_stuff.items = {}
|
||||
end
|
||||
|
||||
function give_initial_stuff.add_from_csv(str)
|
||||
local items = str:split(",")
|
||||
for _, itemname in ipairs(items) do
|
||||
give_initial_stuff.add(itemname)
|
||||
end
|
||||
end
|
||||
|
||||
function give_initial_stuff.set_list(list)
|
||||
give_initial_stuff.items = list
|
||||
end
|
||||
|
||||
function give_initial_stuff.get_list()
|
||||
return give_initial_stuff.items
|
||||
end
|
||||
|
||||
give_initial_stuff.add_from_csv(stuff_string)
|
||||
|
||||
minetest.register_on_newplayer(give_initial_stuff.give)
|
1290
mods/core/mapgen.lua
Normal file
BIN
mods/core/models/character.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
9835
mods/core/models/character.x
Normal file
BIN
mods/core/models/chest_locked.b3d
Normal file
BIN
mods/core/models/chest_unlocked.b3d
Normal file
BIN
mods/core/models/core_bamboo.b3d
Normal file
BIN
mods/core/models/core_cactus.b3d
Normal file
BIN
mods/core/models/hand.b3d
Normal file
BIN
mods/core/models/player_singleplayer.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
mods/core/models/player_singleplayer2.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
226
mods/core/player.lua
Normal file
@ -0,0 +1,226 @@
|
||||
-- Minetest 0.4 mod: player
|
||||
-- See README.txt for licensing and other information.
|
||||
|
||||
-- Player animation blending
|
||||
-- Note: This is currently broken due to a bug in Irrlicht, leave at 0
|
||||
default = {}
|
||||
|
||||
local animation_blend = 0
|
||||
|
||||
default.registered_player_models = { }
|
||||
|
||||
-- Local for speed.
|
||||
local models = default.registered_player_models
|
||||
|
||||
function default.player_register_model(name, def)
|
||||
models[name] = def
|
||||
end
|
||||
|
||||
-- setting player amour textures;
|
||||
|
||||
--[[
|
||||
|
||||
The first texture in the table is for 64x32 skins, the original Minecraft
|
||||
format.
|
||||
|
||||
The second texture in the table is for 64x64 skins, introduced in
|
||||
Minecraft's offical 1.8 update, not the Beta.
|
||||
|
||||
The thrid texture in the table is a 64x32 texture, which follows
|
||||
the same scheme as Minecrafts 64x32 texture, and the same layout.
|
||||
|
||||
Use the head in the top left position and not the "hat layer".
|
||||
|
||||
The fourth texture in the table is the same texture as above.
|
||||
Except, the chest has both the main body and arms. Same place
|
||||
as a normal 64x32 skin.
|
||||
|
||||
The fifth texture in the table is the same texture as the helmet,
|
||||
but uses the top half of the legs texture - note that it does not
|
||||
use the last 4 pixels of the legs.
|
||||
|
||||
The sixth texture in the table is the same texture as the helmet,
|
||||
but uses the final four pixels of the leg texture.
|
||||
|
||||
The seventh texture in the table is teh shield - a 16x16 image
|
||||
that will cover your own or another's left arm.
|
||||
|
||||
A demo texture for armour can be found at;
|
||||
|
||||
https://jordach.net/Images/ProtonArt/base_armour.png
|
||||
|
||||
Use "ptextures_transparent.png" when not using armour layers and
|
||||
or the 64x64 skin socket.
|
||||
|
||||
--]]
|
||||
|
||||
-- Default player appearance
|
||||
default.player_register_model("character.x", {
|
||||
animation_speed = 30,
|
||||
textures = {
|
||||
"ptextures_transparent.png",
|
||||
"(wardrobe_skin.png^[multiply:#ffffff)",
|
||||
"ptextures_transparent.png",
|
||||
"ptextures_transparent.png",
|
||||
"ptextures_transparent.png",
|
||||
"ptextures_transparent.png",
|
||||
"ptextures_transparent.png"
|
||||
},
|
||||
animations = {
|
||||
-- Standard animations.
|
||||
stand = { x= 0, y= 79, },
|
||||
lay = { x=162, y=166, },
|
||||
walk = { x=168, y=187, },
|
||||
mine = { x=189, y=198, },
|
||||
walk_mine = { x=200, y=219, },
|
||||
dead = { x= 221, y=225, },
|
||||
-- Utility animations (not currently used by the game; but still usable by mods).
|
||||
sit = { x= 81, y=160, },
|
||||
lay_bed = { x= 226, y=228, },
|
||||
|
||||
},
|
||||
})
|
||||
|
||||
-- Player stats and animations
|
||||
local player_model = {}
|
||||
local player_textures = {}
|
||||
local player_anim = {}
|
||||
local player_sneak = {}
|
||||
default.player_attached = {}
|
||||
|
||||
function default.player_get_animation(player)
|
||||
local name = player:get_player_name()
|
||||
return {
|
||||
model = player_model[name],
|
||||
textures = player_textures[name],
|
||||
animation = player_anim[name],
|
||||
}
|
||||
end
|
||||
|
||||
-- Called when a player's appearance needs to be updated
|
||||
function default.player_set_model(player, model_name)
|
||||
local name = player:get_player_name()
|
||||
local model = models[model_name]
|
||||
if model then
|
||||
if player_model[name] == model_name then
|
||||
return
|
||||
end
|
||||
player:set_properties({
|
||||
mesh = model_name,
|
||||
textures = player_textures[name] or model.textures,
|
||||
visual = "mesh",
|
||||
visual_size = model.visual_size or {x=1, y=1},
|
||||
})
|
||||
default.player_set_animation(player, "stand")
|
||||
else
|
||||
player:set_properties({
|
||||
textures = { "player.png", "player_back.png", },
|
||||
visual = "upright_sprite",
|
||||
})
|
||||
end
|
||||
player_model[name] = model_name
|
||||
end
|
||||
|
||||
function default.player_set_textures(player, textures)
|
||||
local name = player:get_player_name()
|
||||
player_textures[name] = textures
|
||||
player:set_properties({textures = textures,})
|
||||
end
|
||||
|
||||
function default.player_set_animation(player, anim_name, speed)
|
||||
local name = player:get_player_name()
|
||||
if player_anim[name] == anim_name then
|
||||
return
|
||||
end
|
||||
local model = player_model[name] and models[player_model[name]]
|
||||
if not (model and model.animations[anim_name]) then
|
||||
return
|
||||
end
|
||||
local anim = model.animations[anim_name]
|
||||
player_anim[name] = anim_name
|
||||
player:set_animation(anim, speed or model.animation_speed, animation_blend)
|
||||
end
|
||||
|
||||
-- Update appearance when the player joins
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
default.player_attached[player:get_player_name()] = false
|
||||
default.player_set_model(player, "character.x")
|
||||
player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30)
|
||||
|
||||
player:hud_set_hotbar_image("hud_hotbar.png")
|
||||
player:hud_set_hotbar_selected_image("hud_hotbar_selected.png")
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
player_model[name] = nil
|
||||
player_anim[name] = nil
|
||||
player_textures[name] = nil
|
||||
end)
|
||||
|
||||
-- Localize for better performance.
|
||||
local player_set_animation = default.player_set_animation
|
||||
local player_attached = default.player_attached
|
||||
|
||||
-- Check each player and apply animations
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local name = player:get_player_name()
|
||||
local model_name = player_model[name]
|
||||
local model = model_name and models[model_name]
|
||||
if model and not player_attached[name] then
|
||||
local controls = player:get_player_control()
|
||||
local walking = false
|
||||
local animation_speed_mod = model.animation_speed or 30
|
||||
|
||||
-- Determine if the player is walking
|
||||
if controls.up or controls.down or controls.left or controls.right then
|
||||
walking = true
|
||||
end
|
||||
|
||||
-- Determine if the player is sneaking, and reduce animation speed if so
|
||||
if controls.sneak then
|
||||
animation_speed_mod = animation_speed_mod / 2
|
||||
end
|
||||
|
||||
-- Apply animations based on what the player is doing
|
||||
if player:get_hp() == 0 then
|
||||
player_set_animation(player, "dead")
|
||||
elseif walking then
|
||||
if player_sneak[name] ~= controls.sneak then
|
||||
player_anim[name] = nil
|
||||
player_sneak[name] = controls.sneak
|
||||
end
|
||||
if controls.LMB then
|
||||
player_set_animation(player, "walk_mine", animation_speed_mod)
|
||||
else
|
||||
player_set_animation(player, "walk", animation_speed_mod)
|
||||
end
|
||||
elseif controls.LMB then
|
||||
player_set_animation(player, "mine")
|
||||
else
|
||||
player_set_animation(player, "stand", animation_speed_mod)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_node(":newhand:hand", {
|
||||
description = "",
|
||||
tiles = {"player_singleplayer.png"},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local stack = ItemStack(":")
|
||||
local ret = minetest.item_place(stack, placer, pointed_thing)
|
||||
return ItemStack("newhand:hand "..itemstack:get_count())
|
||||
end,
|
||||
visual_scale = 1,
|
||||
wield_scale = {x=1,y=1,z=1},
|
||||
paramtype = "light",
|
||||
drawtype = "mesh",
|
||||
mesh = "hand.b3d",
|
||||
node_placement_prediction = "",
|
||||
})
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
--player:get_inventory():set_stack("hand", 1, "newhand:hand")
|
||||
end)
|
BIN
mods/core/textures/core_bamboo.png
Normal file
After Width: | Height: | Size: 293 B |
BIN
mods/core/textures/core_birch_leaves.png
Normal file
After Width: | Height: | Size: 388 B |
BIN
mods/core/textures/core_birch_log.png
Normal file
After Width: | Height: | Size: 426 B |
BIN
mods/core/textures/core_birch_log_top.png
Normal file
After Width: | Height: | Size: 527 B |
BIN
mods/core/textures/core_birch_planks.png
Normal file
After Width: | Height: | Size: 263 B |
BIN
mods/core/textures/core_birch_sapling.png
Normal file
After Width: | Height: | Size: 365 B |
BIN
mods/core/textures/core_brick.png
Normal file
After Width: | Height: | Size: 271 B |
BIN
mods/core/textures/core_cactus.png
Normal file
After Width: | Height: | Size: 658 B |
BIN
mods/core/textures/core_cherry_leaves.png
Normal file
After Width: | Height: | Size: 376 B |
BIN
mods/core/textures/core_cherry_log.png
Normal file
After Width: | Height: | Size: 293 B |
BIN
mods/core/textures/core_cherry_log_top.png
Normal file
After Width: | Height: | Size: 457 B |
BIN
mods/core/textures/core_cherry_planks.png
Normal file
After Width: | Height: | Size: 186 B |
BIN
mods/core/textures/core_cherry_sapling.png
Normal file
After Width: | Height: | Size: 373 B |
BIN
mods/core/textures/core_chest_front.png
Normal file
After Width: | Height: | Size: 469 B |
BIN
mods/core/textures/core_chest_interface.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
mods/core/textures/core_chest_locked.png
Normal file
After Width: | Height: | Size: 544 B |
BIN
mods/core/textures/core_chest_sides.png
Normal file
After Width: | Height: | Size: 360 B |
BIN
mods/core/textures/core_chest_uv.png
Normal file
After Width: | Height: | Size: 806 B |
BIN
mods/core/textures/core_clay_block.png
Normal file
After Width: | Height: | Size: 327 B |
BIN
mods/core/textures/core_clay_lump.png
Normal file
After Width: | Height: | Size: 172 B |
BIN
mods/core/textures/core_coal_lump.png
Normal file
After Width: | Height: | Size: 243 B |
BIN
mods/core/textures/core_cobble.png
Normal file
After Width: | Height: | Size: 697 B |
BIN
mods/core/textures/core_cobble_mossy.png
Normal file
After Width: | Height: | Size: 904 B |
BIN
mods/core/textures/core_copper_ingot.png
Normal file
After Width: | Height: | Size: 228 B |
BIN
mods/core/textures/core_diamond.png
Normal file
After Width: | Height: | Size: 296 B |
BIN
mods/core/textures/core_diamond_axe.png
Normal file
After Width: | Height: | Size: 476 B |
BIN
mods/core/textures/core_diamond_pickaxe.png
Normal file
After Width: | Height: | Size: 500 B |
BIN
mods/core/textures/core_diamond_shovel.png
Normal file
After Width: | Height: | Size: 563 B |
BIN
mods/core/textures/core_diamond_sword.png
Normal file
After Width: | Height: | Size: 485 B |
BIN
mods/core/textures/core_dirt.png
Normal file
After Width: | Height: | Size: 461 B |
BIN
mods/core/textures/core_firestone.png
Normal file
After Width: | Height: | Size: 404 B |
BIN
mods/core/textures/core_furnace_arrow_bg.png
Normal file
After Width: | Height: | Size: 278 B |
BIN
mods/core/textures/core_furnace_arrow_fg.png
Normal file
After Width: | Height: | Size: 284 B |
BIN
mods/core/textures/core_furnace_fire_bg.png
Normal file
After Width: | Height: | Size: 259 B |
BIN
mods/core/textures/core_furnace_fire_fg.png
Normal file
After Width: | Height: | Size: 578 B |
BIN
mods/core/textures/core_furnace_front.png
Normal file
After Width: | Height: | Size: 330 B |
BIN
mods/core/textures/core_furnace_front_active.png
Normal file
After Width: | Height: | Size: 529 B |
BIN
mods/core/textures/core_furnace_side.png
Normal file
After Width: | Height: | Size: 216 B |
BIN
mods/core/textures/core_furnace_top.png
Normal file
After Width: | Height: | Size: 318 B |