Compare commits

...

10 Commits

Author SHA1 Message Date
1F616EMO~nya
1b94dac777
Add Simplified Chinese translation (#20)
Some checks failed
build / lint (push) Has been cancelled
2024-03-05 21:38:05 +01:00
Araca
be1cda9464
Adapt inventory to MineClone2/ia (#18)
Co-authored-by: Florent Delord <fdelord@synthesio.com>
2024-02-01 19:04:38 +01:00
David Leal
287d7798e2
Add LuaCheck (#17) 2023-07-28 21:05:38 +02:00
Montandalar
72dc10d6b1
Fix and improve throwing trash into the can (#16)
* The settingtypes default value was mismatched with the actual code.
  settingtypes have been changed to agree with the code because this
  keeps the old behaviour.
* builtin item's on_step has more arguments than self and dtime now, so
  the varargs syntax is used to pass additional arguments on now
  Without this, the mod will crash when trash_can_throw_in is on.
* I have tweaked the calculation for where the trash can will pick
  objects up, since it was too easy to land items on the rim instead of
  them going in.
* The calculation for where the trash can will pick objects up has been
  tweaked upwards, since it was too easy to land items on the rim instead
  of them going in.
* vector.round is now used to ensure the logging co-ordinates are
  accurate instead of floor, since this is the same basic algorithm
  minetest\.get_node uses.
2023-03-25 10:08:13 +01:00
jolesh
0c773c4684
Add Esperanto translation (#15) 2022-11-05 10:01:56 +01:00
Maksym H
f00f97d4ec
Don't error if default mod is not available (#14) 2022-10-29 21:38:10 +02:00
Emo"jigit
78611b3ccd
zh_TW Translations (#13) 2022-08-13 15:03:52 +02:00
tuedel
423b0f26a8
Use listrings for inventories (#12)
Enables moving itemstacks via shift-click for newly placed nodes.
2020-08-12 21:03:25 +02:00
minertestdude
c6ef1d7589
Add MineClone2 compatibility (#10) 2020-04-11 13:26:49 +02:00
David Leal
e2b6b0f06b
Update mod.conf (#6) 2020-02-02 13:45:35 +01:00
13 changed files with 123 additions and 39 deletions

11
.github/workflows/build.yml vendored Normal file
View 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
View 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"
}

View File

@ -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

View File

@ -1 +0,0 @@
default

View File

@ -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
View File

@ -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
View File

@ -0,0 +1,5 @@
# textdomain: trash_can
Trash Can=
Dumpster=
Wooden Trash Can=
Empty Trash=

5
locale/trash_can.eo.tr Normal file
View 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
View File

@ -0,0 +1,5 @@
# textdomain: trash_can
Trash Can=Poubelle
Dumpster=Containeur
Wooden Trash Can=Poubelle en bois
Empty Trash=Vider

View File

@ -0,0 +1,5 @@
# textdomain: trash_can
Trash Can=垃圾桶
Dumpster=大型垃圾桶
Wooden Trash Can=木制垃圾桶
Empty Trash=清空垃圾桶

View File

@ -0,0 +1,5 @@
# textdomain: trash_can
Trash Can=垃圾桶
Dumpster=大型垃圾桶
Wooden Trash Can=木製垃圾桶
Empty Trash=清空垃圾桶

View File

@ -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

View File

@ -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