first commit

This commit is contained in:
kaadmy 2015-09-01 08:15:24 -07:00
commit 12c94adf09
619 changed files with 19556 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*~
*.blend1

116
LICENSE_CC0.txt Normal file
View File

@ -0,0 +1,116 @@
CC0 1.0 Universal
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator and
subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for the
purpose of contributing to a commons of creative, cultural and scientific
works ("Commons") that the public can reliably and without fear of later
claims of infringement build upon, modify, incorporate in other works, reuse
and redistribute as freely as possible in any form whatsoever and for any
purposes, including without limitation commercial purposes. These owners may
contribute to the Commons to promote the ideal of a free culture and the
further production of creative, cultural and scientific works, or to gain
reputation or greater distribution for their Work in part through the use and
efforts of others.
For these and/or other purposes and motivations, and without any expectation
of additional consideration or compensation, the person associating CC0 with a
Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
and publicly distribute the Work under its terms, with knowledge of his or her
Copyright and Related Rights in the Work and the meaning and intended legal
effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not limited
to, the following:
i. the right to reproduce, adapt, distribute, perform, display, communicate,
and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or likeness
depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data in
a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation thereof,
including any amended or successor version of such directive); and
vii. other similar, equivalent or corresponding rights throughout the world
based on applicable law or treaty, and any national implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention of,
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
and Related Rights and associated claims and causes of action, whether now
known or unknown (including existing as well as future claims and causes of
action), in the Work (i) in all territories worldwide, (ii) for the maximum
duration provided by applicable law or treaty (including future time
extensions), (iii) in any current or future medium and for any number of
copies, and (iv) for any purpose whatsoever, including without limitation
commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
the Waiver for the benefit of each member of the public at large and to the
detriment of Affirmer's heirs and successors, fully intending that such Waiver
shall not be subject to revocation, rescission, cancellation, termination, or
any other legal or equitable action to disrupt the quiet enjoyment of the Work
by the public as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason be
judged legally invalid or ineffective under applicable law, then the Waiver
shall be preserved to the maximum extent permitted taking into account
Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
is so judged Affirmer hereby grants to each affected person a royalty-free,
non transferable, non sublicensable, non exclusive, irrevocable and
unconditional license to exercise Affirmer's Copyright and Related Rights in
the Work (i) in all territories worldwide, (ii) for the maximum duration
provided by applicable law or treaty (including future time extensions), (iii)
in any current or future medium and for any number of copies, and (iv) for any
purpose whatsoever, including without limitation commercial, advertising or
promotional purposes (the "License"). The License shall be deemed effective as
of the date CC0 was applied by Affirmer to the Work. Should any part of the
License for any reason be judged legally invalid or ineffective under
applicable law, such partial invalidity or ineffectiveness shall not
invalidate the remainder of the License, and in such case Affirmer hereby
affirms that he or she will not (i) exercise any of his or her remaining
Copyright and Related Rights in the Work or (ii) assert any associated claims
and causes of action with respect to the Work, in either case contrary to
Affirmer's express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or warranties
of any kind concerning the Work, express, implied, statutory or otherwise,
including without limitation warranties of title, merchantability, fitness
for a particular purpose, non infringement, or the absence of latent or
other defects, accuracy, or the present or absence of errors, whether or not
discoverable, all to the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without limitation
any person's Copyright and Related Rights in the Work. Further, Affirmer
disclaims responsibility for obtaining any necessary consents, permissions
or other rights required for any use of the Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to this
CC0 or use of the Work.
For more information, please see
<http://creativecommons.org/publicdomain/zero/1.0/>

21
LICENSE_MIT.txt Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Kaadmy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

13
README.txt Normal file
View File

@ -0,0 +1,13 @@
Pixture
=======
By Kaadmy
Extra-special credit to Kenney(kenney.nl)
Special credits:
Extra-special credit to Kenney(kenney.nl) for the inspiration, most of the graphics design
(All images are of my own creation but based off Kenney's), and the overall feeling.
Sounds in the default mod are all by Kenney(CC0)
All textures/models by Kaadmy(CC0)
Asset license: almost all CC0, see per-mod READMEs.
Source license: almost all MIT, see per-mod READMEs.

1
game.conf Normal file
View File

@ -0,0 +1 @@
name = Pixture

BIN
menu/header.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 781 B

BIN
menu/header.xcf Normal file

Binary file not shown.

BIN
menu/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 B

BIN
menu/icon.xcf Normal file

Binary file not shown.

BIN
menu/overlay.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 647 KiB

BIN
menu/overlay.xcf Normal file

Binary file not shown.

61
minetest.conf Normal file
View File

@ -0,0 +1,61 @@
#day-night cycle is 12 min(about)
time_speed = 120
# movement
movement_acceleration_default = 3.6
movement_acceleration_fast = 7.0
movement_acceleration_air = 3.2
movement_speed_walk = 4.2
movement_speed_fast = 7.0
movement_speed_crouch = 2.2
movement_speed_climb = 2.6
movement_speed_descend = 3.0
movement_speed_jump = 6.8
movement_liquid_fluidity = 0.9
movement_liquid_sink = 11.0
movement_gravity = 9.4
# privs
default_privs = interact, shout, spawn, fast
# if you're given the inital stuff; a stone pick and 10 torches
give_initial_stuff = false
# if beds can be slept in
bed_enabled = true
# if music players are usable
music_enable = true
# if dynamically changing weather is enabled
weather_enable = true
# if pvp is enabled
enable_pvp = true
# tnt is enabledxx
tnt_enable = true
# server
max_users = 8
max_block_generate_distance = 4
max_block_send_distance = 3
max_simultaneous_block_sends_per_client = 20
max_simultaneous_block_sends_server_total = 100
time_send_interval = 5
active_block_range = 4
server_map_save_interval = 15
# mapgen
mg_flags = trees, caves
mgv6_spflags = nojungles
mgv6_freq_desert = 0.65
mgv6_freq_beach = -0.04
water_level = 0
# i don't really know what these numbers change, but whatever :)
# offset, scale, (spread factors), seed offset, number of octaves, persistence, lacunarity.
mg_biome_np_humidity = 50, 20, (600, 850, 600), 31478, 3, 0.5, 2.0
mgv7_np_terrain_base = 10, 30, (750, 1500, 750), 88533, 8, 0.65, 2, 2

9
mods/armor/README.txt Normal file
View File

@ -0,0 +1,9 @@
Armor mod
=========
By Kaadmy, for Pixture
Adds craftable and wearable armor
Asset license: CC0
Source code license: MIT

254
mods/armor/init.lua Normal file
View File

@ -0,0 +1,254 @@
--
-- Armor mod
-- By Kaadmy, for Pixture
--
armor = {}
armor.update_time = 1
armor.materials = {
-- material craftitem % description
{"wood", "group:planks", 15, "Wooden"},
{"steel", "default:ingot_steel", 30, "Steel"},
{"chainmail", "armor:chainmail_sheet", 45, "Chainmail"},
{"carbonsteel", "default:ingot_carbonsteel", 60, "Carbonsteel"},
}
armor.slots = {"helmet", "chestplate", "boots"}
local form_armor = default.ui.get_page("core_2part")
default.ui.register_page("core_armor", form_armor)
local armor_timer = 10
function armor.is_armor(itemname)
local item = minetest.registered_items[itemname]
if item ~= nil and item.groups ~= nil then
if item.groups.is_armor then
return true
end
end
end
function armor.is_slot(itemname, slot)
local match = string.find(itemname, "armor:" .. slot .. "_")
local matchbool = false
if match ~= nil and match >= 1 then
matchbool = true
end
return matchbool
end
function armor.get_texture(player, base)
local inv = player:get_inventory()
local image = base
for _, slot in ipairs(armor.slots) do
local itemstack = inv:get_stack("armor_"..slot, 1)
local itemname = itemstack:get_name()
if armor.is_armor(itemname) and armor.is_slot(itemname, slot) then
local item = minetest.registered_items[itemname]
local mat = armor.materials[item.groups.armor_material][1]
image = image .. "^armor_" .. slot .. "_" .. mat ..".png"
end
end
-- print("[armor] Got armor texture: " .. image)
return image
end
function armor.get_groups(player)
local groups = {fleshy = 100}
local match_mat = nil
local match_amt = 0
local inv = player:get_inventory()
for _, slot in ipairs(armor.slots) do
local itemstack = inv:get_stack("armor_"..slot, 1)
local itemname = itemstack:get_name()
if armor.is_armor(itemname) then
local item = minetest.registered_items[itemname]
for mat_index, _ in ipairs(armor.materials) do
local mat = armor.materials[mat_index][1]
if mat_index == item.groups.armor_material then
groups.fleshy = groups.fleshy - item.groups.armor
if match_mat == nil then
match_mat = mat
end
if mat == match_mat then
match_amt = match_amt + 1
end
break
end
end
end
end
if match_amt == #armor.slots then -- if full set of same armor material, then boost armor by 10%
groups.fleshy = groups.fleshy - 10
end
-- print("[armor] Armor groups: " .. dump(groups))
return groups
end
function armor.init(player)
local inv = player:get_inventory()
for _, slot in ipairs(armor.slots) do
if inv:get_size("armor_"..slot) ~= 1 then
inv:set_size("armor_"..slot, 1)
end
end
end
function armor.update(player)
local groups = armor.get_groups(player)
player:set_armor_groups({fleshy = groups.fleshy})
local image = armor.get_texture(player, "character.png")
if image ~= default.player_get_textures(player)[1] then
default.player_set_textures(player, {image})
end
end
local function on_newplayer(player)
armor.init(player)
end
local function on_joinplayer(player)
armor.init(player)
end
local function on_die(player)
-- remove your armor(when i get to doing it...)
end
local function step(dtime)
armor_timer = armor_timer + dtime
if armor_timer > armor.update_time then
for _, player in pairs(minetest.get_connected_players()) do
armor.update(player)
end
armor_timer = 0
end
end
minetest.register_craftitem(
"armor:chainmail_sheet",
{
description = "Chainmail sheet",
inventory_image = "armor_chainmail.png",
wield_image = "armor_chainmail.png",
stack_max = 20,
})
minetest.register_craft(
{
output = "armor:chainmail_sheet 3",
recipe = {
{"default:ingot_steel", "", "default:ingot_steel"},
{"", "default:ingot_steel", ""},
{"default:ingot_steel", "", "default:ingot_steel"},
}
})
for mat_index, _ in ipairs(armor.materials) do
local def = armor.materials[mat_index]
local mat = def[1]
local armor_def = math.floor(def[3] / #armor.slots)
-- print("Material " .. mat .. ": " .. armor_def)
for _, slot in ipairs(armor.slots) do
minetest.register_craftitem(
"armor:"..slot.."_"..mat,
{
description = def[4].." "..slot,
inventory_image = "armor_"..slot.."_"..mat.."_inventory.png",
wield_image = "armor_"..slot.."_"..mat.."_inventory.png",
groups = {
is_armor = 1,
armor = armor_def,
armor_material = mat_index
},
stack_max = 1,
})
end
local n = def[2]
minetest.register_craft(
{
output = "armor:helmet_"..mat,
recipe = {
{n, n, n},
{n, "", n},
{"", "", ""},
}
})
minetest.register_craft(
{
output = "armor:chestplate_"..mat,
recipe = {
{n, "", n},
{n, n, n},
{n, n, n},
}
})
minetest.register_craft(
{
output = "armor:boots_"..mat,
recipe = {
{"", "", ""},
{n, "", n},
{n, "", n},
}
})
end
minetest.register_on_newplayer(on_newplayer)
minetest.register_on_joinplayer(on_joinplayer)
minetest.register_on_dieplayer(on_die)
minetest.register_globalstep(step)
local form_armor = default.ui.get_page("core_2part")
form_armor = form_armor .. "list[current_player;main;0.25,4.75;8,4;]"
form_armor = form_armor .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1)
form_armor = form_armor .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3)
form_armor = form_armor .. "listring[current_player;main]"
form_armor = form_armor .. "label[3.25,3;Boots]"
form_armor = form_armor .. "list[current_player;armor_boots;2.25,2.75;1,1;]"
form_armor = form_armor .. "listring[current_player;armor_boots]"
form_armor = form_armor .. default.ui.get_itemslot_bg(2.25, 2.75, 1, 1)
form_armor = form_armor .. "label[3.25,2;Chestplate]"
form_armor = form_armor .. "list[current_player;armor_chestplate;2.25,1.75;1,1;]"
form_armor = form_armor .. "listring[current_player;armor_chestplate]"
form_armor = form_armor .. default.ui.get_itemslot_bg(2.25, 1.75, 1, 1)
form_armor = form_armor .. "label[3.25,1;Helmet]"
form_armor = form_armor .. "list[current_player;armor_helmet;2.25,0.75;1,1;]"
form_armor = form_armor .. "listring[current_player;armor_helmet]"
form_armor = form_armor .. default.ui.get_itemslot_bg(2.25, 0.75, 1, 1)
default.ui.register_page("core_armor", form_armor)

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 412 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 408 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

9
mods/bed/README.txt Normal file
View File

@ -0,0 +1,9 @@
Beds mod
========
By PilzAdam, thefamilygrog66
Tweaked by Kadmy, for Pixture
Right-click a bed to sleep, right-click again to get out.
Asset license: CC0
Source license: MIT(originally WTFPL)

2
mods/bed/depends.txt Normal file
View File

@ -0,0 +1,2 @@
default
farming

215
mods/bed/init.lua Normal file
View File

@ -0,0 +1,215 @@
--
-- Bed mod
-- By PilzAdam, thefamilygrog66
-- Tweaked by Kaadmy, for Pixture
--
local players_in_bed = 0
minetest.register_node(
"bed:bed_foot",
{
description = "Bed",
drawtype = "nodebox",
tiles = {"bed_foot.png", "default_wood.png", "bed_side.png"},
inventory_image = "bed_bed_inventory.png",
wield_image = "bed_bed_inventory.png",
sunlight_propagates = true,
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3},
sounds = default.node_sound_wood_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 2/16, 0.5},
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 2/16, 1.5},
}
},
after_place_node = function(pos, placer, itemstack)
local node = minetest.env:get_node(pos)
local p = {x = pos.x, y = pos.y, z = pos.z}
local param2 = node.param2
node.name = "bed:bed_head"
if param2 == 0 then
pos.z = pos.z + 1
elseif param2 == 1 then
pos.x = pos.x + 1
elseif param2 == 2 then
pos.z = pos.z - 1
elseif param2 == 3 then
pos.x = pos.x - 1
end
if minetest.registered_nodes[minetest.env:get_node(pos).name].buildable_to then
minetest.env:set_node(pos, node)
else
minetest.env:remove_node(p)
return true
end
end,
on_destruct = function(pos)
local node = minetest.env:get_node(pos)
local param2 = node.param2
if param2 == 0 then
pos.z = pos.z+1
elseif param2 == 1 then
pos.x = pos.x+1
elseif param2 == 2 then
pos.z = pos.z-1
elseif param2 == 3 then
pos.x = pos.x-1
end
if (minetest.env:get_node({x = pos.x, y = pos.y, z = pos.z}).name == "bed:bed_head") then
if (minetest.env:get_node({x = pos.x, y = pos.y, z = pos.z}).param2 == param2) then
minetest.env:remove_node(pos)
end
end
end,
on_rightclick =function(pos, node, clicker)
if not clicker:is_player()
or not minetest.is_singleplayer()
and not minetest.setting_getbool("bed_enabled") then return end
local meta = minetest.env:get_meta(pos)
local param2 = node.param2
if param2 == 0 then
pos.z = pos.z + 0.5
elseif param2 == 1 then
pos.x = pos.x + 0.5
elseif param2 == 2 then
pos.z = pos.z - 0.5
elseif param2 == 3 then
pos.x = pos.x - 0.5
end
if clicker:get_player_name() == meta:get_string("player") then
if param2 == 0 then
pos.x = pos.x - 1
elseif param2 == 1 then
pos.z = pos.z + 1
elseif param2 == 2 then
pos.x = pos.x + 1
elseif param2 == 3 then
pos.z = pos.z - 1
end
clicker:set_physics_override({speed = 1.0, jump = 1.0, sneak = true})
pos.y = pos.y - 0.5
clicker:setpos(pos)
clicker:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
meta:set_string("player", "")
players_in_bed = players_in_bed - 1
default.player_attached[clicker:get_player_name()] = false
clicker:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30)
default.player_set_animation(clicker, "stand", 30)
elseif meta:get_string("player") == "" then
default.player_attached[clicker:get_player_name()] = true
clicker:set_local_animation({x=162, y=166}, {x=162, y=166}, {x=162, y=166}, {x=162, y=168}, 30)
default.player_set_animation(clicker, "lay", 30)
clicker:set_physics_override({speed = 0.0, jump = 0.0, sneak = false})
pos.y = pos.y + 0.5625
clicker:setpos(pos)
clicker:set_eye_offset({x = 0, y = -13, z = 0}, {x = 0, y = -13, z = 0})
if param2 == 0 then
clicker:set_look_yaw(math.pi)
elseif param2 == 1 then
clicker:set_look_yaw(0.5 * math.pi)
elseif param2 == 2 then
clicker:set_look_yaw(0)
elseif param2 == 3 then
clicker:set_look_yaw(1.5 * math.pi)
end
meta:set_string("player", clicker:get_player_name())
players_in_bed = players_in_bed + 1
end
end
})
minetest.register_node(
"bed:bed_head",
{
drawtype = "nodebox",
tiles = {"bed_head.png", "default_wood.png", "bed_side.png"},
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 3},
sounds = default.node_sound_wood_defaults(),
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, 2/16, 0.5},
}
},
selection_box = {type = "fixed", fixed = {{0, 0, 0, 0, 0, 0},}},
})
minetest.register_alias("bed:bed", "bed:bed_foot")
minetest.register_craft(
{
output = "bed:bed",
recipe = {
{"group:fuzzy", "group:fuzzy", "group:fuzzy"},
{"group:planks", "group:planks", "group:planks"},
}
})
bed_player_spawns = {}
local file = io.open(minetest.get_worldpath().."/bed.txt", "r")
if file then
bed_player_spawns = minetest.deserialize(file:read("*all"))
file:close()
end
local timer = 0
local wait = false
minetest.register_globalstep(
function(dtime)
if timer < 2 then
timer = timer + dtime
return
end
timer = 0
local players = #minetest.get_connected_players()
if players ~= 0 and players * 0.5 < players_in_bed then
if minetest.env:get_timeofday() < 0.2 or minetest.env:get_timeofday() > 0.8 then
if not wait then
minetest.chat_send_all("[zzz] " .. players_in_bed .. " of " .. players .. " players slept, skipping to day.")
minetest.after(2, function()
minetest.env:set_timeofday(0.23)
wait = false
end)
wait = true
for _,player in ipairs(minetest.get_connected_players()) do
bed_player_spawns[player:get_player_name()] = player:getpos()
end
local file = io.open(minetest.get_worldpath().."/bed.txt", "w")
if file then
file:write(minetest.serialize(bed_player_spawns))
file:close()
end
end
end
end
end)
minetest.register_on_respawnplayer(
function(player)
local name = player:get_player_name()
if bed_player_spawns[name] then
player:setpos(bed_player_spawns[name])
return true
end
end)
default.log("mod:bed", "loaded")

Binary file not shown.

After

Width:  |  Height:  |  Size: 299 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

10
mods/book/README.txt Normal file
View File

@ -0,0 +1,10 @@
Books mod
=========
By Kaadmy, for Pixture
Mod originally designed for Pixture, may not work elsewhere
This mod adds books that can be written to, just
left-click while holding one, write, and save
Source license: MIT

1
mods/book/depends.txt Normal file
View File

@ -0,0 +1 @@
default

47
mods/book/init.lua Normal file
View File

@ -0,0 +1,47 @@
--
-- Editable books
-- Code based off the books_plus mod
-- By Kaadmy, for Pixture
--
minetest.register_craftitem(
":default:book",
{
description = "Book",
inventory_image = "default_book.png",
stack_max = 1,
on_use = function(itemstack, player, pointed_thing)
local name = player:get_player_name()
local data = minetest.deserialize(itemstack:get_metadata())
local title = ""
local text = ""
if data then
text = data.text
title = data.title
end
local form = default.ui.get_page("core_notabs")
form = form .. "field[0.5,1.25;8,0;title;Title:;"..minetest.formspec_escape(title).."]"
form = form .. "textarea[0.5,1.75;8,6.75;text;Contents:;"..minetest.formspec_escape(text).."]"
form = form .. default.ui.button_exit(2.75, 7.75, 3, 1, "write", "Write")
minetest.show_formspec(name, "book:book", form)
end,
})
minetest.register_on_player_receive_fields(
function(player, form_name, fields)
if form_name ~= "book:book" or not fields.write then return end
local itemstack = player:get_wielded_item()
local data = minetest.deserialize(itemstack:get_metadata())
if not data then data = {} end
data.text = fields.text
data.title = fields.title
itemstack:set_metadata(minetest.serialize(data))
player:set_wielded_item(itemstack)
end)

View File

@ -0,0 +1,8 @@
Builtin item mod
================
By PilzAdam
Tweaked by Kaadmy, for Pixture
Items are now destroyed by lava and flow with water.
Source license: MIT(originally WTFPL)

View File

@ -0,0 +1 @@
default

148
mods/builtin_item/init.lua Normal file
View File

@ -0,0 +1,148 @@
--
-- Builtin item mod
-- By PilzAdam
-- Tweaked by Kaadmy, for Pixture
--
minetest.register_entity(
":__builtin:item",
{
initial_properties = {
hp_max = 1,
physical = true,
collisionbox = {-0.125, -0.125, -0.125, 0.125, 0.125, 0.125},
collide_with_objects = false,
visual = "sprite",
visual_size = {x=0.15, y=0.15},
textures = {""},
spritediv = {x=1, y=1},
initial_sprite_basepos = {x=0, y=0},
is_visible = false,
timer = 0,
},
itemstring = "",
physical_state = true,
set_item = function(self, itemstring)
self.itemstring = itemstring
local stack = ItemStack(itemstring)
local itemtable = stack:to_table()
local itemname = nil
if itemtable then
itemname = stack:to_table().name
end
local item_texture = nil
local item_type = ""
if minetest.registered_items[itemname] then
item_texture = minetest.registered_items[itemname].inventory_image
item_type = minetest.registered_items[itemname].type
end
local prop = {
is_visible = true,
visual = "sprite",
textures = {"unknown_item.png"}
}
if item_texture and item_texture ~= "" then
prop.visual = "wielditem"
prop.textures = {itemname}
prop.visual_size = {x=0.15, y=0.15}
else
prop.visual = "wielditem"
prop.textures = {itemname}
prop.visual_size = {x=0.15, y=0.15}
prop.automatic_rotate = math.pi * 0.5
end
self.object:set_properties(prop)
end,
get_staticdata = function(self)
--return self.itemstring
return minetest.serialize(
{
itemstring = self.itemstring,
always_collect = self.always_collect,
timer = self.timer,
})
end,
on_activate = function(self, staticdata, dtime_s)
if string.sub(staticdata, 1, string.len("return")) == "return" then
local data = minetest.deserialize(staticdata)
if data and type(data) == "table" then
self.itemstring = data.itemstring
self.always_collect = data.always_collect
self.timer = data.timer
if not self.timer then
self.timer = 0
end
self.timer = self.timer+dtime_s
end
else
self.itemstring = staticdata
end
self.object:set_armor_groups({immortal=1})
self.object:setvelocity({x=0, y=2, z=0})
self.object:setacceleration({x=0, y=-10, z=0})
self:set_item(self.itemstring)
end,
on_step = function(self, dtime)
local time = tonumber(minetest.setting_get("remove_items"))
if not time then time = 600 end
if not self.timer then self.timer = 0 end
self.timer = self.timer + dtime
if time ~= 0 and (self.timer > time) then
self.object:remove()
end
local p = self.object:getpos()
local name = minetest.get_node(p).name
if minetest.registered_nodes[name].damage_per_second > 0 or name == "maptools:igniter" then
minetest.sound_play("builtin_item_lava", {pos = self.object:getpos(), gain = 0.45})
self.object:remove()
return
end
p.y = p.y - 0.3
local nn = minetest.get_node(p).name
-- If node is not registered or node is walkably solid:
if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable then
if self.physical_state then
self.object:setvelocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=0, z=0})
self.physical_state = false
self.object:set_properties(
{
physical = false
})
end
else
if not self.physical_state then
self.object:setvelocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=-10, z=0})
self.physical_state = true
self.object:set_properties(
{
physical = true
})
end
end
end,
--[[ -- This causes a duplication glitch if a player walks upon an item and clicks on it at the same time:
on_punch = function(self, hitter)
if self.itemstring ~= "" then
local left = hitter:get_inventory():add_item("main", self.itemstring)
if not left:is_empty() then
self.itemstring = left:to_string()
return
end
end
self.object:remove()
end,
--]]
})
default.log("mod:builtin_item", "loaded")

Binary file not shown.

View File

@ -0,0 +1,9 @@
Crafting guide mod
==================
By Kaadmy, for Pixture
This mod adds a crafting guide in your inventory.
Asset license: CC0
Source license: MIT

View File

@ -0,0 +1 @@
default

169
mods/craftingguide/init.lua Normal file
View File

@ -0,0 +1,169 @@
--
-- Crafting guide mod
-- By Kaadmy, for Pixture
--
craftingguide = {}
craftingguide.items = {}
craftingguide.itemlist = {}
craftingguide.users = {} -- {item = selected item, itemno = recipe no., page = page no.}
local page_size = 8 * 4
function craftingguide.get_formspec(name)
local user = craftingguide.users[name]
local page = user.page
local max_pages = math.floor(#craftingguide.itemlist / page_size) + 1
local form = ""
form = form .. default.ui.get_page("core_craftingguide")
form = form .. "label[0.41,1.74;"..user.itemno.."/"..#craftingguide.items[user.item].."]" -- itemno
form = form .. "label[3.9,8.15;"..page.."/"..max_pages.."]" -- page
form = form .. "label[4.4,2.5;"..user.item.."]" -- itemname
local method = craftingguide.items[user.item][user.itemno].type
if method == "normal" or method == "crafting" then
form = form .. "image[4.25,1.5;1,1;craftingguide_method_crafting.png]"
elseif method == "cooking" then
form = form .. "image[4.25,1.5;1,1;craftingguide_method_cooking.png]"
-- fuel recipes are different
-- elseif method == "fuel" then
-- form = form .. "image[4.25,1.5;1,1;craftingguide_method_fuel.png]"
else
form = form .. "image[4.25,1.5;1,1;craftingguide_method_unknown.png]"
form = form .. "label[4.1,1.73;"..method.."]"
end
form = form .. default.ui.fake_itemstack(6.25, 1.5, ItemStack(user.item), "guide_craftresult")
local craftrecipe = {{}, {}, {}}
local recipes = craftingguide.items[user.item]
local recipe = recipes[user.itemno]
print(dump(recipe))
for slot_index, itemname in pairs(recipe.items) do
local x = slot_index - 1
local group = string.match(itemname, "group:(.*)")
if group == nil then
form = form .. default.ui.fake_simple_itemstack(1.25+(x % recipe.width), 0.5+math.floor(x/recipe.width), itemname, "guide_craftgrid_"..itemname)
else
form = form .. default.ui.item_group(1.25+(x % recipe.width), 0.5+math.floor(x/recipe.width), group, "guide_craftgrid_"..itemname)
end
end
local page_start = ((page * page_size) - page_size) + 1
local inv_x = 0
local inv_y = 0
for item_index = page_start, (page_start + page_size) - 1 do
local recipes = craftingguide.items[craftingguide.itemlist[item_index]]
if recipes ~= nil then
local itemname = ItemStack(recipes[1].output):get_name()
form = form .. default.ui.fake_simple_itemstack(0.25 + inv_x, 4 + inv_y, itemname, "guide_item_"..itemname)
inv_x = inv_x + 1
if inv_x >= 8 then
inv_x = 0
inv_y = inv_y + 1
end
else
break
end
end
return form
end
local function receive_fields(player, form_name, fields)
if form_name == "core_craftingguide" and not fields.quit then
local name = player:get_player_name()
local user = craftingguide.users[name]
local page = user.page
local recipes = craftingguide.items[user.item]
local itemno = user.itemno
local max_pages = math.floor(#craftingguide.itemlist / page_size) + 1
if fields.guide_next_recipe and itemno < #recipes then
itemno = itemno + 1
elseif fields.guide_prev_recipe and itemno > 1 then
itemno = itemno - 1
end
if fields.guide_next and page < max_pages then
page = page + 1
elseif fields.guide_prev and page > 1 then
page = page - 1
end
for fieldname, val in pairs(fields) do
local itemname = string.match(fieldname, "guide_item_(.*)")
if itemname ~= nil then
craftingguide.users[name].item = itemname
craftingguide.users[name].itemno = 1
end
end
craftingguide.users[name].page = page
craftingguide.users[name].itemno = itemno
minetest.show_formspec(name, "core_craftingguide", craftingguide.get_formspec(name))
end
end
local function on_joinplayer(player)
local name = player:get_player_name()
craftingguide.users[name] = {page = 1, item = craftingguide.itemlist[1], itemno = 1}
end
local function on_leaveplayer(player)
local name = player:get_player_name()
craftingguide.users[name] = nil
end
local function load_recipes()
for itemname, itemdef in pairs(minetest.registered_items) do
local recipes = minetest.get_all_craft_recipes(itemname)
if recipes ~= nil and itemname ~= "" then
-- print(dump(recipes))
craftingguide.items[itemname] = recipes
table.insert(craftingguide.itemlist, itemname)
end
end
table.sort(craftingguide.itemlist)
print("Got "..#craftingguide.itemlist.." craftable items")
end
minetest.after(0, load_recipes)
minetest.register_on_joinplayer(on_joinplayer)
minetest.register_on_leaveplayer(on_leaveplayer)
minetest.register_on_player_receive_fields(receive_fields)
local form_craftingguide = default.ui.get_page("core")
form_craftingguide = form_craftingguide .. default.ui.get_itemslot_bg(0.25, 4, 8, 4)
form_craftingguide = form_craftingguide .. default.ui.image_button(2.5, 7.9, 1, 1, "guide_prev", "ui_arrow_bg.png^[transformR90")
form_craftingguide = form_craftingguide .. default.ui.image_button(5, 7.9, 1, 1, "guide_next", "ui_arrow_bg.png^[transformR270")
form_craftingguide = form_craftingguide .. default.ui.image_button(0.25, 0.5, 1, 1, "guide_next_recipe", "ui_arrow_bg.png")
form_craftingguide = form_craftingguide .. default.ui.image_button(0.25, 2.5, 1, 1, "guide_prev_recipe", "ui_arrow_bg.png^[transformFY")
form_craftingguide = form_craftingguide .. default.ui.get_itemslot_bg(1.25, 0.5, 3, 3)
form_craftingguide = form_craftingguide .. default.ui.get_itemslot_bg(6.25, 1.5, 1, 1)
form_craftingguide = form_craftingguide .. "image[5.25,1.5;1,1;"..minetest.formspec_escape("ui_arrow.png^[transformR270").."]"
default.ui.register_page("core_craftingguide", form_craftingguide)

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

10
mods/default/README.txt Normal file
View File

@ -0,0 +1,10 @@
Default mod
===========
By Kaadmy, for Pixture
Adds the required stuff to run
WARNING: This mod will not be compatible with existing mods, tons of stuff has been renamed!
Asset license: CC0
Source license: MIT(Some parts copied from minetest_game)

788
mods/default/crafting.lua Normal file
View File

@ -0,0 +1,788 @@
--
-- Crafting
--
-- Tools
minetest.register_craft(
{
output = "default:pick_wood",
recipe = {
{"", "group:planks", "default:fiber"},
{"", "default:stick", "group:planks"},
{"default:stick", "", ""},
}
})
minetest.register_craft(
{
output = "default:pick_stone",
recipe = {
{"", "group:stone", "default:fiber"},
{"", "default:stick", "group:stone"},
{"default:stick", "", ""},
}
})
minetest.register_craft(
{
output = "default:pick_steel",
recipe = {
{"", "default:ingot_steel", "default:fiber"},
{"", "default:stick", "default:ingot_steel"},
{"default:stick", "", ""},
}
})
minetest.register_craft(
{
output = "default:pick_carbonsteel",
recipe = {
{"", "default:ingot_carbonsteel", "default:fiber"},
{"", "default:stick", "default:ingot_carbonsteel"},
{"default:stick", "", ""},
}
})
minetest.register_craft(
{
output = "default:shovel_wood",
recipe = {
{"", "group:planks", ""},
{"group:planks", "default:fiber", "group:planks"},
{"", "default:stick", ""},
}
})
minetest.register_craft(
{
output = "default:shovel_stone",
recipe = {
{"", "group:stone", ""},
{"group:stone", "default:fiber", "group:stone"},
{"", "default:stick", ""},
}
})
minetest.register_craft(
{
output = "default:shovel_steel",
recipe = {
{"", "default:ingot_steel", ""},
{"default:ingot_steel", "default:fiber", "default:ingot_steel"},
{"", "default:stick", ""},
}
})
minetest.register_craft(
{
output = "default:shovel_carbonsteel",
recipe = {
{"", "default:ingot_carbonsteel", ""},
{"default:ingot_carbonsteel", "default:fiber", "default:ingot_carbonsteel"},
{"", "default:stick", ""},
}
})
minetest.register_craft(
{
output = "default:axe_wood",
recipe = {
{"group:planks", "default:fiber"},
{"group:planks", "default:stick"},
{"", "default:stick"},
}
})
minetest.register_craft(
{
output = "default:axe_stone",
recipe = {
{"group:stone", "default:fiber"},
{"group:stone", "default:stick"},
{"", "default:stick"},
}
})
minetest.register_craft(
{
output = "default:axe_steel",
recipe = {
{"default:ingot_steel", "default:fiber"},
{"default:ingot_steel", "default:stick"},
{"", "default:stick"},
}
})
minetest.register_craft(
{
output = "default:axe_carbonsteel",
recipe = {
{"default:ingot_carbonsteel", "default:fiber"},
{"default:ingot_carbonsteel", "default:stick"},
{"", "default:stick"},
}
})
minetest.register_craft(
{
output = "default:spear_wood",
recipe = {
{"group:planks"},
{"default:fiber"},
{"default:stick"},
}
})
minetest.register_craft(
{
output = "default:spear_stone",
recipe = {
{"group:stone"},
{"default:fiber"},
{"default:stick"},
}
})
minetest.register_craft(
{
output = "default:spear_steel",
recipe = {
{"default:ingot_steel"},
{"default:fiber"},
{"default:stick"},
}
})
minetest.register_craft(
{
output = "default:spear_carbonsteel",
recipe = {
{"default:ingot_carbonsteel"},
{"default:fiber"},
{"default:stick"},
}
})
-- Nodes
minetest.register_craft(
{
output = "default:dust_carbonsteel",
type = "shapeless",
recipe = {"default:lump_coal", "default:lump_iron", "default:lump_iron"}
})
minetest.register_craft(
{
output = "default:fiber",
type = "shapeless",
recipe = {
"default:grass"
}
})
minetest.register_craft(
{
output = "default:fiber 2",
type = "shapeless",
recipe = {
"default:tall_grass"
}
})
minetest.register_craft(
{
output = "default:fiber 3",
type = "shapeless",
recipe = {
"default:leaves", "default:leaves", "default:leaves", "default:leaves"
}
})
minetest.register_craft(
{
output = "default:gravel",
recipe = {
{"default:cobble"},
}
})
minetest.register_craft(
{
output = "default:bucket",
recipe = {
{"default:fiber", "default:stick", "default:fiber"},
{"group:planks", "", "group:planks"},
{"group:planks", "group:planks", "group:planks"},
}
})
minetest.register_craft(
{
output = "default:brick",
recipe = {
{"default:dirt", "default:gravel", "default:dirt"},
{"default:gravel", "default:dirt", "default:gravel"},
{"default:dirt", "default:gravel", "default:dirt"},
}
})
minetest.register_craft(
{
output = "default:block_steel",
recipe = {
{"default:ingot_steel", "default:ingot_steel", "default:ingot_steel"},
{"default:ingot_steel", "default:ingot_steel", "default:ingot_steel"},
{"default:ingot_steel", "default:ingot_steel", "default:ingot_steel"},
}
})
minetest.register_craft(
{
output = "default:block_coal",
recipe = {
{"default:lump_coal", "default:lump_coal", "default:lump_coal"},
{"default:lump_coal", "default:lump_coal", "default:lump_coal"},
{"default:lump_coal", "default:lump_coal", "default:lump_coal"},
}
})
minetest.register_craft(
{
output = "default:dirt_path 4",
recipe = {
{"default:dirt", "default:dirt", "default:dirt"},
{"default:gravel", "default:gravel", "default:gravel"},
{"default:gravel", "default:gravel", "default:gravel"},
}
})
minetest.register_craft(
{
output = "default:heated_dirt_path 8",
recipe = {
{"default:ingot_steel", "default:dirt_path", "default:ingot_steel"},
{"default:dirt_path", "default:dirt_path", "default:dirt_path"},
{"default:gravel", "default:gravel", "default:gravel"},
}
})
minetest.register_craft(
{
output = "default:planks 4",
recipe = {
{"default:tree"},
}
})
minetest.register_craft(
{
output = "default:planks_oak 4",
recipe = {
{"default:tree_oak"},
}
})
minetest.register_craft(
{
output = "default:planks_birch 4",
recipe = {
{"default:tree_birch"},
}
})
minetest.register_craft(
{
output = "default:frame",
recipe = {
{"default:fiber", "default:stick", "default:fiber"},
{"default:stick", "group:planks", "default:stick"},
{"default:fiber", "default:stick", "default:fiber"},
}
})
minetest.register_craft(
{
output = "default:reinforced_frame",
recipe = {
{"default:fiber", "default:stick", "default:fiber"},
{"default:stick", "default:frame", "default:stick"},
{"default:fiber", "default:stick", "default:fiber"},
}
})
minetest.register_craft(
{
output = "default:stick 4",
recipe = {
{"group:planks"},
}
})
minetest.register_craft(
{
output = "default:fence 4",
recipe = {
{"default:stick", "", "default:stick"},
{"default:fiber", "group:planks", "default:fiber"},
{"default:stick", "", "default:stick"},
}
})
minetest.register_craft(
{
output = "default:sign 2",
recipe = {
{"group:planks", "default:fiber", "group:planks"},
{"group:planks", "group:planks", "group:planks"},
{"", "default:stick", ""},
}
})
minetest.register_craft(
{
output = "default:reinforced_cobble",
recipe = {
{"default:fiber", "default:stick", "default:fiber"},
{"default:stick", "default:cobble", "default:stick"},
{"default:fiber", "default:stick", "default:fiber"},
}
})
minetest.register_craft(
{
output = "default:torch 4",
recipe = {
{"default:lump_coal"},
{"default:fiber"},
{"default:stick"},
}
})
minetest.register_craft(
{
output = "default:chest",
recipe = {
{"group:planks", "group:planks", "group:planks"},
{"group:planks", "default:fiber", "group:planks"},
{"group:planks", "group:planks", "group:planks"},
}
})
minetest.register_craft(
{
output = "default:chest_locked",
recipe = {
{"default:fiber", "default:stick", "default:fiber"},
{"default:stick", "default:chest", "default:stick"},
{"default:fiber", "default:ingot_steel", "default:fiber"},
}
})
minetest.register_craft(
{
output = "default:furnace",
recipe = {
{"group:stone", "group:stone", "group:stone"},
{"group:stone", "", "group:stone"},
{"group:stone", "group:stone", "group:stone"},
}
})
minetest.register_craft(
{
output = "default:sandstone 2",
recipe = {
{"default:sand", "default:sand"},
{"default:sand", "default:sand"},
}
})
minetest.register_craft(
{
output = "default:paper",
recipe = {
{"default:papyrus", "default:papyrus", "default:papyrus"},
}
})
minetest.register_craft(
{
output = "default:book",
recipe = {
{"default:fiber", "default:stick", "default:paper"},
{"default:fiber", "default:stick", "default:paper"},
{"default:fiber", "default:stick", "default:paper"},
}
})
minetest.register_craft(
{
output = "default:bookshelf",
recipe = {
{"group:planks", "group:planks", "group:planks"},
{"default:book", "default:book", "default:book"},
{"group:planks", "group:planks", "group:planks"},
}
})
minetest.register_craft(
{
output = "default:ladder 2",
recipe = {
{"default:stick", "", "default:stick"},
{"default:fiber", "default:stick", "default:fiber"},
{"default:stick", "", "default:stick"},
}
})
--
-- Crafting (tool repair)
--
minetest.register_craft(
{
type = "toolrepair",
additional_wear = -0.1,
})
--
-- Cooking recipes
--
minetest.register_craft(
{
type = "cooking",
output = "default:glass",
recipe = "default:sand",
cooktime = 3,
})
minetest.register_craft(
{
type = "cooking",
output = "default:lump_coal",
recipe = "default:tree",
cooktime = 4,
})
minetest.register_craft(
{
type = "cooking",
output = "default:stone",
recipe = "default:cobble",
cooktime = 6,
})
minetest.register_craft(
{
type = "cooking",
output = "default:ingot_steel",
recipe = "default:lump_iron",
cooktime = 3,
})
minetest.register_craft(
{
type = "cooking",
output = "default:ingot_carbonsteel",
recipe = "default:dust_carbonsteel",
cooktime = 5,
})
minetest.register_craft(
{
type = "cooking",
output = "default:lump_sugar",
recipe = "default:papyrus",
cooktime = 7,
})
--
-- Fuels
--
minetest.register_craft(
{
type = "fuel",
recipe = "group:tree",
burntime = 20,
})
minetest.register_craft(
{
type = "fuel",
recipe = "group:planks",
burntime = 9,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:planks_oak",
burntime = 12,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:planks_birch",
burntime = 12,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:frame",
burntime = 12,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:reinforced_frame",
burntime = 17,
})
minetest.register_craft(
{
type = "fuel",
recipe = "group:leaves",
burntime = 1,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:cactus",
burntime = 10,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:papyrus",
burntime = 2,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:bookshelf",
burntime = 30,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:fence",
burntime = 10,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:ladder",
burntime = 5,
})
minetest.register_craft(
{
type = "fuel",
recipe = "group:planks",
burntime = 5,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:torch",
burntime = 5,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:sign",
burntime = 10,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:chest",
burntime = 20,
})
minetest.register_craft(
{
type = "fuel",
recipe = "group:sapling",
burntime = 7,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:apple",
burntime = 3,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:lump_coal",
burntime = 30,
})
minetest.register_craft(
{
type = "fuel",
recipe = "default:block_coal",
burntime = 270,
})
--
-- Crafting items
--
minetest.register_craftitem(
"default:fiber",
{
description = "Fiber",
inventory_image = "default_fiber.png",
})
minetest.register_craftitem(
"default:bucket_water",
{
description = "Water Bucket",
inventory_image = "default_bucket_water.png",
stack_max = 1,
wield_scale = {x=1,y=1,z=2},
liquids_pointable = true,
on_place = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end
itemstack:take_item()
local inv=user:get_inventory()
if inv:room_for_item("main", {name="default:bucket"}) then
inv:add_item("main", "default:bucket")
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, "default:bucket")
end
local pos = pointed_thing.above
if minetest.registered_nodes[minetest.get_node(pointed_thing.under).name].buildable_to then
pos=pointed_thing.under
end
minetest.add_node(pos, {name = "default:water_source"})
return itemstack
end
})
minetest.register_craftitem(
"default:bucket",
{
description = "Empty Bucket",
inventory_image = "default_bucket.png",
wield_scale = {x=1,y=1,z=2},
liquids_pointable = true,
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type ~= "node" then return end
local nodename=minetest.get_node(pointed_thing.under).name
if nodename == "default:water_source" then
itemstack:take_item()
local inv=user:get_inventory()
if inv:room_for_item("main", {name="default:bucket_water"}) then
inv:add_item("main", "default:bucket_water")
else
local pos = user:getpos()
pos.y = math.floor(pos.y + 0.5)
minetest.add_item(pos, "default:bucket_water")
end
minetest.remove_node(pointed_thing.under)
end
return itemstack
end
})
minetest.register_craftitem(
"default:stick",
{
description = "Stick",
inventory_image = "default_stick.png",
groups = {stick = 1}
})
minetest.register_craftitem(
"default:paper",
{
description = "Paper",
inventory_image = "default_paper.png",
})
minetest.register_craftitem(
"default:book",
{
description = "Book",
inventory_image = "default_book.png",
wield_scale = {x=1,y=1,z=2},
})
minetest.register_craftitem(
"default:lump_coal",
{
description = "Coal Lump",
inventory_image = "default_lump_coal.png",
})
minetest.register_craftitem(
"default:lump_iron",
{
description = "Iron Lump",
inventory_image = "default_lump_iron.png",
})
minetest.register_craftitem(
"default:dust_carbonsteel",
{
description = "Carbon Steel Dust",
inventory_image = "default_dust_carbonsteel.png",
})
minetest.register_craftitem(
"default:ingot_steel",
{
description = "Steel Ingot",
inventory_image = "default_ingot_steel.png",
})
minetest.register_craftitem(
"default:ingot_carbonsteel",
{
description = "Carbon Steel Ingot",
inventory_image = "default_ingot_carbonsteel.png",
})
minetest.register_craftitem(
"default:lump_sugar",
{
description = "Sugar lump",
inventory_image = "default_lump_sugar.png",
on_use = minetest.item_eat({hp = 1, sat = 10})
})
default.log("crafting", "loaded")

311
mods/default/formspec.lua Normal file
View File

@ -0,0 +1,311 @@
default.ui = {}
default.ui.core = {}
default.ui.core.colors = "listcolors[#00000000;#00000010;#00000000;#68B259;#FFF]"
default.ui.core.bg = "bgcolor[#00000000;false]"
function default.ui.get_itemslot_bg(x, y, w, h)
local out = ""
for i = 0, w - 1, 1 do
for j = 0, h - 1, 1 do
out = out .."image["..x+i..","..y+j..";1,1;ui_itemslot.png]"
end
end
return out
end
function default.ui.get_hotbar_itemslot_bg(x, y, w, h)
local out = ""
for i = 0, w - 1, 1 do
for j = 0, h - 1, 1 do
out = out .."image["..x+i..","..y+j..";1,1;ui_itemslot.png^ui_itemslot_dark.png]"
end
end
return out
end
function default.ui.image_button(x, y, w, h, name, image)
local image = minetest.formspec_escape(image)
return "image_button["..x..","..y..";"..w..","..h..";"..image..";"..name..";;;false;"..image.."]"
end
function default.ui.button(x, y, w, h, name, label, noclip)
local nc = "false"
if noclip then
nc = "true"
end
if w == 2 then
return "image_button["..x..","..y..";"..w..","..h..";ui_button_2w_inactive.png;"..name..";"..label..";"..nc..";false;ui_button_2w_active.png]"
else
return "image_button["..x..","..y..";"..w..","..h..";ui_button_3w_inactive.png;"..name..";"..label..";"..nc..";false;ui_button_3w_active.png]"
end
end
function default.ui.button_exit(x, y, w, h, name, label, noclip)
local nc = "false"
if noclip then
nc = "true"
end
if w == 2 then
return "image_button_exit["..x..","..y..";"..w..","..h..";ui_button_2w_inactive.png;"..name..";"..label..";"..nc..";false;ui_button_2w_active.png]"
else
return "image_button_exit["..x..","..y..";"..w..","..h..";ui_button_3w_inactive.png;"..name..";"..label..";"..nc..";false;ui_button_3w_active.png]"
end
end
function default.ui.tab(x, y, name, icon, tooltip)
local tooltip = tooltip or ""
local shifted_icon = "[combine:16x16:0,0=ui_tab_active.png:0,1="..icon
local form = ""
form = form .. "image_button["..x..","..y..";1,1;ui_tab_inactive.png^"..icon..";"..name..";;true;false;"..minetest.formspec_escape(shifted_icon).."]"
form = form .. "tooltip["..name..";"..tooltip.."]"
return form
end
local function get_itemdef_field(itemname, fieldname)
if not minetest.registered_items[itemname] then
return nil
end
return minetest.registered_items[itemname][fieldname]
end
function default.ui.fake_itemstack(x, y, itemstack, name)
local name = name or "fake_itemstack"
local itemname = itemstack:get_name()
local itemamt = itemstack:get_count()
local itemimage = ""
if itemname ~= "" then
local inventory_image = get_itemdef_field(itemname, "inventory_image")
if inventory_image and inventory_image ~= "" then
itemimage = inventory_image
else
local tiles = get_itemdef_field(itemname, "tiles")
local t1 = tiles[1]
local t2 = tiles[1]
local t3 = tiles[1]
if #tiles == 3 then
t1 = tiles[1]
t2 = tiles[3]
t3 = tiles[3]
elseif #tiles == 6 then
t1 = tiles[1]
t2 = tiles[5]
t3 = tiles[6]
end
itemimage=minetest.inventorycube(t1, t2, t3)
end
end
itemimage = minetest.formspec_escape(itemimage)
local itemdesc = ""
if minetest.registered_items[itemname].description ~= nil then
itemdesc = minetest.registered_items[itemname].description
end
if itemamt <= 1 then itemamt = "" end
local result = ""
if itemname ~= "" then
result = result .. "image_button["..x..","..y..";1,1;"..itemimage..";"..name..";;false;false;"..itemimage.."]"
result = result .. "label["..(x+0.6)..","..(y+0.5)..";"..itemamt.."]"
result = result .. "tooltip["..name..";"..itemdesc.."]"
end
return result
end
function default.ui.fake_simple_itemstack(x, y, itemname, name)
local name = name or "fake_simple_itemstack"
local itemimage = ""
if itemname ~= "" then
local inventory_image = get_itemdef_field(itemname, "inventory_image")
if inventory_image and inventory_image ~= "" then
itemimage = inventory_image
else
local tiles = get_itemdef_field(itemname, "tiles")
local t1 = tiles[1]
local t2 = tiles[1]
local t3 = tiles[1]
if #tiles == 3 then
t1 = tiles[1]
t2 = tiles[3]
t3 = tiles[3]
elseif #tiles == 6 then
t1 = tiles[1]
t2 = tiles[5]
t3 = tiles[6]
end
itemimage=minetest.inventorycube(t1, t2, t3)
end
end
itemimage = minetest.formspec_escape(itemimage)
local itemdesc = ""
if minetest.registered_items[itemname].description ~= nil then
itemdesc = minetest.registered_items[itemname].description
end
local result = ""
if itemname ~= "" then
result = result .. "image_button["..x..","..y..";1,1;"..itemimage..";"..name..";;false;false;"..itemimage.."]"
result = result .. "tooltip["..name..";"..itemdesc.."]"
end
return result
end
function default.ui.item_group(x, y, group, name)
local name = name or "fake_simple_itemstack"
local itemname = ""
for itemn, itemdef in pairs(minetest.registered_items) do
if minetest.get_item_group(itemn, group) ~= 0 then
itemname = itemn
end
end
local itemimage = ""
if itemname ~= "" then
local inventory_image = get_itemdef_field(itemname, "inventory_image")
if inventory_image and inventory_image ~= "" then
itemimage = inventory_image
else
local tiles = get_itemdef_field(itemname, "tiles")
local t1 = tiles[1]
local t2 = tiles[1]
local t3 = tiles[1]
if #tiles == 3 then
t1 = tiles[1]
t2 = tiles[3]
t3 = tiles[3]
elseif #tiles == 6 then
t1 = tiles[1]
t2 = tiles[5]
t3 = tiles[6]
end
itemimage=minetest.inventorycube(t1, t2, t3)
end
end
local result = ""
if itemname ~= "" then
local itemdesc = ""
itemimage = minetest.formspec_escape(itemimage)
if minetest.registered_items[itemname].description ~= nil then
itemdesc = minetest.registered_items[itemname].description
end
result = result .. "image_button["..x..","..y..";1,1;"..itemimage..";"..name..";;false;false;"..itemimage.."]"
result = result .. "label["..(x+0.4)..","..(y+0.35)..";G]"
result = result .. "tooltip["..name..";Group: "..group.."]"
end
return result
end
default.ui.registered_pages = {
}
function default.ui.get_page(name)
local page= default.ui.registered_pages[name]
if page == nil then
default.log("UI page '" .. name .. "' is not yet registered", "dev")
page = ""
end
return page
end
function default.ui.register_page(name, form)
default.ui.registered_pages[name] = form
end
local form_core = ""
form_core = form_core .. "size[8.5,9]"
form_core = form_core .. default.ui.core.colors
form_core = form_core .. default.ui.core.bg
form_core = form_core .. default.ui.tab(-0.9, 1, "tab_crafting", "ui_icon_crafting.png", "Crafting")
if minetest.get_modpath("craftingguide") ~= nil then
form_core = form_core .. default.ui.tab(-0.9, 1.78, "tab_craftingguide", "ui_icon_craftingguide.png", "Crafting Guide")
end
if minetest.get_modpath("armor") ~= nil then
form_core = form_core .. default.ui.tab(-0.9, 2.56, "tab_armor", "ui_icon_armor.png", "Armor")
end
if minetest.get_modpath("achievements") ~= nil then
form_core = form_core .. default.ui.tab(-0.9, 3.34, "tab_achievements", "ui_icon_achievements.png", "Achievements")
end
form_core = form_core .. "background[0,0;8.5,9;ui_formspec_bg_tall.png]"
default.ui.register_page("core", form_core)
default.ui.register_page("core_2part", form_core .. "background[0,0;8.5,4.5;ui_formspec_bg_short.png]")
local form_core_notabs = ""
form_core_notabs = form_core_notabs .. "size[8.5,9]"
form_core_notabs = form_core_notabs .. default.ui.core.colors
form_core_notabs = form_core_notabs .. default.ui.core.bg
form_core_notabs = form_core_notabs .. "background[0,0;8.5,9;ui_formspec_bg_tall.png]"
default.ui.register_page("core_notabs", form_core_notabs)
default.ui.register_page("core_notabs_2part", form_core_notabs .. "background[0,0;8.5,4.5;ui_formspec_bg_short.png]")
local form_crafting = default.ui.get_page("core_2part")
form_crafting = form_crafting .. "list[current_player;craft;2.25,0.75;3,3;]"
form_crafting = form_crafting .. "image[5.25,1.75;1,1;ui_arrow.png^[transformR270]"
form_crafting = form_crafting .. "list[current_player;craftpreview;6.25,1.75;1,1;]"
form_crafting = form_crafting .. default.ui.get_itemslot_bg(2.25, 0.75, 3, 3)
form_crafting = form_crafting .. default.ui.get_itemslot_bg(6.25, 1.75, 1, 1)
form_crafting = form_crafting .. "list[current_player;main;0.25,4.75;8,4;]"
form_crafting = form_crafting .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1)
form_crafting = form_crafting .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3)
default.ui.register_page("core_crafting", form_crafting)
function default.ui.receive_fields(player, form_name, fields)
local name = player:get_player_name()
-- print("Received formspec fields from '"..name.."': "..dump(fields))
if fields.tab_crafting then
minetest.show_formspec(name, "core_crafting", default.ui.get_page("core_crafting"))
elseif minetest.get_modpath("craftingguide") ~= nil and fields.tab_craftingguide then
minetest.show_formspec(name, "core_craftingguide", craftingguide.get_formspec(name))
elseif minetest.get_modpath("armor") ~= nil and fields.tab_armor then
minetest.show_formspec(name, "core_armor", default.ui.get_page("core_armor"))
elseif minetest.get_modpath("achievements") ~= nil and fields.tab_achievements then
minetest.show_formspec(name, "core_achievements", default.ui.get_page("core_achievements"))
end
end
minetest.register_on_player_receive_fields(
function(player, form_name, fields)
default.ui.receive_fields(player, form_name, fields)
end)
minetest.register_on_joinplayer(
function(player)
local function cb(player)
minetest.chat_send_player(player:get_player_name(), "Have fun!")
end
minetest.after(1.0, cb, player)
player:set_inventory_formspec(default.ui.get_page("core_crafting"))
end)

294
mods/default/functions.lua Normal file
View File

@ -0,0 +1,294 @@
--
-- Functions/ABMs
--
-- Saplings growing
function default.grow_tree(pos, variety)
local function grow()
if variety == "apple" then
minetest.place_schematic({x = pos.x-2, y = pos.y-1, z = pos.z-2}, minetest.get_modpath("default").."/schematics/default_tree.mts", "0", {}, false)
elseif variety == "oak" then
minetest.place_schematic({x = pos.x-2, y = pos.y-1, z = pos.z-2}, minetest.get_modpath("default").."/schematics/default_tree.mts", "0", {["default:leaves"] = "default:leaves_oak", ["default:tree"] = "default:tree_oak", ["default:apple"] = "air"}, false)
elseif variety == "birch" then
minetest.place_schematic({x = pos.x-1, y = pos.y-1, z = pos.z-1}, minetest.get_modpath("default").."/schematics/default_squaretree.mts", "0", {["default:leaves"] = "default:leaves_birch", ["default:tree"] = "default:tree_birch", ["default:apple"] = "air"}, false)
end
end
minetest.remove_node(pos)
minetest.after(0, grow)
default.log(variety.." tree sapling grows at "..minetest.pos_to_string(pos), "info")
end
minetest.register_abm( -- apple trees or default trees
{
nodenames = {"default:sapling"},
interval = 10,
chance = 40,
action = function(pos, node)
local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
if is_soil == nil or is_soil == 0 then return end
default.grow_tree(pos, "apple")
end
})
minetest.register_abm( -- oak trees
{
nodenames = {"default:sapling_oak"},
interval = 10,
chance = 60,
action = function(pos, node)
local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
if is_soil == nil or is_soil == 0 then return end
default.grow_tree(pos, "oak")
end
})
minetest.register_abm( -- birch trees
{
nodenames = {"default:sapling_birch"},
interval = 10,
chance = 50,
action = function(pos, node)
local is_soil = minetest.registered_nodes[minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name].groups.soil
if is_soil == nil or is_soil == 0 then return end
default.grow_tree(pos, "birch")
end
})
-- Vertical plants
function default.dig_up(pos, node, digger)
-- if digger == nil then return end
local np = {x = pos.x, y = pos.y + 1, z = pos.z}
local nn = minetest.get_node(np)
if nn.name == node.name then
minetest.node_dig(np, nn, digger)
end
end
-- Leaf decay
default.leafdecay_trunk_cache = {}
default.leafdecay_enable_cache = true
-- Spread the load of finding trunks
default.leafdecay_trunk_find_allow_accumulator = 0
minetest.register_globalstep(function(dtime)
local finds_per_second = 5000
default.leafdecay_trunk_find_allow_accumulator =
math.floor(dtime * finds_per_second)
end)
default.after_place_leaves = function(pos, placer, itemstack, pointed_thing)
local node = minetest.get_node(pos)
node.param2 = 1
minetest.set_node(pos, node)
end
minetest.register_abm( -- leaf decay
{
nodenames = {"group:leafdecay"},
neighbors = {"air", "group:liquid"},
-- A low interval and a high inverse chance spreads the load
interval = 2,
chance = 3,
action = function(p0, node, _, _)
--print("leafdecay ABM at "..p0.x..", "..p0.y..", "..p0.z..")")
local do_preserve = false
local d = minetest.registered_nodes[node.name].groups.leafdecay
if not d or d == 0 then
--print("not groups.leafdecay")
return
end
local n0 = minetest.get_node(p0)
if n0.param2 ~= 0 then
--print("param2 ~= 0")
return
end
local p0_hash = nil
if default.leafdecay_enable_cache then
p0_hash = minetest.hash_node_position(p0)
local trunkp = default.leafdecay_trunk_cache[p0_hash]
if trunkp then
local n = minetest.get_node(trunkp)
local reg = minetest.registered_nodes[n.name]
-- Assume ignore is a trunk, to make the thing work at the border of the active area
if n.name == "ignore" or (reg and reg.groups.tree and reg.groups.tree ~= 0) then
--print("cached trunk still exists")
return
end
--print("cached trunk is invalid")
-- Cache is invalid
table.remove(default.leafdecay_trunk_cache, p0_hash)
end
end
if default.leafdecay_trunk_find_allow_accumulator <= 0 then
return
end
default.leafdecay_trunk_find_allow_accumulator =
default.leafdecay_trunk_find_allow_accumulator - 1
-- Assume ignore is a trunk, to make the thing work at the border of the active area
local p1 = minetest.find_node_near(p0, d, {"ignore", "group:tree"})
if p1 then
do_preserve = true
if default.leafdecay_enable_cache then
--print("caching trunk")
-- Cache the trunk
default.leafdecay_trunk_cache[p0_hash] = p1
end
end
if not do_preserve then
-- Drop stuff other than the node itself
local itemstacks = minetest.get_node_drops(n0.name)
for _, itemname in ipairs(itemstacks) do
if minetest.get_item_group(n0.name, "leafdecay_drop") ~= 0 or itemname ~= n0.name then
local p_drop = {
x = p0.x - 0.5 + math.random(),
y = p0.y - 0.5 + math.random(),
z = p0.z - 0.5 + math.random(),
}
minetest.add_item(p_drop, itemname)
end
end
-- Remove node
minetest.remove_node(p0)
nodeupdate(p0)
end
end
})
minetest.register_abm( -- dirt becomes dirt with grass if uncovered
{
nodenames = {"default:dirt"},
interval = 2,
chance = 40,
action = function(pos, node)
local above = {x=pos.x, y=pos.y+1, z=pos.z}
local name = minetest.get_node(above).name
local nodedef = minetest.registered_nodes[name]
if nodedef and (nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none" and (minetest.get_node_light(above) or 0) >= 11 then
minetest.set_node(pos, {name = "default:dirt_with_grass"})
end
end
})
minetest.register_abm( -- dirt with grass becomes dirt if covered
{
nodenames = {"default:dirt_with_grass"},
interval = 2,
chance = 10,
action = function(pos, node)
local above = {x=pos.x, y=pos.y+1, z=pos.z}
local name = minetest.get_node(above).name
local nodedef = minetest.registered_nodes[name]
if name ~= "ignore" and nodedef and not ((nodedef.sunlight_propagates or nodedef.paramtype == "light") and nodedef.liquidtype == "none") then
minetest.set_node(pos, {name = "default:dirt"})
end
end
})
minetest.register_abm( -- grass expands
{
nodenames = {"default:grass"},
interval = 20,
chance = 160,
action = function(pos, node)
local rx = math.random(0, 2) - 1
local rz = math.random(0, 2) - 1
local edgepos = {x = pos.x+rx, y = pos.y, z = pos.z+rz}
local downpos = {x = pos.x+rx, y = pos.y-1, z = pos.z+rz}
local edgenode = minetest.get_node(edgepos)
local downnode = minetest.get_node(downpos)
if edgenode.name == "air" and downnode.name ~= "air" and downnode.buildable_to == false and walkable == true then
minetest.set_node(edgepos, {name = "default:grass"})
end
end
})
minetest.register_abm( -- cactus grows
{
nodenames = {"default:cactus"},
neighbors = {"group:sand"},
interval = 20,
chance = 10,
action = function(pos, node)
pos.y = pos.y-1
local name = minetest.get_node(pos).name
if minetest.get_item_group(name, "sand") ~= 0 then
pos.y = pos.y+1
local height = 0
while minetest.get_node(pos).name == "default:cactus" and height < 3 do
height = height+1
pos.y = pos.y+1
end
if height < 3 then
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name="default:cactus"})
end
end
end
end,
})
minetest.register_abm( -- papyrus grows
{
nodenames = {"default:papyrus"},
neighbors = {"default:sand", "default:dirt_with_grass", "default_dirt"},
interval = 20,
chance = 10,
action = function(pos, node)
pos.y = pos.y-1
local name = minetest.get_node(pos).name
if name == "default:sand" or name == "default:dirt" or name == "default:dirt_with_grass" then
if minetest.find_node_near(pos, 3, {"group:water"}) == nil then
return
end
pos.y = pos.y+1
local height = 0
while minetest.get_node(pos).name == "default:papyrus" and height < 3 do
height = height+1
pos.y = pos.y+1
end
if height < 3 then
if minetest.get_node(pos).name == "air" then
minetest.set_node(pos, {name="default:papyrus"})
end
end
end
end,
})
minetest.register_abm( -- torch flame
{
nodenames = {"default:torch"},
interval = 5,
chance = 1,
action = function(pos, node)
minetest.add_particlespawner(
{
amount = 10,
time = 5,
minpos = {x = pos.x-0.1, y = pos.y-0.4, z = pos.z-0.1},
maxpos = {x = pos.x+0.1, y = pos.y, z = pos.z+0.1},
minvel = {x = -0.3, y = 0.3, z = -0.3},
maxvel = {x = 0.3, y = 1, z = 0.3},
minacc = {x = 0, y = 0.5, z = -0},
maxacc = {x = 0, y = 2, z = 0},
minexptime = 0.3,
maxexptime = 0.6,
minsize = 4,
maxsize = 6,
texture = "spark.png"
})
end
})
default.log("functions", "loaded")

267
mods/default/furnace.lua Normal file
View File

@ -0,0 +1,267 @@
--
-- Furnace
--
function default.furnace_active_formspec(percent, item_percent)
local form = default.ui.get_page("core_2part")
form = form .. "list[current_player;main;0.25,4.75;8,4;]"
form_furnace = form_furnace .. "listring[current_player;main]"
form = form .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1)
form = form .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3)
form = form .. "list[current_name;src;2.25,0.75;1,1;]"
form_furnace = form_furnace .. "listring[current_name;src]"
form = form .. default.ui.get_itemslot_bg(2.25, 0.75, 1, 1)
form = form .. "list[current_name;fuel;2.25,2.75;1,1;]"
form = form .. default.ui.get_itemslot_bg(2.25, 2.75, 1, 1)
form = form .. "list[current_name;dst;4.25,1.25;2,2;]"
form_furnace = form_furnace .. "listring[current_name;dst]"
form = form .. default.ui.get_hotbar_itemslot_bg(4.25, 1.25, 2, 2)
form = form .. "image[2.25,1.75;1,1;ui_fire_bg.png^[lowpart:"
form = form .. (100-percent) .. ":ui_fire.png]"
form = form .. "image[3.25,1.75;1,1;ui_arrow_bg.png^[lowpart:"
form = form .. (item_percent) .. ":ui_arrow.png^[transformR270]"
return form
end
local form_furnace = default.ui.get_page("core_2part")
form_furnace = form_furnace .. "list[current_player;main;0.25,4.75;8,4;]"
form_furnace = form_furnace .. "listring[current_player;main]"
form_furnace = form_furnace .. default.ui.get_hotbar_itemslot_bg(0.25, 4.75, 8, 1)
form_furnace = form_furnace .. default.ui.get_itemslot_bg(0.25, 5.75, 8, 3)
form_furnace = form_furnace .. "list[current_name;src;2.25,0.75;1,1;]"
form_furnace = form_furnace .. "listring[current_name;src]"
form_furnace = form_furnace .. default.ui.get_itemslot_bg(2.25, 0.75, 1, 1)
form_furnace = form_furnace .. "list[current_name;fuel;2.25,2.75;1,1;]"
form_furnace = form_furnace .. default.ui.get_itemslot_bg(2.25, 2.75, 1, 1)
form_furnace = form_furnace .. "list[current_name;dst;4.25,1.25;2,2;]"
form_furnace = form_furnace .. "listring[current_name;dst]"
form_furnace = form_furnace .. default.ui.get_hotbar_itemslot_bg(4.25, 1.25, 2, 2)
form_furnace = form_furnace .. "image[2.25,1.75;1,1;ui_fire_bg.png]"
form_furnace = form_furnace .. "image[3.25,1.75;1,1;ui_arrow_bg.png^[transformR270]"
default.ui.register_page("default_furnace_inactive", form_furnace)
minetest.register_node(
"default:furnace",
{
description = "Furnace",
tiles ={"default_furnace_top.png", "default_furnace_top.png", "default_furnace_sides.png",
"default_furnace_sides.png", "default_furnace_sides.png", "default_furnace_front.png"},
paramtype2 = "facedir",
groups = {cracky = 2},
legacy_facedir_simple = true,
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", default.ui.get_page("default_furnace_inactive"))
meta:set_string("infotext", "Furnace")
local inv = meta:get_inventory()
inv:set_size("fuel", 1)
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("fuel") then
return false
elseif not inv:is_empty("dst") then
return false
elseif not inv:is_empty("src") then
return false
end
return true
end,
})
minetest.register_node(
"default:furnace_active",
{
description = "Furnace",
tiles ={"default_furnace_top.png", "default_furnace_top.png", "default_furnace_sides.png",
"default_furnace_sides.png", "default_furnace_sides.png", "default_furnace_front.png^default_furnace_flame.png"},
paramtype2 = "facedir",
light_source = 8,
drop = "default:furnace",
groups = {cracky = 2},
legacy_facedir_simple = true,
is_ground_content = false,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", default.ui.get_page("default_furnace_inactive"))
meta:set_string("infotext", "Furnace");
local inv = meta:get_inventory()
inv:set_size("fuel", 1)
inv:set_size("src", 1)
inv:set_size("dst", 4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("fuel") then
return false
elseif not inv:is_empty("dst") then
return false
elseif not inv:is_empty("src") then
return false
end
return true
end,
})
function swap_node(pos, name)
local node = minetest.get_node(pos)
if node.name == name then
return
end
node.name = name
minetest.swap_node(pos, node)
end
minetest.register_abm(
{
nodenames = {"default:furnace", "default:furnace_active"},
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
--
-- Initialize metadata
--
local meta = minetest.get_meta(pos)
local fuel_time = meta:get_float("fuel_time") or 0
local src_time = meta:get_float("src_time") or 0
local fuel_totaltime = meta:get_float("fuel_totaltime") or 0
--
-- Initialize inventory
--
local inv = meta:get_inventory()
for listname, size in pairs(
{
src = 1,
fuel = 1,
dst = 4,
}) do
if inv:get_size(listname) ~= size then
inv:set_size(listname, size)
end
end
local srclist = inv:get_list("src")
local fuellist = inv:get_list("fuel")
local dstlist = inv:get_list("dst")
--
-- Cooking
--
-- Check if we have cookable content
local cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
local cookable = true
if cooked.time == 0 then
cookable = false
end
-- Check if we have enough fuel to burn
if fuel_time < fuel_totaltime then
-- The furnace is currently active and has enough fuel
fuel_time = fuel_time + 1
-- If there is a cookable item then check if it is ready yet
if cookable then
src_time = src_time + 1
if src_time >= cooked.time then
-- Place result in dst list if possible
if inv:room_for_item("dst", cooked.item) then
inv:add_item("dst", cooked.item)
inv:set_stack("src", 1, aftercooked.items[1])
src_time = 0
end
end
end
else
-- Furnace ran out of fuel
if cookable then
-- We need to get new fuel
local fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
if fuel.time == 0 then
-- No valid fuel in fuel list
fuel_totaltime = 0
fuel_time = 0
src_time = 0
else
-- Take fuel from fuel list
inv:set_stack("fuel", 1, afterfuel.items[1])
fuel_totaltime = fuel.time
fuel_time = 0
end
else
-- We don't need to get new fuel since there is no cookable item
fuel_totaltime = 0
fuel_time = 0
src_time = 0
end
end
--
-- Update formspec, infotext and node
--
local formspec = default.ui.get_page("default_furnace_inactive")
local item_state = ""
local item_percent = 0
if cookable then
item_percent = math.floor(src_time / cooked.time * 100)
item_state = item_percent .. "%"
else
if srclist[1]:is_empty() then
item_state = "Empty"
else
item_state = "Not cookable"
end
end
local fuel_state = "Empty"
local active = "inactive "
if fuel_time <= fuel_totaltime and fuel_totaltime ~= 0 then
active = "active "
local fuel_percent = math.floor(fuel_time / fuel_totaltime * 100)
fuel_state = fuel_percent .. "%"
formspec = default.furnace_active_formspec(fuel_percent, item_percent)
swap_node(pos, "default:furnace_active")
else
if not fuellist[1]:is_empty() then
fuel_state = "0%"
end
swap_node(pos, "default:furnace")
end
local infotext = "Furnace " .. active .. "(Item: " .. item_state .. "; Fuel: " .. fuel_state .. ")"
--
-- Set meta values
--
meta:set_float("fuel_totaltime", fuel_totaltime)
meta:set_float("fuel_time", fuel_time)
meta:set_float("src_time", src_time)
meta:set_string("formspec", formspec)
meta:set_string("infotext", infotext)
end,
})
default.log("furnace", "loaded")

Some files were not shown because too many files have changed in this diff Show More