Page 165 of 169

Re: Post your modding questions here

Posted: Tue Sep 12, 2017 17:09
by hajo
christoferlevich wrote:I want a timer to start when a player enters an area/room, ..
and I want it to count time until the player exits
Example program:

Code: Select all

if not t then t=0 
  say("Timer started")
end

players = find_player(3);
if players then
  if t==0 then td=os.date("%Y-%m-%d %H:%M:%S\n") end
  t = t+1
  n = #players
  p = table.concat(players," and ")
  msg = td..t..") players here: "..p
  say(msg)
  td=""
else
  t=0  -- reset timer after players moved away
end
When players are found within 3 blocks, announce date&time once,
start counting and list players within range.
Reset timer if nobody is in range.

Re: Post your modding questions here

Posted: Wed Sep 13, 2017 02:00
by John_Constructor
Okay, so I have two questions:

Title: Is it possible to make a tool that digs multiple nodes in one click?

Reason: I want to create a tool that specifically digs a 3X3 area of nodes.

Question two:

Title: How do I make it so that only when the player right-clicks an entity, and is mounted to it, that they can receive a tool and for it to get removed when unmounted?

Reason: I want to give a vehicle concept I have the ability to only give the tool when the player is mounted to the structure.

Re: Post your modding questions here

Posted: Wed Sep 13, 2017 02:46
by Byakuren
John_Constructor wrote:Okay, so I have two questions:

Title: Is it possible to make a tool that digs multiple nodes in one click?

Reason: I want to create a tool that specifically digs a 3X3 area of nodes.
Yes, use a minetest.register_on_dignode callback and when the player digs a node while wielding the tool, dig the area around the node.

Re: Post your modding questions here

Posted: Wed Sep 13, 2017 14:56
by rommo
I am using a particular map where TNT and other explosive mods dont cause any structural damage even in single player mode. They only damage users (me). What do i need to change in the code to enable damage?

Re: Post your modding questions here

Posted: Thu Sep 14, 2017 04:56
by v-rob
How can I make a node take a very long time to dig? (about 10 seconds to dig one block)

Re: Post your modding questions here

Posted: Thu Sep 14, 2017 18:11
by Stix
when i install the mod: better_bread it doesnt show up in-game, why? here is the code:

Code: Select all

--registers doublebaked_bread

minetest.register_craftitem("better_bread:doublebaked_bread", {
descrition = "doublebaked_bread",
inventory_image = "doublebaked.png",
on_use = minetest.item_eat(10)
})
minetest.register_craft({
type = "cooking",
output = "better_bread:doublebaked_bread"
recipie = "farming:bread",
})
--registers bread block

minetest.register_node("better_bread:bread_block", {
description = "bread block",
tiles = {"breadblock.png"},
groups = {oddly_breakable_by_hand = 3},
on_use = function(itemstack, user, pointed_thing),
hp_change = 20
})
minetest.register_craft({
type = "shapeless",
output = "better_bread:bread_block",
recipie = {"farming:bread", "farming:bread", "farming:bread"}
})

Re: Post your modding questions here

Posted: Thu Sep 14, 2017 19:55
by Stix
can anyone tell me why this mod doesnt work?

Re: Post your modding questions here

Posted: Thu Sep 14, 2017 20:07
by Stix
i see its been downloaded 1 time. i cant help but wonder who downloaded it?

Re: Post your modding questions here

Posted: Thu Sep 14, 2017 22:02
by TumeniNodes
Stix wrote:i see its been downloaded 1 time. i cant help but wonder who downloaded it?
a link to the thread where you got it would be better Stix

Re: Post your modding questions here

Posted: Thu Sep 14, 2017 22:10
by Stix
TumeniNodes wrote:
Stix wrote:i see its been downloaded 1 time. i cant help but wonder who downloaded it?
a link to the thread where you got it would be better Stix
its my WIP mod so thats your answer :P
ive recently updated it but it still doesnt work ill provide a download in the attachments.

Re: Post your modding questions here

Posted: Thu Sep 14, 2017 23:20
by Sergey
How can I write to my in-game console (that appears by pressing [T], [F10] or [/]) some info from my mod? it is for the sake of debugging code.

Commands print(), minetest.log(), minetest.debug() do not write to in-game console, but to debug.txt file. Command print() does not work all — it does not write even to debug.txt file.

Re: Post your modding questions here

Posted: Thu Sep 14, 2017 23:29
by Peppy
Stix wrote:i see its been downloaded 1 time. i cant help but wonder who downloaded it?
I did ;)

Dependencies should be listed in depends.txt, one per line,not coma separated.

This code should work :

Code: Select all

--registers doublebaked_bread

minetest.register_craftitem("better_bread:doublebaked_bread", {
description = "doublebaked bread",
inventory_image = "doublebaked.png",
on_use = minetest.item_eat(10)
})

minetest.register_craft{
type = "cooking",
output = "better_bread:doublebaked_bread",
recipe = "farming:bread",
}

--registers bread block

minetest.register_node("better_bread:bread_block", {
description = "bread block",
tiles = {"breadblock.png"},
groups = {oddly_breakable_by_hand = 3},
on_use = minetest.item_eat(20)
})

minetest.register_craft{
type = "shapeless",
output = "better_bread:bread_block",
recipe = {"farming:bread", "farming:bread", "farming:bread"}
}
You may be interested in those two utilities :
Meld to compare files (available in your Xubuntu package manager).
Luacheck , to check your code.

Re: Post your modding questions here

Posted: Fri Sep 15, 2017 00:13
by Stix
Peppy wrote:
Stix wrote:i see its been downloaded 1 time. i cant help but wonder who downloaded it?
I did ;)

Dependencies should be listed in depends.txt, one per line,not coma separated.

This code should work :

Code: Select all

--registers doublebaked_bread

minetest.register_craftitem("better_bread:doublebaked_bread", {
description = "doublebaked bread",
inventory_image = "doublebaked.png",
on_use = minetest.item_eat(10)
})

minetest.register_craft{
type = "cooking",
output = "better_bread:doublebaked_bread",
recipe = "farming:bread",
}

--registers bread block

minetest.register_node("better_bread:bread_block", {
description = "bread block",
tiles = {"breadblock.png"},
groups = {oddly_breakable_by_hand = 3},
on_use = minetest.item_eat(20)
})

minetest.register_craft{
type = "shapeless",
output = "better_bread:bread_block",
recipe = {"farming:bread", "farming:bread", "farming:bread"}
}
You may be interested in those two utilities :
Meld to compare files (available in your Xubuntu package manager).
Luacheck , to check your code.
does it work for you? cuz i still cant get it in-game no matter what way i try, it might be a issue with my copy of minetest so that is why id like to know.

Re: Post your modding questions here

Posted: Fri Sep 15, 2017 04:39
by Peppy
Did you fix the depends.txt file too ?

This won't work :

Code: Select all

default, farming
It should be :

Code: Select all

default
farming

Re: Post your modding questions here

Posted: Fri Sep 15, 2017 15:06
by Stix
Peppy wrote:Did you fix the depends.txt file too ?

This won't work :

Code: Select all

default, farming
It should be :

Code: Select all

default
farming
yes i have fixed it

Re: Post your modding questions here

Posted: Fri Sep 15, 2017 21:51
by Sergey
Sergey wrote:How can I write to my in-game console (that appears by pressing [T], [F10] or [/]) some info from my mod? it is for the sake of debugging code.

Commands print(), minetest.log(), minetest.debug() do not write to in-game console, but to debug.txt file. Command print() does not work all — it does not write even to debug.txt file.
Can anybody answer me?

Re: Post your modding questions here

Posted: Fri Sep 15, 2017 22:41
by Napiophelios
Sergey wrote:
Sergey wrote:How can I write to my in-game console (that appears by pressing [T], [F10] or [/]) some info from my mod? it is for the sake of debugging code.

Commands print(), minetest.log(), minetest.debug() do not write to in-game console, but to debug.txt file. Command print() does not work all — it does not write even to debug.txt file.
Can anybody answer me?
I don't know what kind of info you want to broadcast but you
probably need to look into "chat" messages if you want it to show in game.

https://rubenwardy.com/minetest_modding ... /chat.html

Re: Post your modding questions here

Posted: Fri Sep 15, 2017 23:15
by Sergey
As I understand, mod's name can't be group cuz I saw recipes like

Code: Select all

{
    {"group:stone"},
    {"default:stick"},
    {"default:stick"},
}
... for stone shovel.

group name is a reserved name?
If so, what are reserved names in the game?
What if someone make mod called group?

Re: Post your modding questions here

Posted: Fri Sep 15, 2017 23:44
by John_Constructor
Sergey wrote:As I understand, mod's name can't be group cuz I saw recipes like

Code: Select all

{
    {"group:stone"},
    {"default:stick"},
    {"default:stick"},
}
... for stone shovel.

group name is a reserved name?
If so, what are reserved names in the game?
What if someone make mod called group?
From my understanding, A mod can be called "Group" as long as it doesn't have any items of any name such as "Stone" or relative to any used groups, it also is most likely to interfere with crafting when you DO register such things.

Re: Post your modding questions here

Posted: Sat Sep 16, 2017 00:17
by v-rob
If you want a mod called "group", then name it "groups."

Re: Post your modding questions here

Posted: Sat Sep 16, 2017 00:24
by Sergey
v-rob wrote:If you want a mod called "group", then name it "groups."
No, I don't want to. At all. I was just curious what if… while looking at recipes.

How does MT distinguish e.g. itemname "default:dirt" from group "group:wood", if the format is the same "<super>:<sub>"?

Re: Post your modding questions here

Posted: Sat Sep 16, 2017 04:31
by v-rob
"Group" is registered in the engine.

Re: Post your modding questions here

Posted: Sat Sep 16, 2017 18:53
by Stix
Question: is it possible to attach a entity to a nodebox?

Re: Post your modding questions here

Posted: Sat Sep 16, 2017 19:31
by rubenwardy
Sergey wrote:
v-rob wrote:If you want a mod called "group", then name it "groups."
No, I don't want to. At all. I was just curious what if… while looking at recipes.

How does MT distinguish e.g. itemname "default:dirt" from group "group:wood", if the format is the same "<super>:<sub>"?
It checks if the half is "group", if so it's a group.

Re: Post your modding questions here

Posted: Sun Sep 17, 2017 01:45
by Sergey
How to make each inventory slot hold more than 99 items (if items are stackable)?
Say, 1000 items.