Post your modding questions here

User avatar
stu
Member
 
Posts: 737
Joined: Sat Feb 02, 2013 02:51
GitHub: stujones11

Re: Post your modding questions here

by stu » Wed Oct 05, 2016 18:48

AnxiousInfusion wrote:Thanks, even though that is sad news. I got 90% of the way through making a sword with dynamic sound effects only to get snagged on the on_use override. Maybe I can have it set_hp() if pointed_thing is an object ... object.is_player() ... ?

I really wish the engine had some sort of register-damage function.

I was about to suggest the after_use callback but this only called after a node is dug and I’m not sure if it is even called at all for players or entities.

I came up with this idea which essentially allows you to add a ‘sounds’ table to any tool definition. Unfortunately due to limitations of the api this will only work when you hit nodes or players, not entities.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_punchnode(function(pos, node, puncher)
   local tool = puncher:get_wielded_item()
   if tool then
      local def = tool:get_definition()
      if def and def.sounds and def.sounds.node then
         minetest.sound_play(def.sounds.node, {pos=pos})
      end
   end
end)

minetest.register_on_punchplayer(function(player, hitter)
   local tool = hitter:get_wielded_item()
   if tool then
      local def = tool:get_definition()
      if def and def.sounds and def.sounds.player then
         minetest.sound_play(def.sounds.player, {object=player})
      end
   end
end)

-- example tooldef

minetest.register_tool("soundfx:pick_glass", {
   description = "Glass Pickaxe",
   inventory_image = "soundfx_pick_glass.png",
   tool_capabilities = { ... },
   sounds = {
      node = "default_break_glass",
      player = "default_break_glass",
   },
})

It seems a bit incomplete that we should have on_punchnode and on_punchplayer but no equivalent for entities :(
 

User avatar
AnxiousInfusion
Member
 
Posts: 146
Joined: Sun Aug 02, 2015 05:43
GitHub: AnxiousInfusion[GitLab]
IRC: AnxiousInfusion
In-game: AnxiousInfusion

Re: Post your modding questions here

by AnxiousInfusion » Thu Oct 06, 2016 04:43

Thanks, stu. That works like a charm although I do also want to try the method recommended by Byakuren. The goal is to have a sound for swinging at nothing, a sound for hitting entities and a sound for hitting nodes.

Here is a video demonstrating my original implementation:

https://youtu.be/TkPVr4tVkwI

And my original code:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
   on_use = function(itemstack, user, pointed_thing)
   if pointed_thing.type == "object" then
      minetest.sound_play("blade_strike_flesh", { pos = minetest.get_pointed_thing_position(pointed_thing, above), max_hear_distance = 10 })
   elseif pointed_thing.type == "node" then
      minetest.sound_play("blade_strike_surface", { pos = minetest.get_pointed_thing_position(pointed_thing, above), max_hear_distance = 10 })
   elseif pointed_thing.type == "nothing" then
      minetest.sound_play("blade_strike", { pos = user:getpos(), max_hear_distance = 10 })
   else
      minetest.debug("Player struck something that is somehow not an object, node, nor air.")
   end
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: Post your modding questions here

by taikedz » Thu Oct 06, 2016 09:30

Interesting (and fun!) use case.

I once tried to do a very brittle tin dagger: https://github.com/taikedz/moreores/blo ... ua#L16-L31 (merge was not accepted as it was such a dirty hack :-P)

But in that implementation, it cannot dig nodes anymore. The entity hitting routine works as expected.... I think...... never seen any mobs with anything other than "fleshy" armor....

A dirty workaround could be to register node punch routine and check for your tool:

http://dev.minetest.net/minetest.register_on_punchnode

The code for the sound etc would be on the node callback instead of in the tool.

The upside of this is that you can check for damage groups and play a sound accordingly for crumbly nodes, cracky nodes, etc.

You can also check for node groups - cracky, crumbly, choppy, etc - and adapt the sound as desired. Should affect all nodes that a player could punch.

Down side is, we're still not sure how to implement the digging with the tools....
 

User avatar
orwell
Member
 
Posts: 467
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
In-game: orwell

Re: Post your modding questions here

by orwell » Thu Oct 06, 2016 11:09

BirgitLachner wrote:Ah, yes ... a "s" is missing. I mean default-objects, like stone, sand ...

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
core.register_chatcommand("ilist", {
   params = "[search term]",
   description = "list item ids",
   privs = {},
   func = function(name, param)
      --minetest.chat_send_player(name, "")
      local parami=""
      if param~=nil then
         parami=param
      end
      minetest.chat_send_player(name,"------------------------nodes")
      for n, i in pairs(core.registered_nodes) do
         if string.find(n, parami, 1, true) then
            minetest.chat_send_player(name, n)
         end
      end
      minetest.chat_send_player(name,"------------------------tools")
      for n, i in pairs(core.registered_tools) do
         if string.find(n, parami, 1, true) then
            minetest.chat_send_player(name, n)
         end
      end
      minetest.chat_send_player(name,"------------------------craftitems")
      for n, i in pairs(core.registered_craftitems) do
         if string.find(n, parami, 1, true) then
            minetest.chat_send_player(name, n)
         end
      end

   end,
})

a chatcommand that lists item names (these default:???). Put anywhere and execute it with search term 'default'
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

User avatar
BrunoMine
Member
 
Posts: 902
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine

Re: Post your modding questions here

by BrunoMine » Thu Oct 06, 2016 11:21

how to remove a recipe of default mod? (is possible?)
(not want change the source code of the default mod)
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Thu Oct 06, 2016 11:48

BrunoMine wrote:how to remove a recipe of default mod? (is possible?)
(not want change the source code of the default mod)


You must ghange crafts.lua to do this. or do a mod that override the craft of the item (with air).
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
BrunoMine
Member
 
Posts: 902
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine

Re: Post your modding questions here

by BrunoMine » Thu Oct 06, 2016 12:29

azekill_DIABLO wrote:override the craft of the item (with air).



Could you show me a any code for example? Please.
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Thu Oct 06, 2016 12:31

rah.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_craft({
   output = 'default:sword_wood',
   recipe = {
      {""},
   }
})


EDIT: won't work, idk how to make what you want possible without modifing the code of default.
Last edited by azekill_DIABLO on Thu Oct 06, 2016 12:37, edited 1 time in total.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
BrunoMine
Member
 
Posts: 902
Joined: Thu Apr 25, 2013 17:29
GitHub: BrunoMine

Re: Post your modding questions here

by BrunoMine » Thu Oct 06, 2016 12:37

I do not want to change the source code.

Is there a way to do this without changing the mod source?
 

User avatar
DS-minetest
Member
 
Posts: 707
Joined: Thu Jun 19, 2014 19:49
GitHub: DS-Minetest
In-game: DS

Re: Post your modding questions here

by DS-minetest » Thu Oct 06, 2016 15:08

Do not call me -minetest.
Call me DS or DS-minetest.
I am German, so you don't have to pm me English if you are also German.
The background is a lie.
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Thu Oct 06, 2016 15:42

oh thanks!

EDIT: it won't work. won't work at all, the game says the value is nil. Seem to not exist.

EDIT2: it's the api from 4.14 dev no? because it is not in the 4.14 api i have in minetest\doc:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

Havocado
New member
 
Posts: 2
Joined: Tue Oct 04, 2016 21:04

Re: Post your modding questions here

by Havocado » Thu Oct 06, 2016 16:30

Am I able to change/add to the functionality of an existing node? I'd like to add to the possible drops of a few different nodes.
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Thu Oct 06, 2016 17:00

sure you can. check lua api.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

User avatar
pithy
Member
 
Posts: 252
Joined: Wed Apr 13, 2016 17:34
GitHub: pithydon

Re: Post your modding questions here

by pithy » Thu Oct 06, 2016 17:01

Havocado wrote:Am I able to change/add to the functionality of an existing node? I'd like to add to the possible drops of a few different nodes.


Use minetest.override_item() it works just like minetest.register_node() but you only specify what you want to change.
 

User avatar
pithy
Member
 
Posts: 252
Joined: Wed Apr 13, 2016 17:34
GitHub: pithydon

Re: Post your modding questions here

by pithy » Thu Oct 06, 2016 17:03

Is there a way to make a node kill you when it falls on your head?
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Thu Oct 06, 2016 17:18

when it falls, it's an entity. you should override it. check builtin dir.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

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

Re: Post your modding questions here

by Nyarg » Thu Oct 06, 2016 18:25

pithy wrote:Use minetest.override_item() it works just like minetest.register_node() but you only specify what you want to change.

Is it must be done at loadTime too ?
Where do I find full list of functions that marked as workable only at loadTime ?
I am a noob. still yet. Not so noob ) [vml] WIP
"My english isn't well" I know. I'm sorry )
 

Hybrid Dog
Member
 
Posts: 2460
Joined: Thu Nov 01, 2012 12:46

by Hybrid Dog » Thu Oct 06, 2016 19:19

How can l transform a registered item, which is not a node, to a placeable registered node?
 

User avatar
orwell
Member
 
Posts: 467
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
In-game: orwell

Re: Post your modding questions here

by orwell » Thu Oct 06, 2016 19:32

try to re-register it as node (minetest.register_node(":mod:item", {def})
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

User avatar
orwell
Member
 
Posts: 467
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
In-game: orwell

Re: Post your modding questions here

by orwell » Thu Oct 06, 2016 19:36

Nyarg wrote:
pithy wrote:Use minetest.override_item() it works just like minetest.register_node() but you only specify what you want to change.

Is it must be done at loadTime too ?
Where do I find full list of functions that marked as workable only at loadTime ?

It's logical what may be called at load time only. registered nodes cant be changed after they may have been sent to clients. (you can call register_node after load time but it causes bugs on logged-in clients.)
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

User avatar
pithy
Member
 
Posts: 252
Joined: Wed Apr 13, 2016 17:34
GitHub: pithydon

Re: Post your modding questions here

by pithy » Thu Oct 06, 2016 19:51

azekill_DIABLO wrote:when it falls, it's an entity. you should override it. check builtin dir.

It looks like it uses the same entity for all nodes.
I only want to make one node kill you when it falls on your head.
 

User avatar
azekill_DIABLO
Member
 
Posts: 3458
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: Post your modding questions here

by azekill_DIABLO » Thu Oct 06, 2016 20:05

make a new falling node system then.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
Hi, my username is azekill_DIABLO and i'm an exelent bug-maker(yeah...i know...i have a bad reputation)

azekill_DIABLO said: Mineyoshi+ABJ+Baggins= TOPIC HIJACKED.
My Mods and Stuff | Voxellar | VoxBox on GITHUB | M.I.L.A Monster engine
WEIRD MODDING CONTEST !!!
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Post your modding questions here

by Byakuren » Thu Oct 06, 2016 21:06

pithy wrote:
azekill_DIABLO wrote:when it falls, it's an entity. you should override it. check builtin dir.

It looks like it uses the same entity for all nodes.
I only want to make one node kill you when it falls on your head.

The falling node entity carries information about the node, so you can check the node name to make sure you only kill people if it's your node.
Every time a mod API is left undocumented, a koala dies.
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Thu Oct 06, 2016 21:43

Does anyone know why this doesn't work when damage is enabled? The problem seems to be the "if player:hud_get(fr1) == nil", but I don't understand why, or how to get around the problem. It works fine on creative.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
function tool_anim(player, interval, frame1, frame2, frame3)
   if player:hud_get(fr1) == nil then
   fr1 = player:hud_add({
    hud_elem_type = "image",
    position = {x = 0.5, y = 0.5},
    scale = {
      x = -100,
      y = -100
    },
    text = frame1
   })
   end
...(continues)
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

Icalasari
Member
 
Posts: 17
Joined: Tue Sep 23, 2014 05:29
IRC: Icalasari
In-game: Icalasari

Re: Post your modding questions here

by Icalasari » Thu Oct 06, 2016 22:56

If one wanted to make ambient mobs that at most disappeared and put an item or two in the inventory when a specific tool was used on it, would that be something to code from scratch, or use one of the existing mob APIs for? I'm doing a "bug collecting" mod for my first mod, but other than the tarantula, the others wouldn't need anything complex behaviour wise outside of flight nor a health system, but at the same time I'm not even sure where to begin with making custom AI, and I'm not even sure if Minetest has AI in it as a default

Guess maybe a better way of wording the question is:

If the most complex behaviour a mob may show is flight with a preference of seeking either dark or light along with sky, would it be better to do an AI from scratch to package with the mod, or use MobRedo? And if the former, is there even a resource that would be helpful for that?
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Post your modding questions here

by kaeza » Thu Oct 06, 2016 23:08

D00Med wrote:Does anyone know why this doesn't work when damage is enabled? The problem seems to be the "if player:hud_get(fr1) == nil", but I don't understand why, or how to get around the problem. It works fine on creative.
[...]

Where are you initializing `fr1`? The only place you set it in your snippet is after you access that variable.
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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
D00Med
Member
 
Posts: 712
Joined: Sat Feb 07, 2015 22:49
GitHub: D00Med

Re: Post your modding questions here

by D00Med » Thu Oct 06, 2016 23:44

I'm not sure I understand, are you saying that because fr1 doesn't exist at first there is a problem?
And if so, why would that mean it only works without damage enabled?
Look! I have a signature :]
My subgame: https://forum.minetest.net/viewtopic.php?f=15&t=14051#p207242
dmobs2 is coming...
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: Post your modding questions here

by kaeza » Thu Oct 06, 2016 23:51

I'm saying that in your snippet, you use the `fr1` variable before it gets a value (in the `if` block), thus its value may be nil. More context is needed.
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 | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
pithy
Member
 
Posts: 252
Joined: Wed Apr 13, 2016 17:34
GitHub: pithydon

Re: Post your modding questions here

by pithy » Fri Oct 07, 2016 01:05

azekill_DIABLO wrote:when it falls, it's an entity. you should override it. check builtin dir.

Um, how do I override an entity?
 

Icalasari
Member
 
Posts: 17
Joined: Tue Sep 23, 2014 05:29
IRC: Icalasari
In-game: Icalasari

Re: Post your modding questions here

by Icalasari » Fri Oct 07, 2016 03:58

Sorry for all the questions, but I've got another one

Is there a good guide to metadata anywhere? The Rubenwardy one isn't too clear
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 6 guests

cron