From bbec900a9338e656924845bba4d28bbb9df0237c Mon Sep 17 00:00:00 2001 From: wsor <24964441+wsor4035@users.noreply.github.com> Date: Sat, 26 Jun 2021 23:12:18 -0400 Subject: [PATCH] WIP furnace --- mods/fl_ores/init.lua | 12 + mods/fl_wildlife/crafts.lua | 6 + mods/fl_wildlife/init.lua | 1 + mods/fl_wildlife/node_items.lua | 7 +- ...aked.png => farlands_cooked_riverfish.png} | Bin mods/fl_workshop/furnace.lua | 254 ++++++++++++++++++ .../textures/farlands_furnace_active.png | Bin 0 -> 1766 bytes .../textures/farlands_furnace_fire_bg.png | Bin 0 -> 177 bytes .../textures/farlands_furnace_fire_fg.png | Bin 0 -> 648 bytes .../textures/farlands_furnace_front.png | Bin 0 -> 986 bytes .../textures/farlands_furnace_front2.png | Bin 0 -> 935 bytes .../fl_workshop/textures/i3_furnace_trans.png | Bin 0 -> 1589 bytes 12 files changed, 279 insertions(+), 1 deletion(-) create mode 100644 mods/fl_wildlife/crafts.lua rename mods/fl_wildlife/textures/{mobs_riverfish_baked.png => farlands_cooked_riverfish.png} (100%) create mode 100644 mods/fl_workshop/furnace.lua create mode 100644 mods/fl_workshop/textures/farlands_furnace_active.png create mode 100644 mods/fl_workshop/textures/farlands_furnace_fire_bg.png create mode 100644 mods/fl_workshop/textures/farlands_furnace_fire_fg.png create mode 100644 mods/fl_workshop/textures/farlands_furnace_front.png create mode 100644 mods/fl_workshop/textures/farlands_furnace_front2.png create mode 100644 mods/fl_workshop/textures/i3_furnace_trans.png diff --git a/mods/fl_ores/init.lua b/mods/fl_ores/init.lua index ef99924..a03008c 100644 --- a/mods/fl_ores/init.lua +++ b/mods/fl_ores/init.lua @@ -63,4 +63,16 @@ minetest.register_craft({ {"fl_ores:diamond_ore", "fl_ores:diamond_ore", "fl_ores:diamond_ore"}, {"fl_ores:diamond_ore", "fl_ores:diamond_ore", "fl_ores:diamond_ore"}, } +}) + +minetest.register_craft({ + type = "fuel", + recipe = "fl_ores:coal_ore", + burntime = 41, +}) + +minetest.register_craft({ + type = "fuel", + recipe = "fl_ores:coal_block", + burntime = 370, }) \ No newline at end of file diff --git a/mods/fl_wildlife/crafts.lua b/mods/fl_wildlife/crafts.lua new file mode 100644 index 0000000..1771528 --- /dev/null +++ b/mods/fl_wildlife/crafts.lua @@ -0,0 +1,6 @@ +minetest.register_craft({ + type = "cooking", + output = "fl_wildlife:cooked_riverfish", + recipe = "fl_wildlife:raw_riverfish", + cooktime = 1, +}) \ No newline at end of file diff --git a/mods/fl_wildlife/init.lua b/mods/fl_wildlife/init.lua index 07d9603..aa5a940 100644 --- a/mods/fl_wildlife/init.lua +++ b/mods/fl_wildlife/init.lua @@ -14,6 +14,7 @@ local modpath = minetest.get_modpath(minetest.get_current_modname()) dofile(modpath .. "/api.lua") dofile(modpath .. "/node_items.lua") +dofile(modpath .. "/crafts.lua") local mob_brains = { "villager_brain", diff --git a/mods/fl_wildlife/node_items.lua b/mods/fl_wildlife/node_items.lua index ef82546..5370043 100644 --- a/mods/fl_wildlife/node_items.lua +++ b/mods/fl_wildlife/node_items.lua @@ -101,10 +101,15 @@ minetest.register_craftitem(":fl_bucket:milk", { }) minetest.register_craftitem("fl_wildlife:raw_riverfish", { - description = "riverfish item", + description = "raw riverfish", inventory_image = "farlands_raw_riverfish.png", }) +minetest.register_craftitem("fl_wildlife:cooked_riverfish", { + description = "cooked riverfish", + inventory_image = "farlands_cooked_riverfish.png", +}) + minetest.register_craftitem(":fl_bucket:riverfish", { description = "bucket of riverfish", inventory_image = "(farlands_bucket_water.png^[noalpha)^[brighten", diff --git a/mods/fl_wildlife/textures/mobs_riverfish_baked.png b/mods/fl_wildlife/textures/farlands_cooked_riverfish.png similarity index 100% rename from mods/fl_wildlife/textures/mobs_riverfish_baked.png rename to mods/fl_wildlife/textures/farlands_cooked_riverfish.png diff --git a/mods/fl_workshop/furnace.lua b/mods/fl_workshop/furnace.lua new file mode 100644 index 0000000..422c8ca --- /dev/null +++ b/mods/fl_workshop/furnace.lua @@ -0,0 +1,254 @@ +viewing_furnace = {} + +local function update_active(pos, pname, firep, arrowp) + + --vars for stuff + local clicker = minetest.get_player_by_name(pname) + local chName = "furnace" + local iPos = pos.x .. "," .. pos.y .. "," .. pos.z + local cInvSize = clicker:get_inventory():get_size("main") + local rLength = (cInvSize-9)/3 + local slotSize + local formSize + if rLength == 12 then slotSize, formSize = 0.725, "10.4,9.475" + elseif rLength == 11 then slotSize, formSize = 0.8, "10.4,9.7" + elseif rLength == 10 then slotSize, formSize = 0.89, "10.4,9.97" + else slotSize, formSize = 1, "10.4,10.3" end + + if minetest.get_meta(pos):get_string("description") ~= "" then + chName = minetest.get_meta(pos):get_string("description") + --minetest.get_meta(pos):set_string("infotext", minetest.get_meta(pos):get_string("description")) + end + + --header of formspec + local formspec = { + "formspec_version[4]", + "size[" .. formSize .. "]", + "no_prepend[]", + "style_type[box;colors=#77777710,#77777710,#777,#777]", + "style_type[list;size=1;spacing=0.1]", + "listcolors[#0000;#ffffff20]", + "bgcolor[black;neither]", + "background9[0,0;" .. formSize .. ";i3_bg_full.png;false;10]", + } + + local car = "(i3_arrow.png^[transformR90)" + local arrow_out = "(" .. car .. "^[lowpart:" .. arrowp .. ":(" .. car .. "^[brighten))^[transformR270" + + --build chest inventory + local furnace_layout = { + "label[0.3,0.4;" .. chName .. "]", + "box[2.7,0.7;1,1;]", + "list[nodemeta:" .. iPos .. ";input;2.7,0.7;1,1;]", + "image[2.7,2.2;1,1;farlands_furnace_fire_bg.png^[lowpart:" .. firep ..":farlands_furnace_fire_fg.png]", + "box[2.7,3.7;1,1;]", + "list[nodemeta:" .. iPos .. ";fuel;2.7,3.7;1,1;]", + "image[4.7,2.2;1,1;" .. arrow_out .. "]", + "box[6.7,2.2;1,1;]", + "list[nodemeta:" .. iPos .. ";output;6.7,2.2;1,1;]", + } + table.insert(formspec, table.concat(furnace_layout, "")) + + + --build inventory part of formspec + table.insert(formspec, "label[0.3,5.4;Inventory]") + table.insert(formspec, "style_type[box;colors=#77777710,#77777710,#777,#777]") + for i=0, 8 do + table.insert(formspec, "box[" .. 0.3+i+(i*0.1) ..",5.7;1,1;]") + end + table.insert(formspec, "list[current_player;main;0.3,5.7;9,1;]") + table.insert(formspec, "style_type[list;size=" .. slotSize .. ";spacing=0.1]") + table.insert(formspec, "style_type[box;colors=#666]") -- change bottom 3 rows color + for i=0, 2 do + for j=0, rLength-1 do + table.insert(formspec, "box[" .. 0.3+(j*0.1)+(j*slotSize) .."," .. 6.8+(i*0.1)+(i*slotSize) .. ";" + .. slotSize .. "," .. slotSize .. ";]") + end + table.insert(formspec, "list[current_player;main;0.3," .. 6.8+(i*0.1)+(i*slotSize) .. ";" + .. rLength .. ",1;" .. 9+(rLength*i) .. "]") + end + + --enable shiftclicking? + table.insert(formspec, "listring[nodemeta:" .. iPos .. ";main]") + table.insert(formspec, "listring[current_player;main]") + + --show formspec + local chest_formspec = table.concat(formspec, "") + minetest.show_formspec(clicker:get_player_name(), "fl_workshop:furnace_active_formspec", chest_formspec) +end + +local function furnace_nt(pos, elapsed) + --minetest.chat_send_all(elapsed) + --return true + --[[ + if viewing_furnace[minetest.hash_node_position(pos)] then + for _, pname in pairs(viewing_furnace[minetest.hash_node_position(pos)]) do + update_active(pos, pname, 40, 70) + end + end + --]] + + return false +end + + --if either or empty, do nothing + --if inv:is_empty("input") or inv:is_empty("fuel") then return false end + + --local Coutput, Creturn = minetest.get_craft_result({method = "cooking", width = 1, items = inv:get_list("input")}) + --local Foutput, Freturn = minetest.get_craft_result({method = "fuel", width = 1, items = inv:get_list("fuel")}) + + --not valid fuel or cookable item, do nothing + --if Coutput.time == 0 or Foutput.time == 0 then return false end + + --[[debug dumps + minetest.chat_send_all(dump(Coutput)) + minetest.chat_send_all(dump(Creturn)) + minetest.chat_send_all("break") + minetest.chat_send_all(dump(Foutput)) + minetest.chat_send_all(dump(Freturn)) + --]] + +minetest.register_node("fl_workshop:furnace", { + description = "furnace", + paramtype2 = "facedir", + on_construct = function(pos) + local inv = minetest.get_meta(pos):get_inventory() + inv:set_size("input", 1) + inv:set_size("fuel", 1) + inv:set_size("output", 1) + end, + tiles = { + "farlands_stone_block.png", + "farlands_stone_block.png", + "farlands_stone_block.png", + "farlands_stone_block.png", + "farlands_stone_block.png", + "farlands_furnace_front.png", + }, + groups = {oddly_breakable_by_hand = 3}, + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + + --vars for stuff + local chName = "furnace" + local iPos = pos.x .. "," .. pos.y .. "," .. pos.z + local cInvSize = clicker:get_inventory():get_size("main") + local rLength = (cInvSize-9)/3 + local slotSize + local formSize + if rLength == 12 then slotSize, formSize = 0.725, "10.4,9.475" + elseif rLength == 11 then slotSize, formSize = 0.8, "10.4,9.7" + elseif rLength == 10 then slotSize, formSize = 0.89, "10.4,9.97" + else slotSize, formSize = 1, "10.4,10.3" end + + if minetest.get_meta(pos):get_string("description") ~= "" then + chName = minetest.get_meta(pos):get_string("description") + --minetest.get_meta(pos):set_string("infotext", minetest.get_meta(pos):get_string("description")) + end + + --header of formspec + local formspec = { + "formspec_version[4]", + "size[" .. formSize .. "]", + "no_prepend[]", + "style_type[box;colors=#77777710,#77777710,#777,#777]", + "style_type[list;size=1;spacing=0.1]", + "listcolors[#0000;#ffffff20]", + "bgcolor[black;neither]", + "background9[0,0;" .. formSize .. ";i3_bg_full.png;false;10]", + } + + --build chest inventory + local furnace_layout = { + "label[0.3,0.4;" .. chName .. "]", + "box[2.7,0.7;1,1;]", + "list[nodemeta:" .. iPos .. ";input;2.7,0.7;1,1;]", + "image[2.7,2.2;1,1;farlands_furnace_fire_bg.png]", + "box[2.7,3.7;1,1;]", + "list[nodemeta:" .. iPos .. ";fuel;2.7,3.7;1,1;]", + "image[4.7,2.2;1,1;i3_arrow.png]", + "box[6.7,2.2;1,1;]", + "list[nodemeta:" .. iPos .. ";output;6.7,2.2;1,1;]", + } + table.insert(formspec, table.concat(furnace_layout, "")) + + + --build inventory part of formspec + table.insert(formspec, "label[0.3,5.4;Inventory]") + table.insert(formspec, "style_type[box;colors=#77777710,#77777710,#777,#777]") + for i=0, 8 do + table.insert(formspec, "box[" .. 0.3+i+(i*0.1) ..",5.7;1,1;]") + end + table.insert(formspec, "list[current_player;main;0.3,5.7;9,1;]") + table.insert(formspec, "style_type[list;size=" .. slotSize .. ";spacing=0.1]") + table.insert(formspec, "style_type[box;colors=#666]") -- change bottom 3 rows color + for i=0, 2 do + for j=0, rLength-1 do + table.insert(formspec, "box[" .. 0.3+(j*0.1)+(j*slotSize) .."," .. 6.8+(i*0.1)+(i*slotSize) .. ";" + .. slotSize .. "," .. slotSize .. ";]") + end + table.insert(formspec, "list[current_player;main;0.3," .. 6.8+(i*0.1)+(i*slotSize) .. ";" + .. rLength .. ",1;" .. 9+(rLength*i) .. "]") + end + + --enable shiftclicking? + table.insert(formspec, "listring[nodemeta:" .. iPos .. ";main]") + table.insert(formspec, "listring[current_player;main]") + + --show formspec + local chest_formspec = table.concat(formspec, "") + if viewing_furnace[minetest.hash_node_position(pos)] then + local vft = viewing_furnace[minetest.hash_node_position(pos)] + table.insert(vft, clicker:get_player_name()) + viewing_furnace[minetest.hash_node_position(pos)] = vft + else viewing_furnace[minetest.hash_node_position(pos)] = {clicker:get_player_name()} end + viewing_furnace[clicker:get_player_name()] = pos + minetest.show_formspec(clicker:get_player_name(), "fl_workshop:furnace_formspec", chest_formspec) + end, + on_metadata_inventory_put = function(pos) minetest.get_node_timer(pos):start(1.0) end, + on_metadata_inventory_take = function(pos) minetest.get_node_timer(pos):start(1.0) end, + on_metadata_inventory_move = function(pos) minetest.get_node_timer(pos):start(1.0) end, + on_timer = furnace_nt, +}) + +minetest.register_node("fl_workshop:furnace_active", { + description = "furnace", + paramtype2 = "facedir", + --this will be used because furnace is swaped to furnace_active + on_timer = furnace_nt, + tiles = { + "farlands_stone_block.png", + "farlands_stone_block.png", + "farlands_stone_block.png", + "farlands_stone_block.png", + "farlands_stone_block.png", + { + image = "farlands_furnace_active.png", + backface_culling = false, + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 1.5 + }, + } + }, + groups = {oddly_breakable_by_hand = 3}, +}) + +minetest.register_on_player_receive_fields(function(player, formname, fields) + if formname ~= "fl_workshop:furnace_formspec" and formname ~= "fl_workshop:furnace_active_formspec" then return end + if fields.quit == "true" then + local ref = viewing_furnace[minetest.hash_node_position(viewing_furnace[player:get_player_name()])] + for i, name in pairs(ref) do + if name == player:get_player_name() then + table.remove(ref, i) + if #ref == 0 then + --minetest.chat_send_all("test") + viewing_furnace[minetest.hash_node_position(viewing_furnace[player:get_player_name()])] = nil + end + end + end + viewing_furnace[player:get_player_name()] = nil + return + end +end) \ No newline at end of file diff --git a/mods/fl_workshop/textures/farlands_furnace_active.png b/mods/fl_workshop/textures/farlands_furnace_active.png new file mode 100644 index 0000000000000000000000000000000000000000..7f4d08d001abec51467651c618fcf29dd341b0a3 GIT binary patch literal 1766 zcmV>}EF+lDO<9h}a4?7J`Ln zUF>B_5Z# zT56}vE*uiXi4jJl%p!S8^h+&DW`FylU%n}p#G}jKVg*|qS#sj-6SXW|4XLK+hJ1Ne zRPMj?bj+bauX`{CwGXcQ(hc=nP}y|dj|11O975n8&Wct4lH@e5NH@I z@$HcS000SaNLh0L01sgR01sgSs6VG^000FYNklcUdzNF&djd(WABukZQpIp0L4jvQ$|m3dNbY;1^0VrWQj zx5{NnjiluEtvgb$Z>x^ar5h!^UtTRqY+ItTxw$Dc+Lzj=4b@83cgW5oqob;CHtK3T znR`~saDKPilvt&_C0p@`#0TTDzOp9C+Nw0Gbs6@CGmspRX0ar-&6;XPo_Dt0q~8`oUq<+lz?HSvVnP@Kopd!@eJP~)FqOpk**F2{Rj z8~Y4zt%(!WcZ;)Lye*G;bEhH^#W3M~Pm8ODHjX9|kNWEs8yrgLf^p6?%HZ`??~OJE zcd%&3wNVj?MIBlHZ$)*wh?TNP5zTLZ@tN6l{GIu2QR&xQQuPF2Xpw-c%@9^}w*7O|h7$+_VSJYYCeM=a=y2On|1mpmMxG2|q$;3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# zT56}vE*uiXi4jJl%p!S8^h+&DW`FylU%n}p#G}jKVg*|qS#sj-6SXW|4XLK+hJ1Ne zRPMj?bj+bauX`{CwGXcQ(hc=nP}y|dj|11O975n8&Wct4lH@e5NH@I z@$HcS000SaNLh0L01FcU01FcV0GgZ_0005rNkl(;2dT!MC3~pX6@w69HL7b z!6e{FrTzwgdOh}utC2%w8BAd~1AN~9nvL>5=TkfG(0I-qGVyG+2ssUz{AB@|2!tuP z=MXB_h8SJmU}ZMDRj<#jPLG69bT!+TSjrp!Tz~*8rDU0pjbdp5O%)jZ9q_Z#-f2fE z@criNg&h#!`(YPS5hxltXqHulX_|bZpFhqxL8H|~_t)<%nHtZVn=Ork&DKlqpt0Ue zu0T2<(a>_phMj(P#w^R-Lvtgq1{sDp?VcnF$jXY1y>AD&9*^gaLA&_4y@krgJM_=` z5J9ZEnpI<=5ZRaE+>bDXB{7AuytR0EoE~>!#C3_h$WlyUxyVq_SZ`&VV!?zSpJ?7k z7&1~K?M~1fX%f%%7BzqrGq#gmX-CIBbUH_PYbDx#su71ocn@$z;LB=#JCpzb002ov JPDHLkV1kJxtO@`C literal 0 HcmV?d00001 diff --git a/mods/fl_workshop/textures/i3_furnace_trans.png b/mods/fl_workshop/textures/i3_furnace_trans.png new file mode 100644 index 0000000000000000000000000000000000000000..6de48f9a6ac55bf948bfebdf432595141b561f70 GIT binary patch literal 1589 zcmV-52Fm$~P)>}EF+lDO<9h}a4?7J`Ln zUF>B_5Z# zT56}vE*uiXi4jJl%p!S8^h+&DW`FylU%n}p#G}jKVg*|qS#sj-6SXW|4XLK+hJ1Ne zRPMj?bj+bauX`{CwGXcQ(hc=nP}y|dj|11O975n8&Wct4lH@e5NH@I z@$HcS000SaNLh0L01FZT01FZU(%pXi000DRNkl?di8k7Z+xS3U zj^B4@&TwaD*2_2+u%C^3Lz1^9econ%Lx^T@!sAD@x9#1#; z18=8ijK|tgPkPrJqYj#5Y6E$1=ma08m=j+thh@8Om zYu=1H0I_NH=-*dGQdPVsw?4b(q_Xx+!o=rcFN5=;k{IJvbCMK z;B%gX(d6TT+-$)`HtinKT2H$2@QWXCz-Qk!<|-S*3vhs0c|QNubsla32R|`N<&k!G zcGKttvboo38PAJQ$8M>POP3uDs11xvKZ^TnI)%nfyRwe)4(R;KBkTlQQDMj_@G=MI`TJ zWE^0Uhm$clD~1P={D63{2*cdBg1nz7NNzr3KI@AB72-wN{9q8b+LTz5msmnuj|(b) zfe%eF9>n!RC>Zv6y-+SU;CR{mK$oof!JVDt2Z6Xpl1(QJCL0s%Jq>)`8Sjky93nEO zvm(jp6-1;r7DlHC9x&dGv7H}4wgyL);{g(h&kme?TyZCa@lYtai1ULuKiJ235atPr zaS0{yfEf=t0-G}+hroJSjiQH)v)LR1Ss4Yq(&1QMMAhcGuGat+4h7L-?v^Mklv*vIukC0I}~f1sR!<_C5V zmBa(Z0&)h%7#xCPfsWbEBL5eN1jsg#2?Ub n2uRe=pA>8!hrpbn7#{os(EID!LM;2%00000NkvXXu0mjfGW_ID literal 0 HcmV?d00001