Post your modding questions here

User avatar
You
Member
Posts: 41
Joined: Sat Aug 05, 2017 23:34
GitHub: Me
IRC: Me
In-game: You

Re: Post your modding questions here

by You » Post

Making better anti-cheat system ?
Yeah i know there are good anti-cheats, but they can be easy broken with remoding MT client to ignore them. Is possible to make anti-cheat which can't be broken that easy. Something which would not allow MT remodded client to join server ?
Who's Soulja boy?

Yuuuuuu

User avatar
cx384
Member
Posts: 653
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Post

hajo wrote:With entries in depends.txt it is possible for a mod to check if other needed mods are installed.
https://github.com/minetest/minetest/bl ... i.txt#L150
You should use minetest.get_modnames(). https://github.com/minetest/minetest/bl ... .txt#L2163
hajo wrote: Is it possible to check for a minimum version of the minetest-engine (e.g."needs 0.4.16-dev") ?
You can use minetest.get_version(). https://github.com/minetest/minetest/bl ... .txt#L2222
Can your read this?

wrcwpk
New member
Posts: 3
Joined: Thu Aug 24, 2017 23:44

Re: Post your modding questions here

by wrcwpk » Post

Topic: How to handle a block being right clicked(or more generally how to handle any interactions with a block)

Reason: Part of my mod involves performing a series of actions when a specified block is right clicked with a shovel

More Info(optional): I'm quite new to minetest development(thought not developmenet in general) I didn't see an event for block breaking, clicking, etc in the API, to handle this do I need to change all shovels? I'm assuming there is a more direct route that other mods have taken.

Nyarg
Member
Posts: 276
Joined: Sun May 15, 2016 04:32

Re: Post your modding questions here

by Nyarg » Post

wrcwpk wrote:Topic: How to handle a block being right clicked
in ..\minetest-0.4.14\doc\lua_api.txt
May be ### Node definition (`register_node`)
on_rightclick = func(pos, node, clicker, itemstack, pointed_thing)

for quick scope use something like
Spoiler
Image
SNAG-25204.jpg
SNAG-25204.jpg (192.92 KiB) Viewed 647 times
I am a noob. still yet. Not so noob ) [vml] WIP and a little proof for fun PlantedTorch )))
MT Strike 78a36b468554d101e0be3b0d1f587a555f396452 Great! Somebody have found it )
"My english isn't well" I know. I'm sorry )

wrcwpk
New member
Posts: 3
Joined: Thu Aug 24, 2017 23:44

Re: Post your modding questions here

by wrcwpk » Post

Deleted
Last edited by wrcwpk on Sat Aug 26, 2017 19:30, edited 1 time in total.

wrcwpk
New member
Posts: 3
Joined: Thu Aug 24, 2017 23:44

Re: Post your modding questions here

by wrcwpk » Post

How can I get the formatted item name? when using itemstack:get_name()?

Right now it prints table: 0x<Some hex code> where what I want is "default:dirt"

User avatar
cx384
Member
Posts: 653
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Post

wrcwpk wrote:How can I get the formatted item name? when using itemstack:get_name()?

Right now it prints table: 0x<Some hex code> where what I want is "default:dirt"
"itemstack:get_name()" should give you the name of the itemstack. https://github.com/minetest/minetest/bl ... .txt#L3536

Probably your userdata isn't an itemstack.
Maybe it is an inventory, in this case you can use "inv:get_stack(listname, i)".

Please give us more informations about your code.

By the way you can also try "itemstack:to_table().name".
Can your read this?

John_Constructor
Member
Posts: 76
Joined: Thu Jun 01, 2017 20:06
GitHub: John-Constructor
In-game: Nooberton
Location: On Minetest 24/7

Re: Post your modding questions here

by John_Constructor » Post

Title: Is there a way to mass-override crafts as well as create the ability to use two of the same item to somewhat carve them into things such as AxeHeads?

Reason: I want to make a Crafting Realism mod that rather than allowing to start off with wood, needing to start off with collecting stones to create tools, or at the least, the heads for the tools.
Constructing mechs and wingless aircraft since 2016.

User avatar
cx384
Member
Posts: 653
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Post

John_Constructor wrote:Title: Is there a way to mass-override crafts as well as create the ability to use two of the same item to somewhat carve them into things such as AxeHeads?

Reason: I want to make a Crafting Realism mod that rather than allowing to start off with wood, needing to start off with collecting stones to create tools, or at the least, the heads for the tools.
Yeah minetest.clear_craft(recipe).
https://github.com/minetest/minetest/bl ... .txt#L2339
Do you want to do something like the realtest game?
viewtopic.php?t=13624
Can your read this?

John_Constructor
Member
Posts: 76
Joined: Thu Jun 01, 2017 20:06
GitHub: John-Constructor
In-game: Nooberton
Location: On Minetest 24/7

Re: Post your modding questions here

by John_Constructor » Post

cx384 wrote:
John_Constructor wrote:Title: Is there a way to mass-override crafts as well as create the ability to use two of the same item to somewhat carve them into things such as AxeHeads?

Reason: I want to make a Crafting Realism mod that rather than allowing to start off with wood, needing to start off with collecting stones to create tools, or at the least, the heads for the tools.
Yeah minetest.clear_craft(recipe).
https://github.com/minetest/minetest/bl ... .txt#L2339
Do you want to do something like the realtest game?
viewtopic.php?t=13624
Potentially so, I'll need to look into that.
Constructing mechs and wingless aircraft since 2016.

User avatar
christoferlevich
Member
Posts: 325
Joined: Thu Dec 01, 2016 23:44
GitHub: ChristoferL
Location: Athol, Massachusetts

Re: Post your modding questions here

by christoferlevich » Post

John_Constructor wrote:
cx384 wrote:
John_Constructor wrote:Title: Is there a way to mass-override crafts as well as create the ability to use two of the same item to somewhat carve them into things such as AxeHeads?

Reason: I want to make a Crafting Realism mod that rather than allowing to start off with wood, needing to start off with collecting stones to create tools, or at the least, the heads for the tools.
Yeah minetest.clear_craft(recipe).
https://github.com/minetest/minetest/bl ... .txt#L2339
Do you want to do something like the realtest game?
viewtopic.php?t=13624
Potentially so, I'll need to look into that.
Couldn't you put in the same idea into effect by making nodes unbreakable against hands - and maybe the elimination of wonderful items like wooden sword and ax (these always leave me laughing).
everything can be a learning experience...

John_Constructor
Member
Posts: 76
Joined: Thu Jun 01, 2017 20:06
GitHub: John-Constructor
In-game: Nooberton
Location: On Minetest 24/7

Re: Post your modding questions here

by John_Constructor » Post

I looked into Realtest's description... Exactly my idea for the early game, yet rather than breaking the dirt below the trees- the player needs to start by collecting stones/rocks to make the head of the tool, honestly it would complicate it a little yet it's for the sake of realism; you can't really cut logs apart using your bare hands after digging the soil under it, you need- at the least- some kind of axe head or a saw, the concept came about quite a while before I published my first mod.
Constructing mechs and wingless aircraft since 2016.

User avatar
Desour
Member
Posts: 1469
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: Post your modding questions here

by Desour » Post

John_Constructor wrote:I looked into Realtest's description... Exactly my idea for the early game, yet rather than breaking the dirt below the trees- the player needs to start by collecting stones/rocks to make the head of the tool, honestly it would complicate it a little yet it's for the sake of realism; you can't really cut logs apart using your bare hands after digging the soil under it, you need- at the least- some kind of axe head or a saw, the concept came about quite a while before I published my first mod.
It is already like this. The digging dirt below tree thing was just because of something else.
Last edited by Desour on Sat Sep 02, 2017 16:53, edited 1 time in total.
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
AspireMint
Member
Posts: 415
Joined: Mon Jul 09, 2012 12:59
GitHub: AspireMint
IRC: AspireMint
In-game: AspireMint
Location: Stuck at spawn

Re: Post your modding questions here

by AspireMint » Post

so i tried minetest.register_alias(str1, str2) and minetest.register_alias_force(str1, str2) with no success.
Anyone knows how to use it? (where to put new init.lua file with this function)

EDIT: nvm, forgot to put depends.txt :-/ , so my "mod" is loaded after mod with str1 and str2 blocks

Solved.

John_Constructor
Member
Posts: 76
Joined: Thu Jun 01, 2017 20:06
GitHub: John-Constructor
In-game: Nooberton
Location: On Minetest 24/7

Re: Post your modding questions here

by John_Constructor » Post

Title: How do I create a setting that toggles the existence of certain nodes?

Reason: I want to give one of my mods the ability to have certain materials of nodes disabled to the user's liking,

Extensive information: I decided I wanted to try this when converting it to a modpack wouldn't function correctly (I.E.: only the crafting area of the mod would be enabled when the rest was enabled and in that modpack; in-game result was nodes not being registered compared to crafts.).
Constructing mechs and wingless aircraft since 2016.

DagonX
Member
Posts: 13
Joined: Thu Aug 17, 2017 15:05

Re: Post your modding questions here

by DagonX » Post

Voxel Editor Questions

I ran into some interesting programs that are called Voxel Editors.
Most were geared towards Minecraft though.
My question is there any possible use for them in Minetest?
I was thinking of experimenting with them to do new furniture and plant/tree textures.
I have lot of hand drawn textures I have made but not whole lot of skills with blender or how to put them in Voxel related worlds.
I thought(maybe wrongly) that maybe I could find a easy to use one to work.
I really like to use my tulip tree texture somewhere and some of my silk textures on lounge chairs and chaises.

User avatar
Sergey
Member
Posts: 784
Joined: Wed Jan 11, 2017 13:28
Location: Russia

Re: Post your modding questions here

by Sergey » Post

Here is what is unclear yet for me?
1. How to know what tool was used inside node's on_* methods?
2. How to manipulate durability/wear bar of this tool correctly (e.g. pickaxe)?
3. How wear range 0–65535 of tools related to info in /usr/share/minetest/games/minetest/mods/default/tools.lua

For example, this is info about diamond pickaxe:

Code: Select all

minetest.register_tool("default:pick_diamond", {
	description = "Diamond Pickaxe",
	inventory_image = "default_tool_diamondpick.png",
	tool_capabilities = {
		full_punch_interval = 0.9,
		max_drop_level=3,
		groupcaps={
			cracky = {times={[1]=2.0, [2]=1.0, [3]=0.50}, uses=30, maxlevel=3},
		},
		damage_groups = {fleshy=5},
	},
	sound = {breaks = "default_tool_breaks"},
})
I don't know what all these parameters mean. I wish I know but I can't get details in official documentation. But from here (and from real experience) I know that I can use diamond pickaxe 810 times to break stone (stone pickaxe — 60 times respectively). So I don't see such info in tools.lua.
4. (from above) How I can manually increase wear state of some tool by 10 (for example) uses?
5. Is there event like register_on_toolwearout that run when active tool completely wear out?

P.S. Previous part of my questions about modding: How to…

User avatar
cx384
Member
Posts: 653
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Post

OK, Let's answer this questions.
John_Constructor wrote:Title: How do I create a setting that toggles the existence of certain nodes?
<snip>
First of all you have to create a "settingtypes.txt" file in your mod folder.
Then define your setting inside this file.
how it works

Code: Select all

#<more_info>
<setting_name>(<description>) <type> <default>
example

Code: Select all

# example_setting
mymod_disable_node_mynode(disables mynode) bool true
Now you can check the setting in your lua file.

Code: Select all

if not minetest.settings:get_bool("mymod_disable_node_mynode") then
     minetest.register_node("mymod:mynode", <node definition>)
end
Can your read this?

User avatar
cx384
Member
Posts: 653
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Post

DagonX wrote:Voxel Editor Questions

I ran into some interesting programs that are called Voxel Editors.
Most were geared towards Minecraft though.
My question is there any possible use for them in Minetest?
I was thinking of experimenting with them to do new furniture and plant/tree textures.
I have lot of hand drawn textures I have made but not whole lot of skills with blender or how to put them in Voxel related worlds.
I thought(maybe wrongly) that maybe I could find a easy to use one to work.
I really like to use my tulip tree texture somewhere and some of my silk textures on lounge chairs and chaises.
I think you are searching for meshes or node boxes which you can define in your node definition when you are registering a node.
You can also use the nodebox editor.
Can your read this?

User avatar
cx384
Member
Posts: 653
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: Post your modding questions here

by cx384 » Post

Sergey wrote:Here is what is unclear yet for me?
1. How to know what tool was used inside node's on_* methods?
You can use "player:get_wielded_item()"
Sergey wrote: 2. How to manipulate durability/wear bar of this tool correctly (e.g. pickaxe)?
You can use "itemstack:get_wear()", "itemstack:set_wear(wear)" or "itemstack:add_wear(amount)"
Sergey wrote: 3. How wear range 0–65535 of tools related to info in /usr/share/minetest/games/minetest/mods/default
It is well explained there.
Sergey wrote: 4. (from above) How I can manually increase wear state of some tool by 10 (for example) uses?
See 2.
Sergey wrote: 5. Is there event like register_on_toolwearout that run when active tool completely wear out?
No, you have to work around with "on_use".
Can your read this?

User avatar
orwell
Member
Posts: 958
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell
Location: Raxacoricofallapatorius

Re: Post your modding questions here

by orwell » Post

DagonX wrote:Voxel Editor Questions

I ran into some interesting programs that are called Voxel Editors.
Most were geared towards Minecraft though.
My question is there any possible use for them in Minetest?
I was thinking of experimenting with them to do new furniture and plant/tree textures.
I have lot of hand drawn textures I have made but not whole lot of skills with blender or how to put them in Voxel related worlds.
I thought(maybe wrongly) that maybe I could find a easy to use one to work.
I really like to use my tulip tree texture somewhere and some of my silk textures on lounge chairs and chaises.
This depends on the voxel editor program you use and what it can export
can you name such a program?
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
Sergey
Member
Posts: 784
Joined: Wed Jan 11, 2017 13:28
Location: Russia

Re: Post your modding questions here

by Sergey » Post

cx384 wrote: ... [Answers to Sergey] ...
Thank you very much

User avatar
Sergey
Member
Posts: 784
Joined: Wed Jan 11, 2017 13:28
Location: Russia

Re: Post your modding questions here

by Sergey » Post

Is there any Lua debugger I can use to debug my mod step by step, line by line, looking at what data I have after each line of execution?

Please do not advice to cram my code with print or minetest.debug statements with later scrolling down huge debug.txt file hunting for necessary messages among MT stuff.

User avatar
Sergey
Member
Posts: 784
Joined: Wed Jan 11, 2017 13:28
Location: Russia

Re: Post your modding questions here

by Sergey » Post

Why minetest.register_on_dignode is not recommended?
Are you going to remove that method in future?
As for me, I find it quite useful.

User avatar
rubenwardy
Moderator
Posts: 6972
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: Post your modding questions here

by rubenwardy » Post

Sergey wrote:Why minetest.register_on_dignode is not recommended?
Are you going to remove that method in future?
As for me, I find it quite useful.
it runs on every single node dig, so you should use the node's dig callback if possible instead
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

Locked

Who is online

Users browsing this forum: No registered users and 4 guests