Post your modding questions here

JackWilliam
Member
 
Posts: 10
Joined: Tue Dec 27, 2016 14:41

Re: Post your modding questions here

by JackWilliam » Mon Jan 02, 2017 21:40

Napiophelios wrote:try making a folder in the texture pack directory and place the image there too.
then select your new "texture pack" when you start the game.

Almost every time I get this error it's because I mispelt something somewhere.


Thanks a lot, now it works fine. I have another question, how can I put a node on the map such as the diamond block, coal, gold, etc.?
 

User avatar
yzelast
Member
 
Posts: 43
Joined: Sun Oct 02, 2016 01:18
GitHub: yzelast
In-game: yzelast

Re: Post your modding questions here

by yzelast » Tue Jan 03, 2017 00:34

hi guys,i have a few questions about node timers.

If a timer end in an unloaded mapblock what will happen with the code inside the on_timer function?
And how i do to make a node timer stop decreasing on night, and return to decrease on day?

If i could pause the timers at night my trees mod will benefits a lot,making the growing more precise.
Have a free time? So check it out my mods: Real Trees and Wood Plus
 

sofar
Member
 
Posts: 781
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Post your modding questions here

by sofar » Tue Jan 03, 2017 01:32

yzelast wrote:hi guys,i have a few questions about node timers.

If a timer end in an unloaded mapblock what will happen with the code inside the on_timer function?
And how i do to make a node timer stop decreasing on night, and return to decrease on day?

If i could pause the timers at night my trees mod will benefits a lot,making the growing more precise.


You can't dynamically put code in `on_timer()`, it has to be known at init time, so the code is always known no matter what.

The default trees in the game use node timers and if the timer elapses during the night, the growth is attempted again and again every 2 minutes or so until light levels are in order.

Postponing a node timer is possible, but not on unloaded blocks, so you need to do this in the `on_timer()` function.

If a node timer expires while the block is unloaded, the node timer code for that node is run as soon as the block is loaded. Unlike ABM's, nodetimers are never skipped.

Making a node timer stop decreasing at night is pretty much not possible, not reliably anyway. You're better off finding an algorithm that works for you that doesn't require that type of mechanism.
 

User avatar
yzelast
Member
 
Posts: 43
Joined: Sun Oct 02, 2016 01:18
GitHub: yzelast
In-game: yzelast

Re: Post your modding questions here

by yzelast » Tue Jan 03, 2017 04:14

sofar wrote:
yzelast wrote:hi guys,i have a few questions about node timers.

If a timer end in an unloaded mapblock what will happen with the code inside the on_timer function?
And how i do to make a node timer stop decreasing on night, and return to decrease on day?

If i could pause the timers at night my trees mod will benefits a lot,making the growing more precise.


You can't dynamically put code in `on_timer()`, it has to be known at init time, so the code is always known no matter what.

The default trees in the game use node timers and if the timer elapses during the night, the growth is attempted again and again every 2 minutes or so until light levels are in order.

Postponing a node timer is possible, but not on unloaded blocks, so you need to do this in the `on_timer()` function.

If a node timer expires while the block is unloaded, the node timer code for that node is run as soon as the block is loaded. Unlike ABM's, nodetimers are never skipped.

Making a node timer stop decreasing at night is pretty much not possible, not reliably anyway. You're better off finding an algorithm that works for you that doesn't require that type of mechanism.


Thanks,i think that my mod will not care if a tree grow at night,taking the right time is enough for me.
I asked about the timers because i don't want to face unexpected behavior with it, because my entire mod is basically timers and abm's
Have a free time? So check it out my mods: Real Trees and Wood Plus
 

petra2201
Member
 
Posts: 29
Joined: Fri Jun 05, 2015 14:42

Re: Post your modding questions here

by petra2201 » Tue Jan 03, 2017 19:42

Topic: Where to put code for stairs.
Reason: I've made a mod for indestructible obsidian and my stairs keep blowing up.

In all my other nodes I can put code in the code block marked minetest.register_node.
However in stairs that codeblock is listed in an if else and no matter where I put my code in the code blocks my stairs keep blowing up. The rest of my nodes (block, door, glass) work great.
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Post your modding questions here

by TumeniNodes » Tue Jan 03, 2017 23:03

petra2201 wrote:Topic: Where to put code for stairs.
Reason: I've made a mod for indestructible obsidian and my stairs keep blowing up.

In all my other nodes I can put code in the code block marked minetest.register_node.
However in stairs that codeblock is listed in an if else and no matter where I put my code in the code blocks my stairs keep blowing up. The rest of my nodes (block, door, glass) work great.


do stairs register instead. stairs is a separate mod from default
Flick?... Flick who?
 

sofar
Member
 
Posts: 781
Joined: Fri Jan 16, 2015 07:31
GitHub: sofar
IRC: sofar
In-game: sofar

Re: Post your modding questions here

by sofar » Wed Jan 04, 2017 00:50

petra2201 wrote:Topic: Where to put code for stairs.
Reason: I've made a mod for indestructible obsidian and my stairs keep blowing up.

In all my other nodes I can put code in the code block marked minetest.register_node.
However in stairs that codeblock is listed in an if else and no matter where I put my code in the code blocks my stairs keep blowing up. The rest of my nodes (block, door, glass) work great.


register your stair+slab nodes normally, then afterwards, use minetest.override_*() to attach an `on_blast()` callback handler that stops the explosion from breaking the stair node.

http://dev.minetest.net/minetest.register_node#on_blast
 

JackWilliam
Member
 
Posts: 10
Joined: Tue Dec 27, 2016 14:41

Re: Post your modding questions here

by JackWilliam » Wed Jan 04, 2017 09:24

Topic: How can put a node on map?
Reason: I want to make a mod.
More Info: I tried, but I did not succeed. what should I do? I want to do add a node on the map and find it in a cave for example. As if it were a block of coal, stone, dirt etc. can you help me ?
 

User avatar
TenPlus1
Member
 
Posts: 1874
Joined: Mon Jul 29, 2013 13:38
GitHub: tenplus1

Re: Post your modding questions here

by TenPlus1 » Wed Jan 04, 2017 10:04

JackWilliam: look here for info on ore spawning: viewtopic.php?id=7013
 

JackWilliam
Member
 
Posts: 10
Joined: Tue Dec 27, 2016 14:41

Re: Post your modding questions here

by JackWilliam » Wed Jan 04, 2017 12:50

TenPlus1 wrote:JackWilliam: look here for info on ore spawning: viewtopic.php?id=7013


thanks a lot TenPlus1, but I'm not looking for this, I want to create a new block in the map and when I'm in game I can find and mine it. As if it were a default block of the map that is generated when the map is loaded. How can I do that?
 

petra2201
Member
 
Posts: 29
Joined: Fri Jun 05, 2015 14:42

Re: Post your modding questions here

by petra2201 » Wed Jan 04, 2017 14:07

Thanks for the help on my explosion proof mod. Paramat helped me and I'm going to re-upload after giving him credit. I wish there was a way to limit damage past my blocks but that would require accessing the radius of the tnt mod but only in relation to my blocks. I'm not sure that's possible.
 

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

Re: Post your modding questions here

by cx384 » Wed Jan 04, 2017 16:38

I figured it out. :D
(sorry for the question)
+ Spoiler
Can your read this?
 

User avatar
GreenDimond
Member
 
Posts: 460
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
IRC: GreenDimond
In-game: GreenDimond

Re: Post your modding questions here

by GreenDimond » Wed Jan 04, 2017 20:16

Ok, so I have a recipe question. Normally if I wanted to remove a recipe using a mod, I would re-register it and give it an output of 0. Unfortunately, I tried this with a technic compressor recipe and it didn't work. How do I remove the [Desert Sand] --> [Desert Stone] Technic compressor recipe?
I am Green. I tend to binge-post. "All of this over a 16x16 representation of a cartoon cat ?!?! what has this world come to..." -TenPlus1, 2017.
Diz mah mods! :D ↑ github.com/minetest/minetest_game/issues/1647#issuecomment-288134572 ↑
Sand Plus - Tac Nayn - Waffles - Coming Soon: Caverealms Plus
 

User avatar
GreenDimond
Member
 
Posts: 460
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
IRC: GreenDimond
In-game: GreenDimond

Re: Post your modding questions here

by GreenDimond » Wed Jan 04, 2017 21:51

Another question: How do I register an item as a dye? I have an item I want to register as a substitute for green dye that is included in ALL recipes for green dye. Such as {'mynode','wool:white'} makes green wool and {'mynode','dye:blue'} makes cyan dye and etc (all other dye combos)... How would I do this?
I am Green. I tend to binge-post. "All of this over a 16x16 representation of a cartoon cat ?!?! what has this world come to..." -TenPlus1, 2017.
Diz mah mods! :D ↑ github.com/minetest/minetest_game/issues/1647#issuecomment-288134572 ↑
Sand Plus - Tac Nayn - Waffles - Coming Soon: Caverealms Plus
 

User avatar
GreenDimond
Member
 
Posts: 460
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
IRC: GreenDimond
In-game: GreenDimond

Re: Post your modding questions here

by GreenDimond » Wed Jan 04, 2017 22:47

Oh and here is another question: Where is the damage API stored? Where it defines when to use the hit sound and what to do when a player is hit? Where is that code? (I am using linux xubuntu).
EDIT: No longer need this.
I am Green. I tend to binge-post. "All of this over a 16x16 representation of a cartoon cat ?!?! what has this world come to..." -TenPlus1, 2017.
Diz mah mods! :D ↑ github.com/minetest/minetest_game/issues/1647#issuecomment-288134572 ↑
Sand Plus - Tac Nayn - Waffles - Coming Soon: Caverealms Plus
 

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 Jan 05, 2017 06:06

GreenDimond wrote:Ok, so I have a recipe question. Normally if I wanted to remove a recipe using a mod, I would re-register it and give it an output of 0. Unfortunately, I tried this with a technic compressor recipe and it didn't work. How do I remove the [Desert Sand] --> [Desert Stone] Technic compressor recipe?

You should ask in the Technic forum thread
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

User avatar
GreenDimond
Member
 
Posts: 460
Joined: Wed Oct 28, 2015 01:26
GitHub: GreenXenith
IRC: GreenDimond
In-game: GreenDimond

Re: Post your modding questions here

by GreenDimond » Thu Jan 05, 2017 15:57

orwell wrote:
GreenDimond wrote:Ok, so I have a recipe question. Normally if I wanted to remove a recipe using a mod, I would re-register it and give it an output of 0. Unfortunately, I tried this with a technic compressor recipe and it didn't work. How do I remove the [Desert Sand] --> [Desert Stone] Technic compressor recipe?

You should ask in the Technic forum thread

Will do.
I am Green. I tend to binge-post. "All of this over a 16x16 representation of a cartoon cat ?!?! what has this world come to..." -TenPlus1, 2017.
Diz mah mods! :D ↑ github.com/minetest/minetest_game/issues/1647#issuecomment-288134572 ↑
Sand Plus - Tac Nayn - Waffles - Coming Soon: Caverealms Plus
 

User avatar
yzelast
Member
 
Posts: 43
Joined: Sun Oct 02, 2016 01:18
GitHub: yzelast
In-game: yzelast

Re: Post your modding questions here

by yzelast » Thu Jan 05, 2017 19:56

Hi guys,i'm having a weird problem:my mod adds more tree leaves,and the leaves are using the same logic of the default.
the problem is that the leaves starts to fall for a few seconds,and the remaining stops to fall without reason.
it's doesn't make sense, so i had to create another abm to work around this issue but now the code is duplicated.
Have a free time? So check it out my mods: Real Trees and Wood Plus
 

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

by Hybrid Dog » Thu Jan 05, 2017 20:14

Do you mean your leaves fall like sand and gravel?
If so (l doubt it), remove falling=1 from the groups.
 

User avatar
yzelast
Member
 
Posts: 43
Joined: Sun Oct 02, 2016 01:18
GitHub: yzelast
In-game: yzelast

Re: Post your modding questions here

by yzelast » Thu Jan 05, 2017 20:25

they should fall as default leaves fall,but some of them just stay there without falling..the leaves started to fall normally and after a few seconds stopped falling

here's one small apple leaves:

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_node("real_trees:small_leaves", {
   description = "Small Leaves",
   drawtype = "nodebox",
   paramtype = "light",
   paramtype2 = "facedir",
   groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
   sounds = default.node_sound_leaves_defaults(),
   drop =   {
      max_items = 1,
      items = {
            {items = {"default:sapling"},rarity = 160},
            {items = {'real_trees:small_leaves'}}
            }
         },

   tiles = {"default_leaves.png"},
   after_place_node = default.after_place_leaves,
   node_box = {type = "fixed", fixed = {{-0.25,-0.5,-0.25,0.25,0,0.25}}}
})
Have a free time? So check it out my mods: Real Trees and Wood Plus
 

User avatar
Semmett9
Member
 
Posts: 149
Joined: Sun Oct 07, 2012 13:48

Reusable Function

by Semmett9 » Thu Jan 05, 2017 21:22

I was wondering if they is a way to call a function.

I have some code which on every on_click it places a note above it. The idea is to have a reusable function so that this code can be used more than once, and my different nodes.

so

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
MAIN FUNCTION {
// code for node
send location of node and name to function 1
print function result 1
}

function 1 {
 // code
 return to main function
}


thanks in advance
 

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 Jan 05, 2017 22:56

Eh, you need to use lua.
use -- instead of //
and eg.:
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
local functionname = function(parameter)
-- code, eg.:
something = parameter
return something
end
mfunctionname = function(n)
-- code, eg.:
print(functionname("bla")..tostring(n))
end

So, "mfunction(1)" prints "bla1".
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.
 

KCoombes
Member
 
Posts: 278
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt or Rudilyn

Re: Post your modding questions here

by KCoombes » Fri Jan 06, 2017 13:13

yzelast wrote:they should fall as default leaves fall,but some of them just stay there without falling..the leaves started to fall normally and after a few seconds stopped falling

here's one small apple leaves:

-snip-,
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
-snip-


leafdecay = 3 means the leaves in a 3x3 radius around default:tree (the wood) will fall if the wood is removed - leaves outside this radius will not fall
setting leafdecay higher can result in leaves from tree A being held in place by tree B
 

User avatar
yzelast
Member
 
Posts: 43
Joined: Sun Oct 02, 2016 01:18
GitHub: yzelast
In-game: yzelast

Re: Post your modding questions here

by yzelast » Fri Jan 06, 2017 16:55

KCoombes wrote:
yzelast wrote:they should fall as default leaves fall,but some of them just stay there without falling..the leaves started to fall normally and after a few seconds stopped falling

here's one small apple leaves:

-snip-,
groups = {snappy = 3, leafdecay = 3, flammable = 2, leaves = 1},
-snip-


leafdecay = 3 means the leaves in a 3x3 radius around default:tree (the wood) will fall if the wood is removed - leaves outside this radius will not fall
setting leafdecay higher can result in leaves from tree A being held in place by tree B


i will take a look, thanks
Have a free time? So check it out my mods: Real Trees and Wood Plus
 

User avatar
yzelast
Member
 
Posts: 43
Joined: Sun Oct 02, 2016 01:18
GitHub: yzelast
In-game: yzelast

Re: Post your modding questions here

by yzelast » Sun Jan 08, 2017 05:19

Hi guys,today i have a little question:
if i stop the node timer with the function stop(), what will happen with the elapsed time? Will i be able to get it with the function get_elapsed()?
Have a free time? So check it out my mods: Real Trees and Wood Plus
 

User avatar
TumeniNodes
Member
 
Posts: 1335
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes

Re: Post your modding questions here

by TumeniNodes » Tue Jan 10, 2017 20:23

can particles be added/activated to a node, for only during punch?
so they are only activated while the user is mining a node?
and if so..., can anyone point me to the basic code please, so I can screw it up? :D
Thank you
Flick?... Flick who?
 

User avatar
ulla
Member
 
Posts: 35
Joined: Wed Feb 04, 2015 09:22
GitHub: IIIullaIII
IRC: ulla
In-game: ulla

Re: Post your modding questions here

by ulla » Wed Jan 11, 2017 15:46

HI all
I need to assign functions to my formspec
the function minetest.play_sound
track_1,2,3 ........... to 1,2,3 buttons, ...............
and minetest.stop_sound for the STOP button
Image
EXIT button works well, but only that :-P]]
For try the mod and help me you can download mod prewiev
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
https://www.dropbox.com/sh/82mmlx3bulbdngo/AABSjkhq_mud_-yIAsmOCAlOa?dl=0


SEE first the README
 

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 » Wed Jan 11, 2017 17:25

ulla wrote:HI all
I need to assign functions to my formspec
the function minetest.play_sound
track_1,2,3 ........... to 1,2,3 buttons, ...............
and minetest.stop_sound for the STOP button
Image
EXIT button works well, but only that :-P]]
For try the mod and help me you can download mod prewiev
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
https://www.dropbox.com/sh/82mmlx3bulbdngo/AABSjkhq_mud_-yIAsmOCAlOa?dl=0

SEE first the README

To assign functions to buttons, you need to use minetest.register_on_player_receive_fields().
If a player clicks a button on the client, this event gets sent to server. Every button has an internal name, this will be its name in the 'fields' table. When that button was pressed, its 'fields' entry is (evaluates to) true.
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_player_receive_fields(function(player, formname, fields)
  if formname=="<your formname>" then
    if fields.quit then
      --escape was pressed
    elseif fields.<name of first button> then
       --the first button was pressed
    elseif fields.<name of second button> then
       --the second one was pressed
    [...]
    end
  end
end)

Of course without the <>, just simple lua table indexing.
You can also read the contents of text fields here:
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
local contents_of_text_field = fields.<name of text field>
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...
 

User avatar
ulla
Member
 
Posts: 35
Joined: Wed Feb 04, 2015 09:22
GitHub: IIIullaIII
IRC: ulla
In-game: ulla

Re: Post your modding questions here

by ulla » Wed Jan 11, 2017 18:00

orwell wrote:
ulla wrote:HI all
I need to assign functions to my formspec
the function minetest.play_sound
track_1,2,3 ........... to 1,2,3 buttons, ...............
and minetest.stop_sound for the STOP button
Image
EXIT button works well, but only that :-P]]
For try the mod and help me you can download mod prewiev
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
https://www.dropbox.com/sh/82mmlx3bulbdngo/AABSjkhq_mud_-yIAsmOCAlOa?dl=0

SEE first the README

To assign functions to buttons, you need to use minetest.register_on_player_receive_fields().
If a player clicks a button on the client, this event gets sent to server. Every button has an internal name, this will be its name in the 'fields' table. When that button was pressed, its 'fields' entry is (evaluates to) true.
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_player_receive_fields(function(player, formname, fields)
  if formname=="<your formname>" then
    if fields.quit then
      --escape was pressed
    elseif fields.<name of first button> then
       --the first button was pressed
    elseif fields.<name of second button> then
       --the second one was pressed
    [...]
    end
  end
end)

Of course without the <>, just simple lua table indexing.
You can also read the contents of text fields here:
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
local contents_of_text_field = fields.<name of text field>

TY for answer and sorry for my english is my first problem i need big time for understand english tutor/ial :-) and the guides for formspec are mutch inexplicative :-( (for me :-P) this is my 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
local function play_track(pos, track)
   return minetest.sound_play("juke_track_"..tostring(track),
         {pos = pos, gain = 1.0, loop = true, max_hear_distance = 72,})
end
local function stop_player(pos, node)
   local pos_hash = minetest.hash_node_position(pos)
   local music_handle = music_handles[pos_hash]
   if music_handle then
      minetest.sound_stop(music_handle)
      music_handles[pos_hash] = nil
   end
end
-- Show form when the /formspec command is used.
minetest.register_chatcommand("juke", {
   func = function(name, param)
      minetest.show_formspec(name, "jukebox:form",
            "size[4.0,4.5]" ..
                "background[-0,-0;4,4.5;juke_bag.png]"..
                "label[0,0;CIAO!!!, " .. name .. "]" ..
               "field[0.3,2.5;4,1;ded;" .. name .. ", DEDICA;]" ..
                "button[1,0.3;2,1;stop;STOP!]"..
                "button[0,1;1,1;track_1;1]"..
                "button[1,1;1,1;track_2;2]"..
             "button[2,1;1,1;track_3;3]"..
             "button[3,1;1,1;track_4;4]"..
                "button[0,3;1,1;track_5;5]"..
                "button[1,3;1,1;track_6;6]"..
             "button[2,3;1,1;track_7;7]"..
             "button[3,3;1,1;track_8;8]"..
            "button_exit[1,3.7;2,1;exit;EXIT]")
                   end
   
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
  if formname=="jukebox:form"
   
     
    local stop_player = 0 
    local " .. name .. ", DEDICA = fields.ded
   local juke_track = nil
      if fields.stop then juke_track = 0 end
      elseif fields.track_1 then juke_track_ = 1 end
      elseif fields.track_2 then juke_track_ = 2 end
      elseif fields.track_3 then juke_track = 3 end
      elseif fields.track_4 then juke_track = 4 end
      elseif fields.track_5 then juke_track = 5 end
      elseif fields.track_6 then juke_track = 6 end
      elseif fields.track_7 then juke_track = 7 end
      elseif fields.track_8 then juke_track = 8 end
      elseif fields.track_9 then juke_track = 9 end
      elseif ded then func = function(name, param)
      minetest.chat_send_all(field)
         end       
      end
   end
end       
)
help pls ty in advance
 

User avatar
ulla
Member
 
Posts: 35
Joined: Wed Feb 04, 2015 09:22
GitHub: IIIullaIII
IRC: ulla
In-game: ulla

Re: Post your modding questions here

by ulla » Sat Jan 14, 2017 00:06

ulla wrote:
orwell wrote:
ulla wrote:HI all
I need to assign functions to my formspec
the function minetest.play_sound
track_1,2,3 ........... to 1,2,3 buttons, ...............
and minetest.stop_sound for the STOP button
Image
EXIT button works well, but only that :-P]]
For try the mod and help me you can download mod prewiev
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
https://www.dropbox.com/sh/82mmlx3bulbdngo/AABSjkhq_mud_-yIAsmOCAlOa?dl=0

SEE first the README

To assign functions to buttons, you need to use minetest.register_on_player_receive_fields().
If a player clicks a button on the client, this event gets sent to server. Every button has an internal name, this will be its name in the 'fields' table. When that button was pressed, its 'fields' entry is (evaluates to) true.
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_player_receive_fields(function(player, formname, fields)
  if formname=="<your formname>" then
    if fields.quit then
      --escape was pressed
    elseif fields.<name of first button> then
       --the first button was pressed
    elseif fields.<name of second button> then
       --the second one was pressed
    [...]
    end
  end
end)

Of course without the <>, just simple lua table indexing.
You can also read the contents of text fields here:
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
local contents_of_text_field = fields.<name of text field>

TY for answer and sorry for my english is my first problem i need big time for understand english tutor/ial :-) and the guides for formspec are mutch inexplicative :-( (for me :-P) this is my 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
local function play_track(pos, track)
   return minetest.sound_play("juke_track_"..tostring(track),
         {pos = pos, gain = 1.0, loop = true, max_hear_distance = 72,})
end
local function stop_player(pos, node)
   local pos_hash = minetest.hash_node_position(pos)
   local music_handle = music_handles[pos_hash]
   if music_handle then
      minetest.sound_stop(music_handle)
      music_handles[pos_hash] = nil
   end
end
-- Show form when the /formspec command is used.
minetest.register_chatcommand("juke", {
   func = function(name, param)
      minetest.show_formspec(name, "jukebox:form",
            "size[4.0,4.5]" ..
                "background[-0,-0;4,4.5;juke_bag.png]"..
                "label[0,0;CIAO!!!, " .. name .. "]" ..
               "field[0.3,2.5;4,1;ded;" .. name .. ", DEDICA;]" ..
                "button[1,0.3;2,1;stop;STOP!]"..
                "button[0,1;1,1;track_1;1]"..
                "button[1,1;1,1;track_2;2]"..
             "button[2,1;1,1;track_3;3]"..
             "button[3,1;1,1;track_4;4]"..
                "button[0,3;1,1;track_5;5]"..
                "button[1,3;1,1;track_6;6]"..
             "button[2,3;1,1;track_7;7]"..
             "button[3,3;1,1;track_8;8]"..
            "button_exit[1,3.7;2,1;exit;EXIT]")
                   end
   
})
minetest.register_on_player_receive_fields(function(player, formname, fields)
  if formname=="jukebox:form"
   
     
    local stop_player = 0 
    local " .. name .. ", DEDICA = fields.ded
   local juke_track = nil
      if fields.stop then juke_track = 0 end
      elseif fields.track_1 then juke_track_ = 1 end
      elseif fields.track_2 then juke_track_ = 2 end
      elseif fields.track_3 then juke_track = 3 end
      elseif fields.track_4 then juke_track = 4 end
      elseif fields.track_5 then juke_track = 5 end
      elseif fields.track_6 then juke_track = 6 end
      elseif fields.track_7 then juke_track = 7 end
      elseif fields.track_8 then juke_track = 8 end
      elseif fields.track_9 then juke_track = 9 end
      elseif ded then func = function(name, param)
      minetest.chat_send_all(field)
         end       
      end
   end
end       
)
help pls ty in advance

resolved thank's all for answer
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 8 guests

cron