Post your modding questions here

User avatar
srifqi
Member
 
Posts: 508
Joined: Sat Jun 28, 2014 04:31
GitHub: srifqi
IRC: srifqi
In-game: srifqi

Re: Post your modding questions here

by srifqi » Thu Dec 11, 2014 06:13

Thanks for reply!
I'm from Indonesia! Saya dari Indonesia!
Terjemahkan Minetest!
Mods by me. Modifikasi oleh saya.

Pronounce my nick as in: es-rifqi (IPA: /es rifˈki/)
 

leeminer
Member
 
Posts: 90
Joined: Mon Aug 11, 2014 21:29

Re: Post your modding questions here

by leeminer » Sat Dec 13, 2014 04:08

Is there a way to make a player, invisible? This could be a cool game mechanic or even be used as a way to be an invisible dungeon master, so to speak.

It would be fun to float around, spawn mobs and make life hell for players.
 

User avatar
Merlin
Member
 
Posts: 63
Joined: Tue Dec 09, 2014 22:07
GitHub: sct-0
In-game: my

Re: Post your modding questions here

by Merlin » Sat Dec 13, 2014 16:03

Hi,
I wanted to make a mod with a liquid.
I looked at the minetest.register_node of water/lava in the nodes.lua of the minetest game, and defined my liquid with similiar attributes.
Only problem is: The liquid source does not...well...produce liquid, it just stands there like a normal node.
I tried finding a part of code which looks like it makes the water/lava sources spread their respective liquid, but I found nothing.

Here's 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
oil_VISC = 1

minetest.register_node("dystopia:rohoel_source", {
   tiles = {"rohoel_source.png"},
   walkable = false,
   pointable = false,
   diggable = false,
   buildable_to = true,
   drop = "",
   drowning = 1,
   liquidtype = "source",
   groups = {water=3, liquid=3, flammable=3},
})


minetest.register_node("dystopia:rohoel_flowing", {
   tiles = {"rohoel_source.png"},
   paramtype = "flowingliquid",
   walkable = false,
   pointable = false,
   diggable = false,
   buildable_to = true,
   drop = "",
   drowning = 1,
   liquidtype = "flowing",
   groups = {water=3, liquid=3, flammable=10},
})


Can someone tell me how to make the stuff spread/flow?
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Post your modding questions here

by Krock » Sat Dec 13, 2014 16:14

Merlin wrote:Can someone tell me how to make the stuff spread/flow?

You need on define a flowing liquid.
Use those codes for it:
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
   drawtype = "flowingliquid",
   liquid_alternative_flowing = "dystopia:rohoel_flowing",
   liquid_alternative_source = "dystopia:rohoel_source",

Also define "liquid_alternative_flowing/source" in your liquid source node.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
Don
Member
 
Posts: 1641
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: Post your modding questions here

by Don » Sat Dec 13, 2014 16:21

Here is the code for an oil mod I was working on. Hope it helps.
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("mystreets:oil_flowing", {
   description = "Flowing Oil",
   inventory_image = minetest.inventorycube("mystreets_oil.png"),
   drawtype = "flowingliquid",
   tiles = {"mystreets_oil.png"},
   special_tiles = {
      {
         image="mystreets_oil_flowing_animated.png",
         backface_culling=false,
         animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=4.0}
      },
      {
         image="mystreets_oil_flowing_animated.png",
         backface_culling=true,
         animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=4.0}
      },
   },
   alpha = 250,
   paramtype = "light",
   paramtype2 = "flowingliquid",
   walkable = false,
   pointable = false,
   diggable = false,
   buildable_to = true,
   drop = "",
   drowning = 1,
   liquidtype = "flowing",
   liquid_alternative_flowing = "mystreets:oil_flowing",
   liquid_alternative_source = "mystreets:oil_source",
   liquid_viscosity = 3,
   liquid_renewable = false,
   liquid_range = 3,
   post_effect_color = {a=250, r=0, g=0, b=0},
   groups = {liquid=3, not_in_creative_inventory=1},
})

minetest.register_node("mystreets:oil_source", {
   description = "Oil Source",
   inventory_image = minetest.inventorycube("mystreets_oil.png"),
   drawtype = "liquid",
   light_source = 14,
   tiles = {
      {name="mystreets_oil_source_animated.png"}
   },
   special_tiles = {
      {
         name="mystreets_oil_source_animated.png",
         animation={type="vertical_frames", aspect_w=16, aspect_h=16, length=4.0},
         backface_culling = false,
      }
   },
   alpha = 250,
   paramtype = "light",
   walkable = false,
   pointable = true,
   diggable = true,
   buildable_to = true,
   drop = "mystreets:oil",
   drowning = 1,
   liquidtype = "source",
   liquid_alternative_flowing = "mystreets:oil_flowing",
   liquid_alternative_source = "mystreets:oil_source",
   liquid_viscosity = 3,
   liquid_renewable = false,
   liquid_range = 2,
   damage_per_second = 1,
   post_effect_color = {a=250, r=0, g=0, b=0},
   groups = {liquid=3, crumbly=2, not_in_creative_inventory=1},
})
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here
 

User avatar
Merlin
Member
 
Posts: 63
Joined: Tue Dec 09, 2014 22:07
GitHub: sct-0
In-game: my

Re: Post your modding questions here

by Merlin » Sun Dec 14, 2014 13:18

Thanks you two, liquid's now happily flow around. :D
 

User avatar
pandaro
Member
 
Posts: 266
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro

Re: Post your modding questions here

by pandaro » Thu Dec 18, 2014 18:12

Hi all,
I want to change the size of the inventory of the player.
Is there a limit to the size of the inventory?
I can exceed 32 slot?
for example:
'list [current_player; main; 0.5; 10.5;]'
 

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 Dec 18, 2014 19:57

pandaro wrote:Hi all,
I want to change the size of the inventory of the player.
Is there a limit to the size of the inventory?
I can exceed 32 slot?
for example:
'list [current_player; main; 0.5; 10.5;]'

Yes, you need to set the size of the "main" list in the player's inventory. For example, from an `on_joinplayer` callback:

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_joinplayer(function(player)
  local inv = player:get_inventory()
  inv:set_size("main", 50)
end)
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
pandaro
Member
 
Posts: 266
Joined: Sun Jan 08, 2012 21:34
GitHub: pandaro

Re: Post your modding questions here

by pandaro » Thu Dec 18, 2014 20:04

kaeza wrote:
pandaro wrote:Hi all,
I want to change the size of the inventory of the player.
Is there a limit to the size of the inventory?
I can exceed 32 slot?
for example:
'list [current_player; main; 0.5; 10.5;]'

Yes, you need to set the size of the "main" list in the player's inventory. For example, from an `on_joinplayer` callback:

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_joinplayer(function(player)
  local inv = player:get_inventory()
  inv:set_size("main", 50)
end)


Thanks Kaeza, it works
 

leeminer
Member
 
Posts: 90
Joined: Mon Aug 11, 2014 21:29

Re: Post your modding questions here

by leeminer » Sat Dec 20, 2014 12:45

I can't believe I have to ask, *bangs head on desk* but here goes.

minetest.register_chat_command

Not working.

Code below, but one thing I struggle with is the parameter after the command. For example I want to enter the command like this "/jump 5". I want that command to set the set_physics_overide to jump value 5. However I don't see a variable in the register_chat_command for variables.

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_chat_command("jump", {
params="Enter a value to increase jump height",
description="Speed: Modify the speed of the player",
func = function(name,param)
   local player=minetest.get_player_by_name(name)
   if not player then
      return false, "Player not found"
   end
   player:set_physics_override(jump=param)

)


/time is a good example where it takes a variable. I looked at the wiki and there doesn't seem to be an example for this scenario. When I get an answer can I add the example to the wiki or does someone else have to ?
 

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

Re: Post your modding questions here

by Hybrid Dog » Sat Dec 20, 2014 12:52

leeminer wrote:I can't believe I have to ask, *bangs head on desk* but here goes.

minetest.register_chat_command

Not working.

Code below, but one thing I struggle with is the parameter after the command. For example I want to enter the command like this "/jump 5". I want that command to set the set_physics_overide to jump value 5. However I don't see a variable in the register_chat_command for variables.

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_chat_command("jump", {
params="Enter a value to increase jump height",
description="Speed: Modify the speed of the player",
func = function(name,param)
   local player=minetest.get_player_by_name(name)
   if not player then
      return false, "Player not found"
   end
   player:set_physics_override(jump=param)

)


/time is a good example where it takes a variable. I looked at the wiki and there doesn't seem to be an example for this scenario. When I get an answer can I add the example to the wiki or does someone else have to ?

l saw that you forgot the brackets of the table.
Here's an example https://github.com/HybridDog/extrablock ... mt.lua#L51

And before player:set_physics_override({jump=param}) l would add
param = tonumber(param)
if not param then
return
end
 

leeminer
Member
 
Posts: 90
Joined: Mon Aug 11, 2014 21:29

Re: Post your modding questions here

by leeminer » Sat Dec 20, 2014 13:00

Well, debug.txt has a new error.
Bad news is, its useless to me.

"06:58:34: ERROR[main]: ======= END OF ERROR FROM LUA ========
06:58:34: ERROR[main]: Server: Failed to load and run C:\Users\Elissa\Desktop\Lee\minetest-0.4.10\bin\..\mods\leemod\init.lua
06:58:34: ERROR[main]: ModError: ModError: Failed to load and run C:\Users\Elissa\Desktop\Lee\minetest-0.4.10\bin\..\mods\leemod\init.lua"
 

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

Re: Post your modding questions here

by Hybrid Dog » Sat Dec 20, 2014 14:22

leeminer wrote:Well, debug.txt has a new error.
Bad news is, its useless to me.

"06:58:34: ERROR[main]: ======= END OF ERROR FROM LUA ========
06:58:34: ERROR[main]: Server: Failed to load and run C:\Users\Elissa\Desktop\Lee\minetest-0.4.10\bin\..\mods\leemod\init.lua
06:58:34: ERROR[main]: ModError: ModError: Failed to load and run C:\Users\Elissa\Desktop\Lee\minetest-0.4.10\bin\..\mods\leemod\init.lua"

to me it's useless, too
 

gamemanj
Member
 
Posts: 10
Joined: Fri Dec 19, 2014 13:21
GitHub: gamemanj
IRC: gamemanj
In-game: gamemanj

Re: Post your modding questions here

by gamemanj » Sat Dec 20, 2014 20:33

leeminer wrote:Well, debug.txt has a new error.
Bad news is, its useless to me.

"06:58:34: ERROR[main]: ======= END OF ERROR FROM LUA ========
06:58:34: ERROR[main]: Server: Failed to load and run C:\Users\Elissa\Desktop\Lee\minetest-0.4.10\bin\..\mods\leemod\init.lua
06:58:34: ERROR[main]: ModError: ModError: Failed to load and run C:\Users\Elissa\Desktop\Lee\minetest-0.4.10\bin\..\mods\leemod\init.lua"

Do you have the part above "END OF ERROR FROM LUA"?
(I think the phrase "END OF ERROR" should have tipped you off,but anyway...)
TODO: Something that gives me a reason to put something in the signature
 

User avatar
philipbenr
Member
 
Posts: 1665
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: WisdomFire or philipbenr

Re: Post your modding questions here

by philipbenr » Sat Dec 20, 2014 22:57

Yes, you should include that in the error report. That is where everything important for debugging is.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Post your modding questions here

by rubenwardy » Sun Dec 21, 2014 12:32

It is register_chatcommand, not register_chat_command. Just in case.

Use tonumber() to convert the param to a number - jump = tonumber(param)
 

User avatar
DeepGaze
Member
 
Posts: 332
Joined: Fri May 10, 2013 00:49
GitHub: DeepGaze
IRC: DeepGaze
In-game: DeepGaze

Re: Post your modding questions here

by DeepGaze » Mon Dec 22, 2014 00:51

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
xyz = "<X>,<Y>,<Z>"
minetest.register_alias("device", "quiet:console")
minetest.register_chatcommand("xyz", {
   params = "<X>,<Y>,<Z>",
    description = "set destination for console",
    func = function(name, param)
        xyz = params
        minetest.chat_send_all(name.." sets the value to "..param)
    end,
})
minetest.register_node("quiet:console", {
      texture = "png.png"
  on_punch = function(name, xyz)
      local function find_free_position_near(xyz)
         local tries = {
            {x=1,y=0,z=0},
            {x=-1,y=0,z=0},
            {x=0,y=0,z=1},
            {x=0,y=0,z=-1},
         }
         for _, d in ipairs(tries) do
            local p = {x = pos.x+d.x, y = pos.y+d.y, z = pos.z+d.z}
            local n = core.get_node_or_nil(p)
            if n and n.name then
               local def = core.registered_nodes[n.name]
               if def and not def.walkable then
                  return p, true
               end
            end
         end
         return pos, false
      end
   end
})

I can't seem to make this work. It runs registering a bock and a command but they ignore each other refusing to teleport me.
there's no place like 127.0.0.1
The deep life Minetest text page
minetest cards
 

User avatar
Casimir
Member
 
Posts: 1101
Joined: Fri Aug 03, 2012 16:59

Re: Post your modding questions here

by Casimir » Mon Dec 22, 2014 06:55

In on_punch you register a local function but don't call it. Remove the line whith local function and the end.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Post your modding questions here

by Krock » Mon Dec 22, 2014 07:37

DeepGaze wrote:
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
xyz = "<X>,<Y>,<Z>"
...
    func = function(name, param)
->        xyz = params
          minetest.chat_send_all(name.." sets the value to "..param)

You set it to a nil value.
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

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

Re: Post your modding questions here

by Hybrid Dog » Mon Dec 22, 2014 12:34

Krock wrote:
DeepGaze wrote:
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
xyz = "<X>,<Y>,<Z>"
...
    func = function(name, param)
->        xyz = params
          minetest.chat_send_all(name.." sets the value to "..param)

You set it to a nil value.

and pos is nil, too (or should be nil)
 

leeminer
Member
 
Posts: 90
Joined: Mon Aug 11, 2014 21:29

Re: Post your modding questions here

by leeminer » Mon Dec 22, 2014 16:41

Thanks all I really appreciate it. I caught the register_chat_command error on my part, should be register_chatcommand.

I fixed that but still problems, I will use your other suggestions and keep you updated. Feel so frustrated becasue this SHOULD be so easy. But I guess its part of the learning process..

Will try at home later and update you all on this.

Once I figure something out I like to share so others don't go through this pain ;)
 

User avatar
DeepGaze
Member
 
Posts: 332
Joined: Fri May 10, 2013 00:49
GitHub: DeepGaze
IRC: DeepGaze
In-game: DeepGaze

Re: Post your modding questions here

by DeepGaze » Mon Dec 22, 2014 20:03

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 PLAYER_COOLDOWN = 1
minetest.register_alias("device", "quiet:key")
minetest.register_chatcommand("xyz", {
   params = "<X>,<Y>,<Z>",
    description = "set xyzination for console",
    func = function(name, param)
        xyz = param
        minetest.chat_send_all(name.." sets the value to "..param)
    end,
})

minetest.register_tool("quiet:key", {
      texture = "png.png",
   tool_capabilities = {},
   on_use = function(itemstack, user, pos, xyz)
         local xyz = {param}
         user:setpos(xyz)
      end
})

minetest.register_chatcommand("sos", {
   description = "save you from falling into nil",
   func = function(pos, name)
   name:setpos({x = 0, y = 0, z = 0})
end
})

I am still confused
+ also does anyone recognise this coding language
there's no place like 127.0.0.1
The deep life Minetest text page
minetest cards
 

User avatar
DeepGaze
Member
 
Posts: 332
Joined: Fri May 10, 2013 00:49
GitHub: DeepGaze
IRC: DeepGaze
In-game: DeepGaze

Re: Post your modding questions here

by DeepGaze » Mon Dec 22, 2014 20:05

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 PLAYER_COOLDOWN = 1
minetest.register_alias("device", "quiet:key")
minetest.register_chatcommand("xyz", {
   params = "<X>,<Y>,<Z>",
    description = "set xyzination for console",
    func = function(name, param)
        xyz = param
        minetest.chat_send_all(name.." sets the value to "..param)
    end,
})

minetest.register_tool("quiet:key", {
      texture = "png.png",
   tool_capabilities = {},
   on_use = function(itemstack, user, pos, xyz)
         local xyz = {param}
         user:setpos(xyz)
      end
})

minetest.register_chatcommand("sos", {
   description = "save you from falling into nil",
   func = function(pos, name)
   name:setpos({x = 0, y = 0, z = 0})
end
})

I am still confused
+ also does anyone recognise this coding language
there's no place like 127.0.0.1
The deep life Minetest text page
minetest cards
 

User avatar
AMMOnym
Member
 
Posts: 682
Joined: Tue Sep 10, 2013 14:18
IRC: AMMOnym
In-game: AMMOnym

Re: Post your modding questions here

by AMMOnym » Tue Dec 23, 2014 11:17

Hello there,
Each generating is made in "y line" which means height, so I have question. Is possible to make genereating in "x/z line" ?
Image

1- Spawn point / 0
2- x=posx+200, z=posz+200
3- x=posx+400, z=posz+400
4- x=posx+600, z=posz+600

So someone can generate ores in distance 200 - 400 from spawn etc.
 

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

Re: Post your modding questions here

by Hybrid Dog » Tue Dec 23, 2014 12:54

AMMOnym wrote:Hello there,
Each generating is made in "y line" which means height, so I have question. Is possible to make genereating in "x/z line" ?
Image

1- Spawn point / 0
2- x=posx+200, z=posz+200
3- x=posx+400, z=posz+400
4- x=posx+600, z=posz+600

So someone can generate ores in distance 200 - 400 from spawn etc.

Of course, yes, you could also e.g. generate sea everywhere at math.hypot(x,z) > 1000.
 

User avatar
AMMOnym
Member
 
Posts: 682
Joined: Tue Sep 10, 2013 14:18
IRC: AMMOnym
In-game: AMMOnym

Re: Post your modding questions here

by AMMOnym » Tue Dec 23, 2014 17:26

Hybrid Dog wrote:
AMMOnym wrote:Hello there,
Each generating is made in "y line" which means height, so I have question. Is possible to make genereating in "x/z line" ?
Image

1- Spawn point / 0
2- x=posx+200, z=posz+200
3- x=posx+400, z=posz+400
4- x=posx+600, z=posz+600

So someone can generate ores in distance 200 - 400 from spawn etc.

Of course, yes, you could also e.g. generate sea everywhere at math.hypot(x,z) > 1000.

Thanks a lot, can you show me any mod, which use that ? It will help me a lot
 

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

Re: Post your modding questions here

by Hybrid Dog » Tue Dec 23, 2014 20:42

AMMOnym wrote:
Hybrid Dog wrote:
AMMOnym wrote:Hello there,
Each generating is made in "y line" which means height, so I have question. Is possible to make genereating in "x/z line" ?
Image

1- Spawn point / 0
2- x=posx+200, z=posz+200
3- x=posx+400, z=posz+400
4- x=posx+600, z=posz+600

So someone can generate ores in distance 200 - 400 from spawn etc.

Of course, yes, you could also e.g. generate sea everywhere at math.hypot(x,z) > 1000.

Thanks a lot, can you show me any mod, which use that ? It will help me a lot

Maybe this one
viewtopic.php?f=11&t=8066
or
viewtopic.php?f=11&t=6128
 

aliyahjack
New member
 
Posts: 1
Joined: Fri Dec 26, 2014 13:50

Re: Rip-off

by aliyahjack » Fri Dec 26, 2014 14:41

Lets say I wanted to suggest new mobs or something, how do you make/what program do you use to make the graphics and is there a scripting/coding tutorial here?
aliyah
 

leeminer
Member
 
Posts: 90
Joined: Mon Aug 11, 2014 21:29

Re: Post your modding questions here

by leeminer » Wed Dec 31, 2014 11:51

Still trying to understand register_chatcommand

Here are two examples from worldedit mod.

minetest.register_chatcommand("/unmark", {
params = "",
description = "Hide markers if currently shown",
privs = {worldedit=true},
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
worldedit.pos1[name] = nil
worldedit.pos2[name] = nil
worldedit.mark_pos1(name)
worldedit.mark_pos2(name)
worldedit.pos1[name] = pos1
worldedit.pos2[name] = pos2
worldedit.player_notify(name, "region unmarked")
end,
})

minetest.register_chatcommand("/pos1", {
params = "",
description = "Set WorldEdit region position 1 to the player's location",
privs = {worldedit=true},
func = function(name, param)





What I don't understand so far is why the functioins don't do anything. Seems like a half baked function definition...


Here is an example from the ambiance mod

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_chatcommand("mvol", {
   params = "<mvol>",
   description = "set volume of music, default 1 normal volume.",
   privs = {server=true},
   func = function(name, param)




How does the command, actually change the volume? This is bugging me ;)
 

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

Re: Post your modding questions here

by Hybrid Dog » Wed Dec 31, 2014 12:52

leeminer wrote:Still trying to understand register_chatcommand

Here are two examples from worldedit mod.

minetest.register_chatcommand("/unmark", {
params = "",
description = "Hide markers if currently shown",
privs = {worldedit=true},
func = function(name, param)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
worldedit.pos1[name] = nil
worldedit.pos2[name] = nil
worldedit.mark_pos1(name)
worldedit.mark_pos2(name)
worldedit.pos1[name] = pos1
worldedit.pos2[name] = pos2
worldedit.player_notify(name, "region unmarked")
end,
})

minetest.register_chatcommand("/pos1", {
params = "",
description = "Set WorldEdit region position 1 to the player's location",
privs = {worldedit=true},
func = function(name, param)





What I don't understand so far is why the functioins don't do anything. Seems like a half baked function definition...


Here is an example from the ambiance mod

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_chatcommand("mvol", {
   params = "<mvol>",
   description = "set volume of music, default 1 normal volume.",
   privs = {server=true},
   func = function(name, param)




How does the command, actually change the volume? This is bugging me ;)

It runs the function func, which sets the musicvolume, which is also used by other functions, to param.
https://github.com/HybridDog/MinetestAm ... t.lua#L754
 

PreviousNext

Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 8 guests

cron