Page 48 of 169

Re: Comand for suicide

PostPosted: Thu Jun 26, 2014 16:40
by BrunoMine
Krock wrote:
brunob.santos wrote:there is a command for suicide? Can you show me?

Code: Select all
minetest.register_chatcommand("killme", {
   description = "Kills you",
   func = function(name, param)
      local player = minetest.get_player_by_name(name)
      player:set_hp(0)
   end
})


as if I would want that the player has an empty inventory?

Code: Select all
minetest.register_chatcommand("killme", {
   description = "Kills you",
   func = function(name, param)
      local player = minetest.get_player_by_name(name)
      local invref = player:get_inventory()
      local size = invref:get_size(name)   
          if size == nil then
              player:setpos({x = 100, y = 20, z = 100})
          end
          if size ~= nil then
              player:set_hp(0)
    end
end})

*did not work. Help!
This will serve to fix a bug (to be so)

Re: Post your modding questions here

PostPosted: Thu Jun 26, 2014 17:15
by drkwv
1. Can I rotate nodebox without rotating textures? Or rotate textures not touching the nodebox. Brick textures are drawed in a way that does not allow any texture rotating.
2. Default brick stairs are glowing in the night on the brick background because of paramtype = "light". Is there a way to fix this glowing for my nodebox brick nodes without affecting the lighting?

Re: Post your modding questions here

PostPosted: Thu Jun 26, 2014 20:43
by ZOOOO
Is it possible to make player names not render if there is no direct sight to it? (e.g. two players separated by a solid wall)

Re: Post your modding questions here

PostPosted: Fri Jun 27, 2014 13:05
by Krock
ZOOOO wrote:Is it possible to make player names not render if there is no direct sight to it? (e.g. two players separated by a solid wall)

This is not possible with the current Lua API. Checking if it's glass or stone in between the two positions (other player and me) would require too much calculations.

Re: Post your modding questions here

PostPosted: Fri Jun 27, 2014 13:11
by drkwv
Krock wrote:Checking if it's glass or stone in between the two positions (other player and me) would require too much calculations.

As for me (nobody asked, but anyway), it's ok to not to see a nickname through the glass.

Also, player is not too big, so one can set nicknames not visible by default, then draw an imaginary line from current pos to player pos and check for an obstacles every, say 1 second (because it's okay to not to show nicknames immediately in realtime too!) and then decide if show nickname or not. If, for example, you decide to show nickname but player is not visible at this particular moment, it's okay to show his nickname for a second too, because it will just mean that you spotted him a moment before. So, I probably think that performance is not the problem at all in this type of task.

And you also could use a random probability of showing nickname in situations where it's not clear about how much % of player behind blocks is visible, so people would have a chance to play hide-and-seek still. The main rule is: you're not trying to hide nickname by cycling through all possible situations, you decide a few situations when there is clearly that you need to show it. It can be shown even using timeouts if there is many players around and you have problems with performance (or change checking time interval from 1 to 2 secs). There is no need for high-performant realtime players pos tracking.

Re: Post your modding questions here

PostPosted: Fri Jun 27, 2014 13:29
by BrunoMine

Re: Post your modding questions here

PostPosted: Fri Jun 27, 2014 14:22
by golthem
Hello!

I'm trying to make a new crafting type for my mod but I'm have some problems, I started out trying to use the crafter mod but that's not working for me, what's the best way to create a new crafting type that a node can use?

Re: Post your modding questions here

PostPosted: Sat Jun 28, 2014 18:49
by ZOOOO
Krock wrote:
ZOOOO wrote:Is it possible to make player names not render if there is no direct sight to it? (e.g. two players separated by a solid wall)

This is not possible with the current Lua API. Checking if it's glass or stone in between the two positions (other player and me) would require too much calculations.

Do you know which source file has code for rendering players? I have not been able to find it.

Can I use third party libraries in mods?

EDIT.Accidentally pushed submit button
EDIT2. Added another question

overlay textures with diffrent resolutions

PostPosted: Sun Jun 29, 2014 09:39
by addi
i know the questions was answered somewhere in the board, but i cant find it anymore

i have 2 textures i want to overlay:

default_stone.png (16x16)
my_texture.png (64x64)

if i using this: default_stone.png^my_texture.png

it does only show a part of my_texture.png

im happy for each tip i can get. thanks in advance

Re: overlay textures with diffrent resolutions

PostPosted: Sun Jun 29, 2014 14:16
by stu
addi wrote:i know the questions was answered somewhere in the board, but i cant find it anymore

i have 2 textures i want to overlay:

default_stone.png (16x16)
my_texture.png (64x64)

if i using this: default_stone.png^my_texture.png

it does only show a part of my_texture.png

im happy for each tip i can get. thanks in advance


You could use [combine to overlay the 16x16 image at a specific location on the 64x64 image but this is probably not what you want and scaling is not currently supported. There was, however, a pull request sometime ago for a scaling version of [combine this was closed fairly recently.

Another option might be to use a third-party image lib like Lua-GD

Re: Post your modding questions here

PostPosted: Sun Jun 29, 2014 17:49
by addi
ok lots of thanks
than i must look for another way

Re: Post your modding questions here

PostPosted: Wed Jul 02, 2014 18:46
by Kilarin
Stupid question time again.
How do I make an error beep? I can find plenty of examples of how to set a sound for a node being walked on or a node being broken, but I can't find an example of just making an "BEEP!" when the user does something wrong.

Re: Post your modding questions here

PostPosted: Wed Jul 02, 2014 19:08
by Calinou
Kilarin wrote:Stupid question time again.
How do I make an error beep? I can find plenty of examples of how to set a sound for a node being walked on or a node being broken, but I can't find an example of just making an "BEEP!" when the user does something wrong.


Code: Select all
minetest.sound_play("beep", {gain = 0.5})

or
Code: Select all
minetest.sound_play("beep", {gain = 0.5, pos = player:getpos()})


You need a beep.ogg sound (in mono, not in stereo). gain changes the volume. pos determines the position; if unset, the sound is played position-less throughout the world. Else, the sound will be played near the player, with other players nearby also hearing it (slightly).

When testing sounds, be sure to lower the sound volume (through the game, through the OS or through the hardware), to not end up hearing excessively loud sounds.

Re: Post your modding questions here

PostPosted: Wed Jul 02, 2014 20:23
by Kilarin
Thank you very much Calinou!

Re: Post your modding questions here

PostPosted: Thu Jul 03, 2014 06:40
by srifqi
Topic: How to use minetest.register_on_generated?
Reason: I want to make a mod.
More Info: I've tried but I don't know how.

Anyone know why this doesn't work (no error reported).
EDIT:
What's wrong with this code?
Why it can not run in singlenode map?
Code: Select all
minetest.register_on_generated(function(minp, maxp, seed)
   if minp.y < -50 or maxp.y > 50 then
      return
   end
   for x = minp.x, maxp.x do
   for z = minp.z, maxp.z do
      if(minetest.get_node({x = x, y = 0, z = z}).name~="default:cobble") then
         minetest.set_node({x = x, y = 1, z = z}, {name="default:dirt_with_grass"})
         minetest.set_node({x = x, y = 0, z = z}, {name="default:cobble"})
      end
   end
   end
end)

Gracefully replace node upon digging?

PostPosted: Sat Jul 05, 2014 17:35
by drkwv
Is there a way to tell the client that i'm going to replace the block upon digging? In my mod I use several nodes for damage levels, but a lag between node digging and replacing is noticeable even on my local machine.

Re: Post your modding questions here

PostPosted: Sat Jul 05, 2014 20:14
by prestidigitator
srifqi wrote:Topic: How to use minetest.register_on_generated?
Reason: I want to make a mod.
More Info: I've tried but I don't know how.

Anyone know why this doesn't work (no error reported)

Are you sure it doesn't work? "Generated" means blocks of the map newly created. This means it happens when they are visited for the first time. It won't just change existing pieces of the already generated map (which are loaded from the database, not "generated"). If you use this on an existing world, you will have to travel out to someplace where the map hasn't yet been generated. Otherwise, try it on a brand new world, where the mod is enabled prior to you first logging into it.

Re: Post your modding questions here

PostPosted: Sat Jul 05, 2014 20:15
by acblonde
how do you enable a mod

Re: Post your modding questions here

PostPosted: Sat Jul 05, 2014 20:53
by Casimir
When installed correctly, select a world, click "configure", double click the mod you want to enable, then save. See also: http://wiki.minetest.net/Installing_Mods

Re: Post your modding questions here

PostPosted: Sat Jul 05, 2014 21:24
by webdesigner97
Is it possible to completely disable damage within a game without having to rely on the mainmenu option?

Re: Gracefully replace node upon digging?

PostPosted: Sat Jul 05, 2014 21:30
by prestidigitator
drkwv wrote:Is there a way to tell the client that i'm going to replace the block upon digging? In my mod I use several nodes for damage levels, but a lag between node digging and replacing is noticeable even on my local machine.


I assume you've tried the after_dig_node() callback? If that's not fast enough (it does remove the node before making the callback, you might need to us on_dig() instead. If you don't set this callback, the default is minetest.node_dig(). Examine that function's logic carefully in builtin/item.lua (or builtin/game/item.lua now, I guess) so you know everything your replacement callback might have to do. You'll want to have it call minetest.set_node() or minetest.swap_node() instead of minetest.remove_node().

Interesting thought. It would be a simple enough game feature to add some kind of "dig_replacement" property to the node definition and have minetest.node_dig() check for this property and do a replacement rather than a remove if it exists. A mod could replace that function, but it would be a pain to maintain it in parallel with the game code over time.

Re: Post your modding questions here

PostPosted: Sun Jul 06, 2014 07:42
by srifqi
prestidigitator wrote:try it on a brand new world, where the mod is enabled prior to you first logging into it.


If I use singlenode or math mapgen, it doesn't work (and causing server crash).
But, if i use v6, v7, or indev mapgen, it works.

Re: Post your modding questions here

PostPosted: Sun Jul 06, 2014 08:35
by prestidigitator
srifqi wrote:If I use singlenode or math mapgen, it doesn't work (and causing server crash).
But, if i use v6, v7, or indev mapgen, it works.

Huh. Well, I'm thinking the singlenode and math mapgens don't use those nodes, but it still seems strange that you can't from a mod and that it'll cause a crash. Hmm. It's supposed to be slower outside the on_generated callback, but I'm wondering if it will cause the same crash. You might want to try registering your node changes to be called "later". For example:

Code: Select all
minetest.register_on_generated(
   function(minp, maxp, seed)
      minetest.after(0.1, myOnGeneratedCallbackFunction, minp, maxp, seed);
   end);


Either way it sounds like a defect to me. Does it spit out an error message like it usually does if a mod has an error (e.g. indexing a nil value), or just die without explanation?

Re: Post your modding questions here

PostPosted: Mon Jul 07, 2014 04:22
by srifqi
prestidigitator wrote:Does it spit out an error message like it usually does if a mod has an error (e.g. indexing a nil value), or just die without explanation?


I just type "/grant singleplayer all" and no result from server.
Is it server crash or server lag?

Re: Post your modding questions here

PostPosted: Mon Jul 07, 2014 08:32
by prestidigitator
srifqi wrote:I just type "/grant singleplayer all" and no result from server.
Is it server crash or server lag?

Where did you start the server? Can you see any error output in the console there, or in the log file? If you don't have access to the server, it might be difficult to debug server problems....