~gpcf/advtrains

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] Automatically group wagons and locomotives based on "is_locomotive" definition

Details
Message ID
<20210817152011.20801-1-git.maverick2797@gmail.com>
DKIM signature
missing
Download raw message
Patch: +7 -2
---
 advtrains/wagons.lua | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index 4093f06..6296e33 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -1316,14 +1316,19 @@ function advtrains.register_wagon(sysname_p, prototype, desc, inv_img, nincreati
	minetest.register_entity(":"..sysname,prototype)
	advtrains.wagon_prototypes[sysname] = prototype
	
	--group classification to make recipe searching easier
	local wagon_loco = prototype.is_locomotive and "at_loco" or "at_wagon"
	local wagon_groups = { not_in_creative_inventory = nincreative and 1 or 0}
	wagon_groups[wagon_loco] = 1

	minetest.register_craftitem(":"..sysname, {
		description = desc,
		inventory_image = inv_img,
		wield_image = inv_img,
		stack_max = 1,
		
		groups = { not_in_creative_inventory = nincreative and 1 or 0},
		
		groups = wagon_groups,

		on_place = function(itemstack, placer, pointed_thing)
				if not pointed_thing.type == "node" then
					return
-- 
2.31.1

[PATCH] Automatically group wagons and locomotives based on definition values

Details
Message ID
<20210818101041.20144-1-git.maverick2797@gmail.com>
In-Reply-To
<20210817152011.20801-1-git.maverick2797@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Patch: +11 -2
Based on the advtrains wiki groups:
  Type		Group			Classifier
- Locomotives:	group:at_loco		is_locomotive = true
- Controllable:	group:at_control	seat_groups.dstand
- Passengers:	group:at_pax		seat_groups.pass
- Freight:	group:at_freight	has_inventory = true
---
 advtrains/wagons.lua | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index 4093f06..94eda30 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -1316,14 +1316,23 @@ function advtrains.register_wagon(sysname_p, prototype, desc, inv_img, nincreati
	minetest.register_entity(":"..sysname,prototype)
	advtrains.wagon_prototypes[sysname] = prototype
	
	--group classification to make recipe searching easier
	local wagon_groups = { not_in_creative_inventory = nincreative and 1 or 0}
	if prototype.is_locomotive then wagon_groups['at_loco'] = 1 end
	if prototype.seat_groups then
		if prototype.seat_groups.dstand then wagon_groups['at_control'] = 1 end
		if prototype.seat_groups.pass then wagon_groups['at_pax'] = 1 end
	end
	if prototype.has_inventory then wagon_groups['at_freight'] = 1 end

	minetest.register_craftitem(":"..sysname, {
		description = desc,
		inventory_image = inv_img,
		wield_image = inv_img,
		stack_max = 1,
		
		groups = { not_in_creative_inventory = nincreative and 1 or 0},
		
		groups = wagon_groups,

		on_place = function(itemstack, placer, pointed_thing)
				if not pointed_thing.type == "node" then
					return
-- 
2.31.1
Reply to thread Export thread (mbox)