Page 163 of 169

Re: Post your modding questions here

PostPosted: Tue Aug 22, 2017 21:11
by You
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 ?

Re: Post your modding questions here

PostPosted: Tue Aug 22, 2017 21:56
by cx384
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

Re: Post your modding questions here

PostPosted: Thu Aug 24, 2017 23:48
by wrcwpk
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.

Re: Post your modding questions here

PostPosted: Fri Aug 25, 2017 02:30
by Nyarg
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
SNAG-25204.jpg
(192.92 KiB) Not downloaded yet

Re: Post your modding questions here

PostPosted: Fri Aug 25, 2017 18:37
by wrcwpk
Deleted

Re: Post your modding questions here

PostPosted: Sat Aug 26, 2017 19:26
by wrcwpk
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"

Re: Post your modding questions here

PostPosted: Sun Aug 27, 2017 07:56
by cx384
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".

Re: Post your modding questions here

PostPosted: Mon Aug 28, 2017 18:46
by John_Constructor
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.

Re: Post your modding questions here

PostPosted: Mon Aug 28, 2017 22:09
by cx384
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

Re: Post your modding questions here

PostPosted: Mon Aug 28, 2017 23:13
by John_Constructor
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.

Re: Post your modding questions here

PostPosted: Tue Aug 29, 2017 11:31
by christoferlevich
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).

Re: Post your modding questions here

PostPosted: Thu Aug 31, 2017 14:11
by John_Constructor
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.

Re: Post your modding questions here

PostPosted: Thu Aug 31, 2017 16:08
by DS-minetest
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.

Re: Post your modding questions here

PostPosted: Sat Sep 02, 2017 16:19
by AspireMint
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.

Re: Post your modding questions here

PostPosted: Sun Sep 03, 2017 21:02
by John_Constructor
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.).

Re: Post your modding questions here

PostPosted: Mon Sep 04, 2017 20:51
by DagonX
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.

Re: Post your modding questions here

PostPosted: Mon Sep 04, 2017 21:10
by Sergey
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…

Re: Post your modding questions here

PostPosted: Tue Sep 05, 2017 09:17
by cx384
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

Re: Post your modding questions here

PostPosted: Tue Sep 05, 2017 09:40
by cx384
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.

Re: Post your modding questions here

PostPosted: Tue Sep 05, 2017 10:01
by cx384
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".

Re: Post your modding questions here

PostPosted: Tue Sep 05, 2017 12:19
by orwell
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?

Re: Post your modding questions here

PostPosted: Wed Sep 06, 2017 01:04
by Sergey
cx384 wrote:... [Answers to Sergey] ...

Thank you very much

Re: Post your modding questions here

PostPosted: Wed Sep 06, 2017 01:05
by Sergey
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.

Re: Post your modding questions here

PostPosted: Wed Sep 06, 2017 23:54
by Sergey
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.

Re: Post your modding questions here

PostPosted: Wed Sep 06, 2017 23:56
by rubenwardy
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