Post your modding questions here

Locked
User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Post your modding questions here

by Krock » Post

Kilarin wrote:Lua syntax question.
I want to register a new type of door in a mod. So, I figured I'd just need to make my mod depend on doors and then call doors:register_door
But when I do I get:

Code: Select all

09:43:49: ERROR[main]: /usr/share/minetest/builtin/game/register.lua:60: Name doors:door_secret does not follow naming conventions: "modname:" or ":" prefix required
Which means I'm doing something STUPID. Any help here?
If you want to add a node to a diffrent mod, you need to use:
minetest.register_node(":testmod:testnode",def)


EDIT: Whoops. Saw your 2nd post too late.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
Kilarin
Member
Posts: 896
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

Re: Post your modding questions here

by Kilarin » Post

Krock wrote:If you want to add a node to a diffrent mod, you need to use:
minetest.register_node(":testmod:testnode",def)
Useful info anyway!

Ok, next question, hopefully not so stupid.

I'm playing with making secret doors that look like background material. I'm sure someone has already done it, but the only mod I could find made panels you could walk through instead of actual doors that look like stone or wood etc.

As proof of concept, I can make a wooden door that looks like default_wood, or a cobble door that looks like default_cobble. Works.

BUT, what I'd like to do is enable a recipe in the form of:
group:wood,group:wood,
group:wood,group:wood,
group:wood,group:wood,special_item

where the item would use the default texture for whatever kind of wood you used in the recipe. Is that even possible?

If not, then how could I loop through whatever group:wood or group:stone (or any other groups) are available for a particular world, and build a recipe (and corresponding node) for each using the correct texture for the item?

User avatar
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

Re: Post your modding questions here

by kaeza » Post

Something like this should do:

Code: Select all

for name, def in pairs(minetest.registered_nodes) do
  if def.groups and ((def.groups.stone or 0) > 0) and def.tiles and def.tiles[1] then
    local basename = name:match("[^:]+:(.*)") -- Base name of item without `modname:' prefix.
    register_my_door(basename, def.tiles[1])
  end
end
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal

User avatar
Kilarin
Member
Posts: 896
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

Re: Post your modding questions here

by Kilarin » Post

That looks perfect kaeza, thanks!

video28
New member
Posts: 2
Joined: Wed Jun 18, 2014 17:59
In-game: video28

Re: Post your modding questions here

by video28 » Post

I have the android version, will mods work for me

User avatar
Kilarin
Member
Posts: 896
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

Re: Post your modding questions here

by Kilarin » Post

So, I've got a two sample "secret doors", one plain wood and one cobble. defined like this:

Code: Select all

doors:register_door("secretdoor:door_secret_wood", {
	description = "Secret Door Wood",
	inventory_image = "door_wood.png",
	groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1},
	tiles_bottom = {"default_wood.png", "default_wood.png"},
	tiles_top = {"default_wood.png", "default_wood.png"},
})
My problem is shading/lighting:

Image

As you can see, the doors appear slightly darker than their surroundings. Is this because Doors:register_door sets drawtype = "nodebox" ???

User avatar
Casimir
Member
Posts: 1207
Joined: Fri Aug 03, 2012 16:59
GitHub: CasimirKaPazi

Re: Post your modding questions here

by Casimir » Post

Yes this is because of the drawtype. Smooth lighting is not working for nodeboxes.

User avatar
Kilarin
Member
Posts: 896
Joined: Mon Mar 10, 2014 00:36
GitHub: Kilarin

Re: Post your modding questions here

by Kilarin » Post

Casimir wrote:Yes this is because of the drawtype. Smooth lighting is not working for nodeboxes.
So, I am assuming then that there is NOT a solution right now? Changing the drawtype would not let it be thin as a door. Correct?

I mean, I can live with this, but it's not quite what I had been trying for. :)

User avatar
spootonium
Member
Posts: 94
Joined: Fri May 02, 2014 01:38
Location: Down the mine.

Re: Post your modding questions here

by spootonium » Post

The Project: Attempting to implement a "co-operative hardcore mode", in which the death of all players triggers the deletion and re-generation of the map.
The Problem: In order to delete the map files (without causing errors and additional problems) the server will need to cease reading and writing actions and "close" those files, preferably without needing to shut down itself.
The Question: Is there a way, within the Lua API, to force-close the map, without shutting down the server?

EDIT - Bonus Question: Alternatively, is there a simple way to purge the map data?
I write code. Sometimes, it even works.

User avatar
Casimir
Member
Posts: 1207
Joined: Fri Aug 03, 2012 16:59
GitHub: CasimirKaPazi

Re: Post your modding questions here

by Casimir » Post

I don't know about deleting, but there are some alternatives:
* Random respawn anywhere on the map. When you respawn 30000 nodes away from your first spawn, you probably won't find your old world again.
* ABM to replace air with some other node, containing an check if the player died. That way the player would be stuck where he respawns.
* Use a protector mod to protect the whole world. You can still look at what you have build and save it with worldedit, but the game is over. I like this way the best. Together with some details it would also feel very smooth. Like, respawn exactly where you died, changing the skin to ghost (like BlockMens creature mod), grant fly and fast, and so on.

video28
New member
Posts: 2
Joined: Wed Jun 18, 2014 17:59
In-game: video28

Re: Post your modding questions here

by video28 » Post

I have the android version: how do I use mods

User avatar
spootonium
Member
Posts: 94
Joined: Fri May 02, 2014 01:38
Location: Down the mine.

Re: Post your modding questions here

by spootonium » Post

Casimir wrote:I don't know about deleting, but there are some alternatives:
* Random respawn anywhere on the map. When you respawn 30000 nodes away from your first spawn, you probably won't find your old world again.
* ABM to replace air with some other node, containing an check if the player died. That way the player would be stuck where he respawns.
* Use a protector mod to protect the whole world. You can still look at what you have build and save it with worldedit, but the game is over. I like this way the best. Together with some details it would also feel very smooth. Like, respawn exactly where you died, changing the skin to ghost (like BlockMens creature mod), grant fly and fast, and so on.
Hmm. None of those options really satisfy the purpose of what I want to accomplish. If actually deleting the map isn't possible without killing the server altogether, I suspect the best thing to do would be to purge map.db, and force a new mapgen with a new seed. Sadly, I don't know nearly enough about MySQL to do that safely.
I write code. Sometimes, it even works.

User avatar
DeepGaze
Member
Posts: 332
Joined: Fri May 10, 2013 00:49
GitHub: DeepGaze
IRC: DeepGaze
In-game: DeepGaze
Location: Take your best guess

Re: Post your modding questions here

by DeepGaze » Post

is there a tutorial on map gen- wanting to populate a world with a single node (air above the nodes though)
there's no place like 127.0.0.1
The deep life Minetest text page
minetest cards

User avatar
Casimir
Member
Posts: 1207
Joined: Fri Aug 03, 2012 16:59
GitHub: CasimirKaPazi

Re: Post your modding questions here

by Casimir » Post

Only one node and everything flat? Than this might be what you want: https://github.com/CasimirKaPazi/untern ... r/init.lua
Last edited by Casimir on Mon Jun 23, 2014 18:53, edited 2 times in total.

User avatar
DeepGaze
Member
Posts: 332
Joined: Fri May 10, 2013 00:49
GitHub: DeepGaze
IRC: DeepGaze
In-game: DeepGaze
Location: Take your best guess

Re: Post your modding questions here

by DeepGaze » Post

Thank you Casmir one more question: How can you fix the sky to night but keep the map lit, I have seen it on a server but can't remember witch?
there's no place like 127.0.0.1
The deep life Minetest text page
minetest cards

User avatar
pandaro
Member
Posts: 327
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro
Location: behind

Re: Post your modding questions here

by pandaro » Post

someone here has already used minetest.find_path ()?
are not able to make it work.
I post something, tell me if I'm wrong thanks!

Code: Select all

ant.find_food=function(pos)
	local food=minetest.find_node_near(pos, 10, "default:apple")
	if food==nil then
		print(tostring("no"))
		
	else
		print(tostring("yes"))
		if dist>1 then 
			local path=minetest.find_path(pos,food,2,1,1,"A*_noprefetch")
			print(tostring("path ")..dump(path))
		else
			minetest.remove_node(food)
		end
	end
	return food
end

Daven
Member
Posts: 26
Joined: Mon Jan 20, 2014 21:51
Location: Inside the white whale

Re: Post your modding questions here

by Daven » Post

Can someone post a link to the inventory_plus mod?

User avatar
kaeza
Moderator
Posts: 2162
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza
Location: Montevideo, Uruguay
Contact:

Re: Post your modding questions here

by kaeza » Post

Daven wrote:Can someone post a link to the inventory_plus mod?
Have you tried using a web search engine?
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal

drkwv
Member
Posts: 102
Joined: Thu Jun 28, 2012 13:48
GitHub: aa6

Re: Post your modding questions here

by drkwv » Post

RHR wrote:You do not need an own group for that:

1. is diggable by bare hands
oddly_breakable_by_hand = 3

2. but sounds like a stone upon digging (like a stone that is being digged by axe)
has nothing to do with tool, just use the stone sound:
sounds = default.node_sound_stone_defaults()

3. and has some custom crack pattern (if that possible)
change the crack_anylength.png texture to your custom crack pattern.

Code: Select all

minetest.register_node("YourModName:YourBlockName", {
	tiles = {"YourTexture.png"},
	groups = {oddly_breakable_by_hand = 3}, -- or: groups = {oddly_breakable_by_hand = 3, choppy = 3},
	sounds = default.node_sound_stone_defaults(),
})
Please post your future modding questions here:
viewtopic.php?f=9&t=4668&p=146064#p146064
Thank you for the answer.
1. I set groups = {oddly_breakable_by_hand = 3} for node and now it's breaking with more situable sound, but I must admit that digging sound is not still the same as for groups = { cracky = 1, stone = 1 }. Any other thing I could do to fix the sound?
2. I changed crack_anylength.png, put it in my mods/mod/textures folder and cracking texture has changed for all blocks, not only from my mod. Is there a way to define custom cracking pattern only for a particular node?

User avatar
Topywo
Member
Posts: 1721
Joined: Fri May 18, 2012 20:27

Re: Post your modding questions here

by Topywo » Post

Daven wrote:Can someone post a link to the inventory_plus mod?
viewtopic.php?f=11&t=3100

drkwv
Member
Posts: 102
Joined: Thu Jun 28, 2012 13:48
GitHub: aa6

Re: Post your modding questions here

by drkwv » Post

Do minetest.get_node_light(pos) working? I'm getting 0 all the time.

User avatar
BlockMen
Developer
Posts: 768
Joined: Fri Mar 01, 2013 17:24
GitHub: BlockMen
Location: Germany

Re: Post your modding questions here

by BlockMen » Post

drkwv wrote:Do minetest.get_node_light(pos) working? I'm getting 0 all the time.
Yes, it works. I guess you are using a wrong pos. Imagine that the function returns the light value "inside" of the node at given position. So if you want to get the light value ontop your node you need to get the light value above.
Example:
Image

If you want get the light value ontop of this dirt block you need to add

Code: Select all

pos.y = pos.y+1
to your code to get the correct value

User avatar
pandaro
Member
Posts: 327
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro
Location: behind

Re: Post your modding questions here

by pandaro » Post

Someone here can, at least, ensure me that minetest.find_path() work properly?
I begin to suspect a bug. In which case I will report it on github.
But if someone tells me, at least, that he work, then I'm wrong!
thanks

User avatar
BrunoMine
Member
Posts: 1082
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine
Location: SP-Brasil
Contact:

Comand for suicide

by BrunoMine » Post

there is a command for suicide? Can you show me?

User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Comand for suicide

by Krock » Post

brunob.santos wrote:there is a command for suicide? Can you show me?

Code: Select all

minetest.register_chatcommand("killme", {
	description = "Kills you",
	func = function(name, param)
		local player = minetest.get_player_by_name(name)
		player:set_hp(0)
	end
})
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

Locked

Who is online

Users browsing this forum: No registered users and 10 guests