a lot of dev stuff here
This commit is contained in:
parent
ce0547e1f5
commit
eeb3a8fa1b
@ -45,7 +45,7 @@ Nugget blocks can be melted by placing them beside a block of burning charcoal,
|
||||
|
||||
|
||||
## Starting fires
|
||||
This is a fairly simple task, find some an iron nugget and some flint. When you have found some flint, take it and put it right next to the node you want to light. After doing this you start to beat the flint with the iron nugget. This should produce a lot of sparks and the fire should ignite after a few attempts. It can take a while sometimes so don't give up to quickly. Some things like wood burn to charcoal, this can be used to melt metals.
|
||||
This is a fairly simple task, find some iron nuggets and some flint. When you have found some flint, take it and put it right next to the node you want to light. After doing this you start to beat (`aux1`) the flint with the iron nugget. This should produce a lot of sparks and the fire should ignite after a few attempts. It can take a while sometimes so don't give up to quickly. Some things like wood burn to charcoal, this can be used to melt metals.
|
||||
|
||||
|
||||
## Tools
|
||||
|
@ -35,13 +35,14 @@ We strive to maintain a simple base texturepack for the game.
|
||||
### Weather
|
||||
|
||||
- Make weather have affects on the enviorment, like hail damage the player, and rain put out fires.
|
||||
- Add feature where transitions between weathers is clean.
|
||||
|
||||
|
||||
### Mapgen
|
||||
|
||||
- Improve cave generation
|
||||
- Make treasures spawn
|
||||
- Move mapgen to no-longer use a single mapgen file.
|
||||
- Make treasures spawn. Done
|
||||
- Move mapgen to no-longer use a single mapgen file. Done
|
||||
|
||||
|
||||
### UI
|
||||
|
@ -94,9 +94,11 @@ end
|
||||
local path = core.get_modpath("1042_core")
|
||||
|
||||
dofile(path.."/src/funcs.lua")
|
||||
dofile(path.."/src/invs.lua")
|
||||
dofile(path.."/src/player_inv.lua")
|
||||
dofile(path.."/src/player.lua")
|
||||
dofile(path.."/src/privs.lua")
|
||||
dofile(path.."/src/achievements.lua")
|
||||
dofile(path.."/src/chat_commands.lua")
|
||||
dofile(path.."/src/node_wear.lua")
|
||||
|
||||
|
137
mods/1042_core/src/invs.lua
Normal file
137
mods/1042_core/src/invs.lua
Normal file
@ -0,0 +1,137 @@
|
||||
|
||||
core_1042.all_registered_items = {}
|
||||
|
||||
|
||||
|
||||
|
||||
-- Trash
|
||||
core_1042.void_inv = core.create_detached_inventory("void",
|
||||
{
|
||||
allow_move = function() return 0 end,
|
||||
allow_put = function() return -1 end,
|
||||
allow_take = function() return 0 end,
|
||||
})
|
||||
core_1042.void_inv:set_size("main", 1)
|
||||
|
||||
|
||||
|
||||
-- Creative inv
|
||||
core_1042.creative_inv = core.create_detached_inventory("creative",
|
||||
{
|
||||
allow_move = function() return 0 end,
|
||||
allow_put = function() return 0 end,
|
||||
allow_take = function() return -1 end,
|
||||
})
|
||||
|
||||
|
||||
-- Generate the inv
|
||||
core.register_on_mods_loaded(function()
|
||||
local size = 0
|
||||
local lists = {core.registered_nodes, core.registered_items, core.registered_tools, core.registered_craftitems}
|
||||
|
||||
local added = {}
|
||||
local items_to_reg = {}
|
||||
|
||||
for _, list in ipairs(lists) do
|
||||
for name, def in pairs(list) do
|
||||
if not added[name] then
|
||||
added[name] = true
|
||||
core_1042.all_registered_items[#core_1042.all_registered_items+1] = def -- Add to global refs list
|
||||
if not def.groups.not_in_creative_inventory then
|
||||
size = size + 1
|
||||
items_to_reg[#items_to_reg+1] = def -- Add to local for creative
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
table.sort(items_to_reg, function(a, b)
|
||||
return a.name > b.name
|
||||
end)
|
||||
|
||||
table.sort(core_1042.all_registered_items, function(a, b)
|
||||
return a.name > b.name
|
||||
end)
|
||||
|
||||
core_1042.creative_inv:set_size("main", size)
|
||||
for i, def in ipairs(items_to_reg) do
|
||||
local is = ItemStack(def.name)
|
||||
is:set_count(def.stack_max)
|
||||
core_1042.creative_inv:set_stack("main", i, is)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
|
||||
-- #fixme needs finished
|
||||
|
||||
function core_1042.update_player_crafts(player)
|
||||
local inv = player:get_inventory()
|
||||
local craft_inv = core.get_inventory({type="detached", name=player:get_player_name() .. "_crafts"})
|
||||
|
||||
local table_of_crafts = {}
|
||||
|
||||
for _, def in ipairs(core_1042.all_registered_items) do
|
||||
if def.name and def.name ~= "" then
|
||||
local recipe = core.get_craft_recipe(def.name)
|
||||
|
||||
if recipe and recipe.method == "normal" then
|
||||
local req_items = {}
|
||||
for _, v in ipairs(recipe.items) do
|
||||
req_items[#req_items+1] = v
|
||||
end
|
||||
|
||||
table_of_crafts[#table_of_crafts+1] = {recipe = recipe, output = core.get_craft_result(recipe), req_items = req_items}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
craft_inv:set_size("main", #table_of_crafts)
|
||||
|
||||
for i, craft in ipairs(table_of_crafts) do
|
||||
-- Add craft req thing here
|
||||
craft.output.item:get_meta():set_string("items_needed_to_craft", core.serialize(craft.req_items))
|
||||
craft_inv:set_stack("main", i, craft.output.item)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- Triggers to update
|
||||
core.register_on_player_inventory_action(function(player, action, inventory, inventory_info)
|
||||
if ((action == "put" or action == "take") and inventory_info.listname == "main") or action == "move" then
|
||||
core_1042.update_player_crafts(player)
|
||||
end
|
||||
end)
|
||||
core.register_on_item_pickup(function(_, player)
|
||||
core_1042.update_player_crafts(player)
|
||||
end)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
core.register_on_joinplayer(function(player)
|
||||
local inv = player:get_inventory()
|
||||
inv:set_size("main", 40)
|
||||
|
||||
local craft_inv = core.create_detached_inventory(player:get_player_name() .. "_crafts", {
|
||||
allow_move = function() return 0 end,
|
||||
allow_put = function() return 0 end,
|
||||
allow_take = function(inv, listname, index, stack, player)
|
||||
local inv = player:get_inventory()
|
||||
local items_needed_to_craft = core.deserialize(stack:get_meta():get_string("items_needed_to_craft") or {})
|
||||
|
||||
-- take from inv
|
||||
|
||||
return 0
|
||||
end,
|
||||
-- Add part that does take items from inv when crafting
|
||||
})
|
||||
|
||||
craft_inv:set_size("main", 0)
|
||||
|
||||
core_1042.update_player_crafts(player)
|
||||
end)
|
49
mods/1042_core/src/node_wear.lua
Normal file
49
mods/1042_core/src/node_wear.lua
Normal file
@ -0,0 +1,49 @@
|
||||
item_wear = {}
|
||||
|
||||
function item_wear.set_uses(itemstack, uses)
|
||||
itemstack:get_meta():set_int("item_uses", uses)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function item_wear.register_complex_node(name, def)
|
||||
def._item_wear_old_after_use = def.after_use
|
||||
def._item_wear_uses = def.uses
|
||||
def.uses = nil
|
||||
|
||||
def.after_use = function(itemstack, user, node, digparams)
|
||||
local meta = itemstack:get_meta()
|
||||
local uses = meta:get_int("item_uses")
|
||||
local def = core.registered_items[itemstack:get_name()] or {}
|
||||
|
||||
if uses == 0 then
|
||||
uses = (core.registered_items[itemstack:get_name()] or {})._item_wear_uses or 0
|
||||
else
|
||||
-- Add check for use type
|
||||
uses = uses - 1
|
||||
-- set color here
|
||||
end
|
||||
|
||||
|
||||
if uses == 0 then
|
||||
if def.sounds and def.sounds.breaks then
|
||||
if user and user:is_player() then
|
||||
core.sound_play(def.sounds.breaks, {gain = 1.0, pitch = 1.0, loop = false, to_player = user:get_player_name()}, true)
|
||||
end
|
||||
end
|
||||
|
||||
itemstack:take_item(1)
|
||||
return itemstack
|
||||
else
|
||||
meta:set_int("item_uses", uses)
|
||||
end
|
||||
|
||||
if def._item_wear_old_after_use then
|
||||
return def._item_wear_old_after_use(itemstack, user, node, digparams)
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end
|
||||
|
||||
core.register_node(name, def)
|
||||
end
|
@ -8,7 +8,7 @@ local aux1_cooldown = {}
|
||||
|
||||
|
||||
core.override_item("", {
|
||||
wield_image = "[combine:2x4:0,0=1042_plain_node.png\\^[colorize\\:#ffffff\\:0:0,2=1042_plain_node.png\\^[transformR90\\^[colorize\\:#aa8877\\:144",
|
||||
wield_image = "[combine:2x4:0,0=1042_plain_node.png\\^[colorize\\:#ffffff\\:0:0,2=1042_plain_node.png\\^[transformR90\\^[colorize\\:#aa8877\\:168",
|
||||
wield_scale = {x = 0.35, y = 4, z = 4},
|
||||
|
||||
range = 4.0,
|
||||
@ -111,7 +111,7 @@ core.register_on_joinplayer(function(player, last_join)
|
||||
{
|
||||
minimap = false,
|
||||
minimap_radar = false,
|
||||
crosshair = false,
|
||||
crosshair = false, -- We use custom one
|
||||
basic_debug = false,
|
||||
hotbar = false -- We use custom one
|
||||
}
|
||||
@ -266,7 +266,7 @@ core.register_globalstep(function(dtime)
|
||||
local name = player:get_player_name()
|
||||
local pointed_thing = core_1042.get_pointed_thing(player)
|
||||
|
||||
if aux1_cooldown[name] > 0 then
|
||||
if aux1_cooldown[name] and aux1_cooldown[name] > 0 then
|
||||
aux1_cooldown[name] = aux1_cooldown[name] - dtime
|
||||
end
|
||||
|
||||
@ -288,7 +288,7 @@ core.register_globalstep(function(dtime)
|
||||
local itemstack = player:get_wielded_item()
|
||||
local def = core.registered_items[itemstack:get_name()]
|
||||
|
||||
if def._1042_on_use and aux1_cooldown[name] <= 0 then
|
||||
if def._1042_on_use and aux1_cooldown[name] and aux1_cooldown[name] <= 0 then
|
||||
local ret_itemstack = def._1042_on_use(itemstack, player, pointed_thing)
|
||||
if ret_itemstack then
|
||||
player:set_wielded_item(ret_itemstack)
|
||||
@ -302,7 +302,7 @@ core.register_globalstep(function(dtime)
|
||||
|
||||
-- Hud code
|
||||
|
||||
local player_huds = player_huds[name]
|
||||
local player_huds = player_huds[name] or {}
|
||||
|
||||
-- Pointed Item
|
||||
local id = player_huds.pointed_thing
|
||||
|
@ -1,64 +1,6 @@
|
||||
-- Inv
|
||||
|
||||
local inv_row_count = 0
|
||||
|
||||
core.register_on_mods_loaded(function()
|
||||
local inv = core.create_detached_inventory("creative",
|
||||
{
|
||||
allow_move = function() return 0 end,
|
||||
allow_put = function() return 0 end,
|
||||
allow_take = function() return -1 end,
|
||||
})
|
||||
|
||||
local size = 0
|
||||
|
||||
local lists = {core.registered_nodes, core.registered_items, core.registered_tools, core.registered_craftitems}
|
||||
|
||||
local added = {}
|
||||
local items_to_reg = {}
|
||||
|
||||
for _, list in ipairs(lists) do
|
||||
for name, def in pairs(list) do
|
||||
if not added[name] then
|
||||
added[name] = true
|
||||
if not def.groups.not_in_creative_inventory then
|
||||
size = size + 1
|
||||
items_to_reg[#items_to_reg+1] = def
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
table.sort(items_to_reg, function(a, b)
|
||||
return a.name > b.name
|
||||
end)
|
||||
|
||||
inv:set_size("main", size)
|
||||
for i, def in ipairs(items_to_reg) do
|
||||
local is = ItemStack(def.name)
|
||||
is:set_count(def.stack_max)
|
||||
inv:set_stack("main", i, is)
|
||||
end
|
||||
|
||||
|
||||
inv_row_count = (size / 8)
|
||||
if size % 8 > 0 then
|
||||
inv_row_count = inv_row_count + 1
|
||||
end
|
||||
|
||||
-- Void
|
||||
|
||||
local void = core.create_detached_inventory("void",
|
||||
{
|
||||
allow_move = function() return 0 end,
|
||||
allow_put = function() return -1 end,
|
||||
allow_take = function() return 0 end,
|
||||
})
|
||||
|
||||
void:set_size("main", 1)
|
||||
|
||||
|
||||
end)
|
||||
|
||||
-- Load gameplay.md
|
||||
local fn = core_1042.info.path .. "/docs/gameplay.md"
|
||||
@ -94,6 +36,9 @@ end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function core_1042.make_inv_formspec(player)
|
||||
local greyscale = core_1042.get("playersetting_"..player:get_player_name().."_greyscale") or "false"
|
||||
local hud_at_bottom = core_1042.get("playersetting_"..player:get_player_name().."_hud_at_bottom") or "false"
|
||||
@ -105,15 +50,18 @@ function core_1042.make_inv_formspec(player)
|
||||
position = "0.5,0.48"
|
||||
end
|
||||
|
||||
local craft_count = core.get_inventory({type="detached", name=player:get_player_name() .. "_crafts"}):get_size("main")
|
||||
|
||||
local inv_formspec =
|
||||
"formspec_version[8]size[32,17,false]position["..position.."]"..
|
||||
"formspec_version[8]size[32,17.5,false]position["..position.."]style_type[*;sound=stone_dig]"..
|
||||
"scrollbaroptions[arrows=hide]"..
|
||||
"listcolors[#00ffff40;#00ffff80;#00aaaaff;#00444480;#00ffffff]"..
|
||||
"bgcolor[#00223320;;]"..
|
||||
|
||||
"model[13,-2.2;4,4;logo;1042.obj;1042_plain_node.png^[colorize:#672307:168;0,90;true;true;;]"..
|
||||
"set_focus[leave_game;true]"..
|
||||
"image_button[29,0.3;2.7,1;1042_plain_node.png^[colorize:#ff2200:144;leave_game;Leave Game]"..
|
||||
|
||||
"model[13,-2.2;4,4;logo;1042.obj;1042_plain_node.png^[colorize:#672307:168;0,90;true;true;;]"..
|
||||
|
||||
"label[1.5,1.5;Settings]"..
|
||||
"scroll_container[2,2;28,4;setting_box_scrollbar;vertical;0.1;true]"..
|
||||
|
||||
@ -137,30 +85,34 @@ function core_1042.make_inv_formspec(player)
|
||||
"image_button[11,8;2,1;1042_plain_node.png^[colorize:#448888:144;credits_txt;credits.txt]"..
|
||||
|
||||
"list[current_player;main;1,11;10,4;]"..
|
||||
"listring[current_player;main]"..
|
||||
"listring[current_player;craft]"..
|
||||
"listring[current_player;main]"..
|
||||
|
||||
"list[detached:void;main;18.5,14;1,1;]"..
|
||||
"image[18.9,14.4;0.25,0.25;1042_plain_node.png^[colorize:#ff2200:144]"..
|
||||
"listring[current_player;main]"
|
||||
|
||||
"list[current_player;craft;14.5,11.5;3,3;]"..
|
||||
"list[current_player;craftpreview;18.5,11.5;1,1;]"..
|
||||
"image[18.9,11.9;0.25,0.25;1042_plain_node.png^[colorize:#22ff00:144]"
|
||||
if craft_count > 0 then
|
||||
inv_formspec = inv_formspec..
|
||||
"scroll_container[15,11;10,5;craft;vertical;0.1;true]"..
|
||||
"list[detached:" .. player:get_player_name() .. "_crafts;main;0,0;4," .. craft_count / 4 + ((craft_count % 4 > 0) and 1 or 0) .. ";]"..
|
||||
"scroll_container_end[]"..
|
||||
"scrollbar[14.3,11;0.5,5;vertical;craft;0]"
|
||||
end
|
||||
|
||||
inv_formspec = inv_formspec..
|
||||
"list[detached:void;main;1,16;1,1;]"..
|
||||
"image[1.4,16.4;0.25,0.25;1042_plain_node.png^[colorize:#ff2200:144]"
|
||||
|
||||
|
||||
if show_creative and hide_creative_inv ~= "true" then
|
||||
inv_formspec = inv_formspec ..
|
||||
"scroll_container[21,11;10,5;creative_inv;vertical;0.1;true]"..
|
||||
local size = core_1042.creative_inv:get_size("main")
|
||||
|
||||
"list[detached:creative;main;0.1,0.1;8," .. inv_row_count .. ";]"..
|
||||
inv_formspec = inv_formspec ..
|
||||
"scroll_container[21,11;10,5;creative_inv;vertical;0.1;true]"..
|
||||
"list[detached:creative;main;0.1,0.1;8," .. (size / 8) + ((size % 8 > 0) and 1 or 0) .. ";]"..
|
||||
"listring[detached:creative;main]"..
|
||||
"lstring[current_player;main]"..
|
||||
|
||||
"scroll_container_end[]"..
|
||||
"scrollbar[20.3,11;0.5,5;vertical;creative_inv;0]"
|
||||
"scroll_container_end[]"..
|
||||
"scrollbar[20.3,11;0.5,5;vertical;creative_inv;0]"
|
||||
end
|
||||
|
||||
|
||||
return inv_formspec
|
||||
end
|
||||
|
||||
@ -226,10 +178,10 @@ end)
|
||||
|
||||
|
||||
|
||||
core.register_on_joinplayer(function(player)
|
||||
local inv = player:get_inventory()
|
||||
inv:set_size("main", 40)
|
||||
inv:set_size("craft", 9)
|
||||
|
||||
|
||||
|
||||
|
||||
core.register_on_joinplayer(function(player)
|
||||
player:set_inventory_formspec(core_1042.make_inv_formspec(player))
|
||||
end)
|
@ -1,12 +1,9 @@
|
||||
core.register_alias("mapgen_stone", "1042_nodes:stone")
|
||||
core.register_alias("mapgen_water_source", "1042_nodes:water_source")
|
||||
|
||||
|
||||
-- API
|
||||
dofile(core.get_modpath("1042_mapgen") .. "/mapgen_api.lua")
|
||||
|
||||
-- Mapgen thread
|
||||
core.register_mapgen_script(core.get_modpath("1042_mapgen") .. "/mapgen.lua")
|
||||
|
||||
core.register_alias("mapgen_stone", "air")
|
||||
core.register_alias("mapgen_water_source", "air")
|
||||
core.register_alias("mapgen_river_water_source", "air")
|
||||
|
||||
core.register_on_generated(function(minp, maxp, seed)
|
||||
core.fix_light(minp, maxp)
|
||||
end)
|
||||
|
@ -32,7 +32,7 @@ local treasure_y = mapgen_1042.water_level - 10
|
||||
-- Mapgen
|
||||
|
||||
|
||||
local stone = core.get_content_id("1042_nodes:stone")
|
||||
local stone = core.get_content_id("mapgen_stone")
|
||||
local dirt = core.get_content_id("1042_nodes:dirt")
|
||||
local sand = core.get_content_id("1042_nodes:sand")
|
||||
local turf = core.get_content_id("1042_nodes:turf")
|
||||
@ -42,7 +42,7 @@ local bedrock = core.get_content_id("1042_nodes:bedrock")
|
||||
local lava = core.get_content_id("1042_nodes:lava_source")
|
||||
local iron_ore = core.get_content_id("1042_nodes:iron_ore")
|
||||
|
||||
local water = core.get_content_id("1042_nodes:water_source")
|
||||
local water = core.get_content_id("mapgen_water_source")
|
||||
local ice = core.get_content_id("1042_nodes:ice")
|
||||
|
||||
local rock = core.get_content_id("1042_nodes:rock")
|
||||
|
@ -21,7 +21,7 @@ mapgen_1042.map_single = PerlinNoise(map_noise_params)
|
||||
mapgen_1042.cave_map = PerlinNoiseMap({
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x = 50, y = 20, z = 50},
|
||||
spread = {x = 50, y = 30, z = 50},
|
||||
seed = core.get_mapgen_setting("seed") + 34634,
|
||||
octaves = 3,
|
||||
persist = 0.7,
|
||||
|
@ -487,7 +487,7 @@ core.register_node("1042_nodes:chest", {
|
||||
})
|
||||
|
||||
core.register_craft({
|
||||
output = "1042_nodes:chest",
|
||||
output = "1042_nodes:chest 2",
|
||||
recipe = {
|
||||
{"group:wood", "group:wood", "group:wood"},
|
||||
{"group:wood", "", "group:wood"},
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
core.register_node("1042_tools:sword",{
|
||||
item_wear.register_complex_node("1042_tools:sword",{
|
||||
description = "Sword",
|
||||
drawtype = "mesh",
|
||||
mesh = "sword.obj",
|
||||
@ -36,9 +36,7 @@ core.register_node("1042_tools:sword",{
|
||||
},
|
||||
wield_scale = {x = 1.5, y = 2, z = 1.5},
|
||||
|
||||
after_use = function(itemstack, user, pointed_thing)
|
||||
-- Add dmg
|
||||
end,
|
||||
uses = 150,
|
||||
|
||||
damage_per_second = 128,
|
||||
|
||||
@ -57,7 +55,7 @@ core.register_craft({
|
||||
|
||||
|
||||
|
||||
core.register_node("1042_tools:pick",{
|
||||
item_wear.register_complex_node("1042_tools:pick",{
|
||||
description = "Pick",
|
||||
drawtype = "mesh",
|
||||
mesh = "pick.obj",
|
||||
@ -84,9 +82,7 @@ core.register_node("1042_tools:pick",{
|
||||
},
|
||||
wield_scale = {x = 1.5, y = 2, z = 1.5},
|
||||
|
||||
after_use = function(itemstack, user, pointed_thing)
|
||||
-- Add dmg
|
||||
end,
|
||||
uses = 10,
|
||||
|
||||
damage_per_second = 128,
|
||||
|
||||
@ -106,7 +102,7 @@ core.register_craft({
|
||||
|
||||
|
||||
|
||||
core.register_node("1042_tools:axe_flint",{
|
||||
item_wear.register_complex_node("1042_tools:axe_flint",{
|
||||
description = "Flint axe",
|
||||
drawtype = "mesh",
|
||||
mesh = "axe.obj",
|
||||
@ -132,9 +128,7 @@ core.register_node("1042_tools:axe_flint",{
|
||||
},
|
||||
wield_scale = {x = 1.5, y = 2, z = 1.5},
|
||||
|
||||
after_use = function(itemstack, user, pointed_thing)
|
||||
-- Add dmg
|
||||
end,
|
||||
uses = 25,
|
||||
|
||||
damage_per_second = 128,
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 144 B |
Loading…
x
Reference in New Issue
Block a user