Compare commits
10 Commits
f046558327
...
1b94dac777
Author | SHA1 | Date | |
---|---|---|---|
|
1b94dac777 | ||
|
be1cda9464 | ||
|
287d7798e2 | ||
|
72dc10d6b1 | ||
|
0c773c4684 | ||
|
f00f97d4ec | ||
|
78611b3ccd | ||
|
423b0f26a8 | ||
|
c6ef1d7589 | ||
|
e2b6b0f06b |
11
.github/workflows/build.yml
vendored
Normal file
11
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
on: [push, pull_request]
|
||||||
|
name: build
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: lint
|
||||||
|
uses: Roang-zero1/factorio-mod-luacheck@master
|
||||||
|
with:
|
||||||
|
luacheckrc_url: ""
|
15
.luacheckrc
Normal file
15
.luacheckrc
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
allow_defined_top = true
|
||||||
|
unused_args = false
|
||||||
|
max_line_length = false
|
||||||
|
|
||||||
|
read_globals = {
|
||||||
|
"mcl_sounds",
|
||||||
|
"ItemStack",
|
||||||
|
"vector",
|
||||||
|
"default",
|
||||||
|
"mcl_core"
|
||||||
|
}
|
||||||
|
|
||||||
|
globals = {
|
||||||
|
"minetest"
|
||||||
|
}
|
@ -8,7 +8,7 @@
|
|||||||
This mod adds a wooden trash can, and a dumpster to the game. Right click it, put in your trash, and click the empty trash button.
|
This mod adds a wooden trash can, and a dumpster to the game. Right click it, put in your trash, and click the empty trash button.
|
||||||
You can also throw things in the wooden trash can by pressing "q" or throwing them out of your inventory.
|
You can also throw things in the wooden trash can by pressing "q" or throwing them out of your inventory.
|
||||||
|
|
||||||
Version: 0.2.2
|
Version: 0.2.3
|
||||||
License: MIT (see LICENSE.txt)
|
License: MIT (see LICENSE.txt)
|
||||||
|
|
||||||
Dependencies:
|
Dependencies:
|
||||||
@ -46,4 +46,5 @@ Mossmanikin:
|
|||||||
Made the nodeboxes for the dumpster, the textures for the wooden trash can, and the texture for the dumpster node.
|
Made the nodeboxes for the dumpster, the textures for the wooden trash can, and the texture for the dumpster node.
|
||||||
(with some editing by me). (old)
|
(with some editing by me). (old)
|
||||||
|
|
||||||
|
Minerdudetest(Minertestdude on Github):
|
||||||
|
compatibility with MCL2
|
||||||
|
@ -1 +0,0 @@
|
|||||||
default
|
|
@ -1 +0,0 @@
|
|||||||
This mod adds a wooden trash can, and a dumpster to the game. Right click it, put in your trash, and click the empty trash button.
|
|
100
init.lua
100
init.lua
@ -1,3 +1,35 @@
|
|||||||
|
-- standard compatibility switcher block.
|
||||||
|
|
||||||
|
local moditems = {} -- switcher
|
||||||
|
local mineclone_path = minetest.get_modpath("mcl_core") and mcl_core
|
||||||
|
local S = minetest.get_translator("trash_can")
|
||||||
|
|
||||||
|
if mineclone_path then -- means MineClone 2 is loaded
|
||||||
|
moditems.iron_item = "mcl_core:iron_ingot" -- MCL version of iron ingot
|
||||||
|
moditems.coal_item = "mcl_core:coalblock" -- MCL version of coal block
|
||||||
|
moditems.green_dye = "mcl_dye:green" -- MCL version of green dye
|
||||||
|
moditems.sounds = mcl_sounds.node_sound_defaults
|
||||||
|
moditems.trashcan_infotext = nil
|
||||||
|
moditems.dumpster_infotext = nil
|
||||||
|
-- trying to imitate MCL boxart (no getter API)
|
||||||
|
moditems.boxart = "bgcolor[#d0d0d0;false]listcolors[#9d9d9d;#9d9d9d;#5c5c5c;#000000;#ffffff]"
|
||||||
|
moditems.trashbin_groups = {pickaxey=1,axey=1,handy=1,swordy=1,flammable=1,destroy_by_lava_flow=1,craftitem=1}
|
||||||
|
moditems.dumpster_groups = {pickaxey=1,axey=1,handy=1,swordy=1,flammable=0,destroy_by_lava_flow=0,craftitem=1}
|
||||||
|
moditems.slot_per_row = 9
|
||||||
|
else -- fallback, assume default (Minetest Game) is loaded
|
||||||
|
moditems.iron_item = "default:steel_ingot" -- MTG iron ingot
|
||||||
|
moditems.coal_item = "default:coalblock" -- MTG coal block
|
||||||
|
moditems.green_dye = "dye:dark_green" -- MTG version of green dye
|
||||||
|
moditems.sounds = default and default.node_sound_defaults
|
||||||
|
moditems.trashcan_infotext = S("Trash Can")
|
||||||
|
moditems.dumpster_infotext = S("Dumpster")
|
||||||
|
moditems.boxart = ""
|
||||||
|
moditems.trashbin_groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3}
|
||||||
|
moditems.dumpster_groups = {cracky=3,oddly_breakable_by_hand=1}
|
||||||
|
moditems.slot_per_row = 8
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Functions
|
-- Functions
|
||||||
--
|
--
|
||||||
@ -33,10 +65,9 @@ local function get_dumpster_sound()
|
|||||||
dig = {name="metal_bang", gain=0.6},
|
dig = {name="metal_bang", gain=0.6},
|
||||||
dug = {name="default_dug_node", gain=1.0}
|
dug = {name="default_dug_node", gain=1.0}
|
||||||
}
|
}
|
||||||
default.node_sound_defaults(sndtab)
|
moditems.sounds(sndtab)
|
||||||
return sndtab
|
return sndtab
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Nodeboxes
|
-- Nodeboxes
|
||||||
--
|
--
|
||||||
@ -69,7 +100,7 @@ local dumpster_nodebox = {
|
|||||||
|
|
||||||
-- Normal Trash Can
|
-- Normal Trash Can
|
||||||
minetest.register_node("trash_can:trash_can_wooden",{
|
minetest.register_node("trash_can:trash_can_wooden",{
|
||||||
description = "Wooden Trash Can",
|
description = S("Wooden Trash Can"),
|
||||||
drawtype="nodebox",
|
drawtype="nodebox",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -81,21 +112,21 @@ minetest.register_node("trash_can:trash_can_wooden",{
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = trash_can_nodebox
|
fixed = trash_can_nodebox
|
||||||
},
|
},
|
||||||
groups = {
|
groups = moditems.trashbin_groups,
|
||||||
snappy=1,
|
_mcl_blast_resistance = 5,
|
||||||
choppy=2,
|
_mcl_hardness = 1,
|
||||||
oddly_breakable_by_hand=2,
|
|
||||||
flammable=3
|
|
||||||
},
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
local offset = moditems.slot_per_row / 2 - 1
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec",
|
||||||
"size[8,9]" ..
|
"size["..moditems.slot_per_row..",9]" ..
|
||||||
"button[0,0;2,1;empty;Empty Trash]" ..
|
"button[0,0;2,1;empty;" .. S("Empty Trash") .. "]" ..
|
||||||
"list[context;trashlist;3,1;2,3;]" ..
|
"list[context;trashlist;"..offset..",1;2,3;]" ..
|
||||||
"list[current_player;main;0,5;8,4;]"
|
"list[current_player;main;0,5;"..moditems.slot_per_row..",4;]" ..
|
||||||
|
"listring[]" ..
|
||||||
|
moditems.boxart
|
||||||
)
|
)
|
||||||
meta:set_string("infotext", "Trash Can")
|
meta:set_string("infotext", moditems.trashcan_infotext)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("main", 8*4)
|
inv:set_size("main", 8*4)
|
||||||
inv:set_size("trashlist", 2*3)
|
inv:set_size("trashlist", 2*3)
|
||||||
@ -131,7 +162,7 @@ minetest.register_node("trash_can:trash_can_wooden",{
|
|||||||
|
|
||||||
-- Dumpster
|
-- Dumpster
|
||||||
minetest.register_node("trash_can:dumpster", {
|
minetest.register_node("trash_can:dumpster", {
|
||||||
description = "Dumpster",
|
description = S("Dumpster"),
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
inventory_image = "dumpster_wield.png",
|
inventory_image = "dumpster_wield.png",
|
||||||
@ -152,22 +183,22 @@ minetest.register_node("trash_can:dumpster", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = dumpster_nodebox,
|
fixed = dumpster_nodebox,
|
||||||
},
|
},
|
||||||
groups = {
|
_mcl_blast_resistance = 10,
|
||||||
cracky = 3,
|
_mcl_hardness = 3,
|
||||||
oddly_breakable_by_hand = 1,
|
groups = moditems.dumpster_groups,
|
||||||
},
|
|
||||||
|
|
||||||
sounds = get_dumpster_sound(),
|
sounds = get_dumpster_sound(),
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
local offset = moditems.slot_per_row / 2 - 3
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec",
|
||||||
"size[8,9]" ..
|
"size["..moditems.slot_per_row..",9]" ..
|
||||||
"button[0,0;2,1;empty;Empty Trash]" ..
|
"button[0,0;2,1;empty;" .. S("Empty Trash") .. "]" ..
|
||||||
"list[context;main;1,1;6,3;]" ..
|
"list[context;main;"..offset..",1;6,3;]" ..
|
||||||
"list[current_player;main;0,5;8,4;]"
|
"list[current_player;main;0,5;"..moditems.slot_per_row..",4;]"..
|
||||||
|
"listring[]" ..
|
||||||
|
moditems.boxart
|
||||||
)
|
)
|
||||||
meta:set_string("infotext", "Dumpster")
|
meta:set_string("infotext", moditems.dumpster_infotext)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("main", 8*4)
|
inv:set_size("main", 8*4)
|
||||||
end,
|
end,
|
||||||
@ -201,7 +232,7 @@ minetest.register_node("trash_can:dumpster", {
|
|||||||
inv:set_list("main", {})
|
inv:set_list("main", {})
|
||||||
minetest.sound_play("trash", {to_player=sender:get_player_name(), gain = 2.0})
|
minetest.sound_play("trash", {to_player=sender:get_player_name(), gain = 2.0})
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
--
|
--
|
||||||
@ -222,9 +253,9 @@ minetest.register_craft({
|
|||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = 'trash_can:dumpster',
|
output = 'trash_can:dumpster',
|
||||||
recipe = {
|
recipe = {
|
||||||
{'default:coalblock', 'default:coalblock', 'default:coalblock'},
|
{moditems.coal_item,moditems.coal_item,moditems.coal_item},
|
||||||
{'default:steel_ingot', 'dye:dark_green', 'default:steel_ingot'},
|
{moditems.iron_item,moditems.green_dye,moditems.iron_item},
|
||||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
{moditems.iron_item,moditems.iron_item,moditems.iron_item},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -235,10 +266,11 @@ minetest.register_craft({
|
|||||||
if trash_can_throw_in then
|
if trash_can_throw_in then
|
||||||
-- Remove any items thrown in trash can.
|
-- Remove any items thrown in trash can.
|
||||||
local old_on_step = minetest.registered_entities["__builtin:item"].on_step
|
local old_on_step = minetest.registered_entities["__builtin:item"].on_step
|
||||||
minetest.registered_entities["__builtin:item"].on_step = function(self, dtime)
|
minetest.registered_entities["__builtin:item"].on_step = function(self, dtime, ...)
|
||||||
local item_pos = self.object:getpos()
|
local item_pos = self.object:get_pos()
|
||||||
|
item_pos.y = item_pos.y - 0.325
|
||||||
|
item_pos = vector.round(item_pos)
|
||||||
-- Round the values. Not essential, but makes logging look nicer.
|
-- Round the values. Not essential, but makes logging look nicer.
|
||||||
for key, value in pairs(item_pos) do item_pos[key] = math.floor(value + 0.5) end
|
|
||||||
if minetest.get_node(item_pos).name == "trash_can:trash_can_wooden" then
|
if minetest.get_node(item_pos).name == "trash_can:trash_can_wooden" then
|
||||||
local item_stack = ItemStack(self.itemstring)
|
local item_stack = ItemStack(self.itemstring)
|
||||||
local inv = minetest.get_inventory({type="node", pos=item_pos})
|
local inv = minetest.get_inventory({type="node", pos=item_pos})
|
||||||
@ -256,6 +288,6 @@ if trash_can_throw_in then
|
|||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
old_on_step(self, dtime)
|
old_on_step(self, dtime, ...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
5
locale/template.txt
Normal file
5
locale/template.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: trash_can
|
||||||
|
Trash Can=
|
||||||
|
Dumpster=
|
||||||
|
Wooden Trash Can=
|
||||||
|
Empty Trash=
|
5
locale/trash_can.eo.tr
Normal file
5
locale/trash_can.eo.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: trash_can
|
||||||
|
Trash Can=Rubujo
|
||||||
|
Dumpster=Granda Rubujo
|
||||||
|
Wooden Trash Can=Ligna Rubujo
|
||||||
|
Empty Trash=Malpleni Rubon
|
5
locale/trash_can.fr.tr
Normal file
5
locale/trash_can.fr.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: trash_can
|
||||||
|
Trash Can=Poubelle
|
||||||
|
Dumpster=Containeur
|
||||||
|
Wooden Trash Can=Poubelle en bois
|
||||||
|
Empty Trash=Vider
|
5
locale/trash_can.zh_CN.tr
Normal file
5
locale/trash_can.zh_CN.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: trash_can
|
||||||
|
Trash Can=垃圾桶
|
||||||
|
Dumpster=大型垃圾桶
|
||||||
|
Wooden Trash Can=木制垃圾桶
|
||||||
|
Empty Trash=清空垃圾桶
|
5
locale/trash_can.zh_TW.tr
Normal file
5
locale/trash_can.zh_TW.tr
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# textdomain: trash_can
|
||||||
|
Trash Can=垃圾桶
|
||||||
|
Dumpster=大型垃圾桶
|
||||||
|
Wooden Trash Can=木製垃圾桶
|
||||||
|
Empty Trash=清空垃圾桶
|
2
mod.conf
2
mod.conf
@ -1 +1,3 @@
|
|||||||
name = trash_can
|
name = trash_can
|
||||||
|
description = This mod adds a wooden trash can, and a dumpster to the game. Right click it, put in your trash, and click the empty trash button.
|
||||||
|
optional_depends = default,mcl_core
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
# Requires some additional processing to check all items in the world each server step
|
# Requires some additional processing to check all items in the world each server step
|
||||||
trash_can_throw_in (Allow throwing trash into the trash can) bool true
|
trash_can_throw_in (Allow throwing trash into the trash can) bool false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user