Page 52 of 125

Re: Post your modding questions here

PostPosted: Thu Dec 11, 2014 06:13
by srifqi
Thanks for reply!

Re: Post your modding questions here

PostPosted: Sat Dec 13, 2014 04:08
by leeminer
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.

Re: Post your modding questions here

PostPosted: Sat Dec 13, 2014 16:03
by Merlin
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?

Re: Post your modding questions here

PostPosted: Sat Dec 13, 2014 16:14
by Krock
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.

Re: Post your modding questions here

PostPosted: Sat Dec 13, 2014 16:21
by Don
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},
})

Re: Post your modding questions here

PostPosted: Sun Dec 14, 2014 13:18
by Merlin
Thanks you two, liquid's now happily flow around. :D

Re: Post your modding questions here

PostPosted: Thu Dec 18, 2014 18:12
by pandaro
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;]'

Re: Post your modding questions here

PostPosted: Thu Dec 18, 2014 19:57
by kaeza
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)

Re: Post your modding questions here

PostPosted: Thu Dec 18, 2014 20:04
by pandaro
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

Re: Post your modding questions here

PostPosted: Sat Dec 20, 2014 12:45
by leeminer
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 ?

Re: Post your modding questions here

PostPosted: Sat Dec 20, 2014 12:52
by Hybrid Dog
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

Re: Post your modding questions here

PostPosted: Sat Dec 20, 2014 13:00
by leeminer
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"

Re: Post your modding questions here

PostPosted: Sat Dec 20, 2014 14:22
by Hybrid Dog
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

Re: Post your modding questions here

PostPosted: Sat Dec 20, 2014 20:33
by gamemanj
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...)

Re: Post your modding questions here

PostPosted: Sat Dec 20, 2014 22:57
by philipbenr
Yes, you should include that in the error report. That is where everything important for debugging is.

Re: Post your modding questions here

PostPosted: Sun Dec 21, 2014 12:32
by rubenwardy
It is register_chatcommand, not register_chat_command. Just in case.

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

Re: Post your modding questions here

PostPosted: Mon Dec 22, 2014 00:51
by DeepGaze
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.

Re: Post your modding questions here

PostPosted: Mon Dec 22, 2014 06:55
by Casimir
In on_punch you register a local function but don't call it. Remove the line whith local function and the end.

Re: Post your modding questions here

PostPosted: Mon Dec 22, 2014 07:37
by Krock
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.

Re: Post your modding questions here

PostPosted: Mon Dec 22, 2014 12:34
by Hybrid Dog
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)

Re: Post your modding questions here

PostPosted: Mon Dec 22, 2014 16:41
by leeminer
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 ;)

Re: Post your modding questions here

PostPosted: Mon Dec 22, 2014 20:03
by DeepGaze
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

Re: Post your modding questions here

PostPosted: Mon Dec 22, 2014 20:05
by DeepGaze
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

Re: Post your modding questions here

PostPosted: Tue Dec 23, 2014 11:17
by AMMOnym
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.

Re: Post your modding questions here

PostPosted: Tue Dec 23, 2014 12:54
by Hybrid Dog
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.

Re: Post your modding questions here

PostPosted: Tue Dec 23, 2014 17:26
by AMMOnym
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

Re: Post your modding questions here

PostPosted: Tue Dec 23, 2014 20:42
by Hybrid Dog
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

Re: Rip-off

PostPosted: Fri Dec 26, 2014 14:41
by aliyahjack
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?

Re: Post your modding questions here

PostPosted: Wed Dec 31, 2014 11:51
by leeminer
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 ;)

Re: Post your modding questions here

PostPosted: Wed Dec 31, 2014 12:52
by Hybrid Dog
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