Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide numeric biome IDs #91

Open
Montandalar opened this issue Jan 10, 2023 · 2 comments
Open

Provide numeric biome IDs #91

Montandalar opened this issue Jan 10, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@Montandalar
Copy link

This is the terminal output when I add the demo test specs to aussieforks/australia

.minetest/mods/australia$ mineunit
I:	Mineunit configuration loaded from	spec/mineunit.conf
I:	Mod configuration loaded from	mod.conf
I:	Setting modpath	australia	.
I:	Mineunit initialized, current modname is	australia
I:	File not found:	spec/fixtures/fonts
I:	File not found:	spec/fixtures/fonts
I:	Settings object created from:	spec/fixtures/minetest.conf
I:	Running custom core.get_us_time with step increment: 100
I:	Loading fixture	spec/fixtures/default.lua
I:	Loading fixture	spec/fixtures/mesecons.lua
I:	Setting modpath	mesecons	spec/fixtures
I:	Setting modpath	mesecons_mvps	spec/fixtures
I:	Loading fixture	spec/fixtures/digilines.lua
I:	Setting modpath	digilines	spec/fixtures
I:	Loading fixture	spec/fixtures/pipeworks.lua
I:	Setting modpath	pipeworks	spec/fixtures
I:	Loading source	init.lua
E:	* Not loading MOD: Australia *
E:	MOD: Australia requires mod functions which are
E:	 not exposed by your Minetest build.
I:	Executing register_on_mods_loaded functions
I:	Sam places node default:sand at (0,1,0)
●I:	node under is buildable to
I:	Sam places node default:sandstone at (2,1,0)
●I:	node under is buildable to
I:	Sam places node default:sandstonebrick at (3,1,0)
●I:	node under is buildable to
I:	Sam places node default:stonebrick at (4,1,0)
●I:	node under is buildable to
I:	Sam places node default:furnace at (5,1,0)
●I:	node under is buildable to
I:	Sam places node default:stone at (6,1,0)
●I:	node under is buildable to
I:	Sam places node default:steelblock at (7,1,0)
●◌●
8 successes / 0 failures / 0 errors / 1 pending : 0.024418 seconds

Pending → spec/init_spec.lua @ 61
Demo tests placed all nodes
spec/init_spec.lua:61: This test might be too simple for potentially complex operation and fails if node is changed

The mod code doesn't load due to a missing C++ API function (l_get_biome_id)

The builtin Lua code does not manage these numeric IDs, rather they have a C++ getter available as minetest.get_biome_id. How should these IDs be provided, some kind of fork to the builtin code to record biome IDs inside Lua so they can be provided later? I'm just not sure where the code would go or I'd bring a PR. I do think it belongs inside mineunit instead of a test fixture.

@Montandalar
Copy link
Author

Montandalar commented Jan 10, 2023

Of course, the code the relies on this in Australia mod is disabled and could arguably be deleted because the scraps of functionality that it has as a work in progress seem overlap the biome functionality anyway. But I did think it was worth bringing up in case some other mod uses it.

@S-S-X
Copy link
Owner

S-S-X commented Feb 17, 2023

I guess this is probably very similar to content ids which is mostly auto increment:

mineunit/core.lua

Lines 117 to 134 in 15adf6c

local content_name2id = {}
local content_id2name = {}
_G.minetest.get_content_id = function(name)
-- check if the node exists
assert(minetest.registered_nodes[name], "node " .. name .. " is not registered")
-- create and increment
if not content_name2id[name] then
content_name2id[name] = #content_id2name
table.insert(content_id2name, name)
end
return content_name2id[name]
end
_G.minetest.get_name_from_content_id = function(cid)
assert(content_id2name[cid+1], "Unknown content id")
return content_id2name[cid+1]
end

(content ids aren't handled exactly like in actual engine, few special core nodes have static ids in minetest but not on mineunit)

Biome ID in docs, so I guess something similar to above snippet would work just fine:

integer object handle uniquely identifying the registered biome

edit. Also there's no biome registration in mineunit so would need to add that, probably some stuff as no-ops...

@S-S-X S-S-X added the enhancement New feature or request label Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

2 participants