Page 103 of 125

Re: Post your modding questions here

PostPosted: Fri Aug 05, 2016 19:48
by BrunoMine
1) Fast privilege can inhibit antcheater?
I want to allow players to run on my server, but I believe that this can open a security hole. Maybe I'm wrong and anticheater works normally.

2) It is possible to check whether it is possible to add a list of items simultaneously in the inventory of a player?

Re: Post your modding questions here

PostPosted: Fri Aug 05, 2016 23:58
by ozkur
minetest.register_node("rocket:pod", {
description = " Rocket Control Pod",
tiles = {"top.png", "pad.png", "pod.png"},
groups = {cracky = 1},
on_punch = function(pos,node,player,pointed_thing)
tank = minetest.get_node({pos.x, pos.y-1, pos.z})
engine = minetest.get_node({pos.x, pos.y-2, pos.z})
pad = minetest.get_node({pos.x, pos.y-3, pos.z})
if tank == "rocket:tankfull" and engine == "rocket:engine" and pad == "rocket:pad" then
--player:get_pos(p)
--player:set_pos({p.x, 25000, p.z})
--player:set_physics_override(1, 1, 0.17)
--player:set_sky({0, 0, 0}, "skybox"})
--minetest.remove_node({pos.x, pos.y-1, pos.z})
--minetest.remove_node({pos.x, pos.y-2, pos.z})
--minetest.remove_node(pos)
minetest.chat_send_all("Hello World!")
end
end
})


i'm having troubles with get_node() Please help

Re: Post your modding questions here

PostPosted: Sat Aug 06, 2016 17:18
by kaeza
ozkur wrote:[...]
i'm having troubles with get_node() Please help

You are comparing a string to a table:
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
if tank == "rocket:tankfull" and ...

Looks like you want to compare the `name` field of the node:
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
if tank.name == "rocket:tankfull" and ...


Edit: For clarification: `get_node` returns a table, which you assign to `tank` here. Same with `engine` and others in that conditional.

As another tip, you most likely want to make `tank`, `engine`, etc. local to the function. This not only yields better performance (as slight as it may be), but it will prevent obscure bugs in the future should another mod need to use globals with those names.

Re: Post your modding questions here

PostPosted: Sat Aug 06, 2016 17:32
by zorman2000
Hello,

I would like to know how to use minetest.register_on_player_receive_fields() when it is a node's formspec.
What would be the name of that form?

I know that with:
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.show_formspec(username, formname, formspec)

you specify a "formname" which usually is the way to detect on the callback. But how to do it when the formspec is set to a node? Like the following:

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 meta = minetest.get_meta(pos)
meta:set_string("formspec", formspec)


Does this formspec has a name?

Thanks,
zorman2000

Re: Post your modding questions here

PostPosted: Sat Aug 06, 2016 17:48
by Byakuren
zorman2000 wrote:Hello,

I would like to know how to use minetest.register_on_player_receive_fields() when it is a node's formspec.
What would be the name of that form?

I know that with:
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.show_formspec(username, formname, formspec)

you specify a "formname" which usually is the way to detect on the callback. But how to do it when the formspec is set to a node? Like the following:

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 meta = minetest.get_meta(pos)
meta:set_string("formspec", formspec)


Does this formspec has a name?

Thanks,
zorman2000


No, also node formspecs don't trigger the global formspec callbacks, only the node's callback.

Re: Post your modding questions here

PostPosted: Sun Aug 07, 2016 07:10
by cx384
old

Re: Post your modding questions here

PostPosted: Wed Aug 10, 2016 07:28
by ph8jPf9M
how can i make drop item size bigger from the atachment to this https://youtu.be/DY6yVnyquxg?t=6m59s with particles and sound emiting from it?

Re: Post your modding questions here

PostPosted: Fri Aug 12, 2016 02:11
by BrunoMine
Block I said goodbye.
Two major projects will be discontinued:
I use these mods on my server, but I need to change them. What are the best options to replace?

Re: Post your modding questions here

PostPosted: Fri Aug 12, 2016 02:55
by Byakuren
BrunoMine wrote:Block I said goodbye.
Two major projects will be discontinued:
I use these mods on my server, but I need to change them. What are the best options to replace?

For HUD hunger there is hbhunger, which uses hudbars.

Re: Post your modding questions here

PostPosted: Fri Aug 12, 2016 05:26
by burli
You can fork them

Re: Post your modding questions here

PostPosted: Fri Aug 12, 2016 16:29
by azekill_DIABLO
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 start_screen =
   "size[8,7;]"..
   default.gui_bg..
   default.gui_bg_img..
   default.gui_slots..
   "field[1,1;100,100;formtext;lol;default]"..
   default.get_hotbar_bg(0,2.85)

minetest.register_on_newplayer (function(player)
   minetest.show_formspec(player:get_player_name(), "start_screen", formspec)
end)


Can someone help me? it is supposed to make a formspec pop on first join, but it makes the game crashes.

Re: Post your modding questions here

PostPosted: Fri Aug 12, 2016 22:07
by kaeza
azekill_DIABLO 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
-- ...
minetest.show_formspec(player:get_player_name(), "start_screen", formspec)
-- ...


Can someone help me? it is supposed to make a formspec pop on first join, but it makes the game crashes.

Probably because the formspec argument is nil. I'll leave you to figure that out.

Re: Post your modding questions here

PostPosted: Sat Aug 13, 2016 08:34
by azekill_DIABLO
i should use 'local formspec' no?

PostPosted: Sat Aug 13, 2016 12:24
by Hybrid Dog
You could put start_screen instead of formspec.

kaeza, maybe formspec is defined somewhere before that code and the crash is caused by a missing default mod

Re: Post your modding questions here

PostPosted: Sat Aug 13, 2016 12:30
by azekill_DIABLO
Missing default mod? i have it :) it's taken from mt game (not the lastest)

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 start_screen =
   "size[8,7;]"..
   default.gui_bg..
   "field[1,1;100,100;formtext;lol;default]"

minetest.register_on_newplayer (function(player)
   minetest.show_formspec(player:get_player_name(), "start_screen", formspec)
end


seems weird. it was shown like that on the dev wiki!

EDIT: ok i understand
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_newplayer (function(player)
   minetest.show_formspec(name, "start_screen",
      "size[8,7;]"..
      default.gui_bg..
      "field[1,1;100,100;formtext;lol;default]")
   end
end)


now says me: missing ') 'at line 7

Re:

PostPosted: Sun Aug 14, 2016 00:18
by kaeza
Hybrid Dog wrote:kaeza, maybe formspec is defined somewhere before that code and the crash is caused by a missing default mod

No. The error in the code is pretty obvious. I just gave him a hint so he actually reads his code and figures what he's doing wrong. It is fine to ask for solutions to problems, but the question sounded (to me, at least) like he's just copy-pasting without actually trying to understand the thing.

Re: Post your modding questions here

PostPosted: Sun Aug 14, 2016 08:15
by azekill_DIABLO
thanks :|
(i dind't copy pasted the code and look at my second post: i corrected my first error but i won't understand the thing after that.)

PostPosted: Sun Aug 14, 2016 16:02
by Hybrid Dog
If you call a function you do not need to put an "end", e.g.
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
print"hello"
or
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.show_formspec(name, "start_screen", "size[8,7;]")
and not
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
print"hello"
end

but if you put a function you need an end, e.g.
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 a = function()
print"hello"
end
or
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_newplayer(function(player)
print"hello"
end)


Anyway, l assume your overlooked that there's an "end" after calling minetest.show_formspec in your code.

Re: Post your modding questions here

PostPosted: Sun Aug 14, 2016 17:39
by azekill_DIABLO
oh? sorry and thanks :)

Re: Post your modding questions here

PostPosted: Mon Aug 15, 2016 10:27
by ABJ
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 def = {
   name = "grenade:explosion",
   description = "Grenade Explosion (you hacker you!)",
   radius = 3,
   tiles = {
      side = "default_dirt.png",
      top = "default_dirt.png",
      bottom = "default_dirt.png",
      burning = "default_dirt.png"
   },
}

tnt.register_tnt(def)



minetest.register_craftitem("grenade:grenade", {
   description = "Grenade",
   inventory_image = "default_coal_lump.png",
   on_use = function(itemstack, user, pointed_thing)
      local v = user:get_look_dir()
      local pos = user:getpos()
      pos.y = pos.y + 1.2

      local obj = minetest.add_entity(pos, "grenade:grenade_flight")
      obj:setvelocity({x = v.x * 4, y = v.y * 2 + 2, z = v.z * 4})
      obj:setacceleration({x = v.x / 4, y = v.y / 2 - 4, z = v.z / 4})

      itemstack:take_item()
      return itemstack
   end,
})

minetest.register_entity("grenade:grenade_flight", {
    physical = true,
   collide_with_objects = true,
   weight = 5,
   textures = {"default_coal_lump.png"},
   on_activate = function(self, staticdata)
      self.timer = 2
   end,
   on_step = function(self, dtime)
      local acc = self.object:getacceleration()
      self.object:setacceleration({x = acc.x * 2 / 4, y = acc.y, z = acc.z * 2 / 4})

      self.timer = self.timer + dtime
      if self.timer > 4 then
         tnt.boom(self.object:getpos(), def)
      end
   end,
})

minetest.register_craft({
    output = "grenade:grenade",
   recipe = {
            {"", "group:stick", ""},
          {"group:wood", "default:coal_lump", "group:wood"},
          {"", "group:wood", ""}
                
   }





})

My attempt at helping with everamzah's coal grenade mod.
Copy the code into an init.lua and open up minetest with mod enabled, type /giveme grenade:grenade 3. The first two grenades will work perfectly, but the last one, (in each stack) doesn't. It's mysterious and beyond me. How even is such a ridiculous bug possible?

Re: Post your modding questions here

PostPosted: Mon Aug 15, 2016 19:42
by TumeniNodes
ABJ 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
local def = {
   name = "grenade:explosion",
   description = "Grenade Explosion (you hacker you!)",
   radius = 3,
   tiles = {
      side = "default_dirt.png",
      top = "default_dirt.png",
      bottom = "default_dirt.png",
      burning = "default_dirt.png"
   },
}

tnt.register_tnt(def)



minetest.register_craftitem("grenade:grenade", {
   description = "Grenade",
   inventory_image = "default_coal_lump.png",
   on_use = function(itemstack, user, pointed_thing)
      local v = user:get_look_dir()
      local pos = user:getpos()
      pos.y = pos.y + 1.2

      local obj = minetest.add_entity(pos, "grenade:grenade_flight")
      obj:setvelocity({x = v.x * 4, y = v.y * 2 + 2, z = v.z * 4})
      obj:setacceleration({x = v.x / 4, y = v.y / 2 - 4, z = v.z / 4})

      itemstack:take_item()
      return itemstack
   end,
})

minetest.register_entity("grenade:grenade_flight", {
    physical = true,
   collide_with_objects = true,
   weight = 5,
   textures = {"default_coal_lump.png"},
   on_activate = function(self, staticdata)
      self.timer = 2
   end,
   on_step = function(self, dtime)
      local acc = self.object:getacceleration()
      self.object:setacceleration({x = acc.x * 2 / 4, y = acc.y, z = acc.z * 2 / 4})

      self.timer = self.timer + dtime
      if self.timer > 4 then
         tnt.boom(self.object:getpos(), def)
      end
   end,
})

minetest.register_craft({
    output = "grenade:grenade",
   recipe = {
            {"", "group:stick", ""},
          {"group:wood", "default:coal_lump", "group:wood"},
          {"", "group:wood", ""}
                
   }





})

My attempt at helping with everamzah's coal grenade mod.
Copy the code into an init.lua and open up minetest with mod enabled, type /giveme grenade:grenade 3. The first two grenades will work perfectly, but the last one, (in each stack) doesn't. It's mysterious and beyond me. How even is such a ridiculous bug possible?

I don't have an answer but, it could be considered a feature because it is realistic :D This actually happens in real life...

Re: Post your modding questions here

PostPosted: Tue Aug 16, 2016 00:01
by ABJ
What the?
How is this realistic? Do people in real life have to "stack" grenades for them to work? LOL

Re: Post your modding questions here

PostPosted: Tue Aug 16, 2016 14:12
by DS-minetest
is it possible to attach a particlespawner to an object (0.4.14-dev)? if yes, how?

Re: Post your modding questions here

PostPosted: Tue Aug 16, 2016 17:25
by Byakuren
No, not yet. There is a PR (https://github.com/minetest/minetest/pull/4409) but it has not been pulled.

Re: Post your modding questions here

PostPosted: Tue Aug 16, 2016 19:24
by DS-minetest
ok, thx

Re: Post your modding questions here

PostPosted: Wed Aug 17, 2016 09:36
by ABJ
:( Why TumeniNodes?
Now I'm just gonna have to repeat my question.
ABJ 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
local def = {
   name = "grenade:explosion",
   description = "Grenade Explosion (you hacker you!)",
   radius = 3,
   tiles = {
      side = "default_dirt.png",
      top = "default_dirt.png",
      bottom = "default_dirt.png",
      burning = "default_dirt.png"
   },
}

tnt.register_tnt(def)



minetest.register_craftitem("grenade:grenade", {
   description = "Grenade",
   inventory_image = "default_coal_lump.png",
   on_use = function(itemstack, user, pointed_thing)
      local v = user:get_look_dir()
      local pos = user:getpos()
      pos.y = pos.y + 1.2

      local obj = minetest.add_entity(pos, "grenade:grenade_flight")
      obj:setvelocity({x = v.x * 4, y = v.y * 2 + 2, z = v.z * 4})
      obj:setacceleration({x = v.x / 4, y = v.y / 2 - 4, z = v.z / 4})

      itemstack:take_item()
      return itemstack
   end,
})

minetest.register_entity("grenade:grenade_flight", {
    physical = true,
   collide_with_objects = true,
   weight = 5,
   textures = {"default_coal_lump.png"},
   on_activate = function(self, staticdata)
      self.timer = 2
   end,
   on_step = function(self, dtime)
      local acc = self.object:getacceleration()
      self.object:setacceleration({x = acc.x * 2 / 4, y = acc.y, z = acc.z * 2 / 4})

      self.timer = self.timer + dtime
      if self.timer > 4 then
         tnt.boom(self.object:getpos(), def)
      end
   end,
})

minetest.register_craft({
    output = "grenade:grenade",
   recipe = {
            {"", "group:stick", ""},
          {"group:wood", "default:coal_lump", "group:wood"},
          {"", "group:wood", ""}
                
   }





})

My attempt at helping with everamzah's coal grenade mod.
Copy the code into an init.lua and open up minetest with mod enabled, type /giveme grenade:grenade 3. The first two grenades will work perfectly, but the last one, (in each stack) doesn't. It's mysterious and beyond me. How even is such a ridiculous bug possible?

Re: Post your modding questions here

PostPosted: Wed Aug 17, 2016 10:59
by KCoombes
I'm getting a strange crash to desktop after an on_punch function. Debug shows this:

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
2016-08-17 06:57:07: INFO[Main]: OpenALSoundManager: Creating playing sound
2016-08-17 06:57:08: INFO[Main]: Left button released (stopped digging)
2016-08-17 06:57:08: INFO[Main]: Client::addUpdateMeshTaskForNode(): (5,5,32)
2016-08-17 06:57:10: INFO[Main]: collisionMoveSimple: maximum step interval exceeded, lost movement details!


Any suggestions?

Re: Post your modding questions here

PostPosted: Thu Aug 18, 2016 21:39
by zorman2000
Hi all,

Anyone who knows this information will help me a lot!

Is there a limit to the "interval" property when registering an Active Block Modifier? I have registered an ABM and would like it to run every 0.2 seconds or similar with a chance of 1 (I know this could be laggy but the blocks are very limited) and replace a block and set another. However, when I test, I see that blocks are being set at an aprox. 1 second interval.

Is there an internal limit to the ABM interval?

Thanks,
zorman2000

Re: Post your modding questions here

PostPosted: Thu Aug 18, 2016 22:08
by pithy
zorman2000 wrote:Hi all,

Anyone who knows this information will help me a lot!

Is there a limit to the "interval" property when registering an Active Block Modifier? I have registered an ABM and would like it to run every 0.2 seconds or similar with a chance of 1 (I know this could be laggy but the blocks are very limited) and replace a block and set another. However, when I test, I see that blocks are being set at an aprox. 1 second interval.

Is there an internal limit to the ABM interval?

Thanks,
zorman2000

Yes ABMs have a 1 second interval limit. You can use LBMs and globalsteps to get around this.
See my wireworld mod for an example.

Re: Post your modding questions here

PostPosted: Fri Aug 19, 2016 03:14
by zorman2000
pithy wrote:Yes ABMs have a 1 second interval limit. You can use LBMs and globalsteps to get around this.
See my wireworld mod for an example.


Thanks! I have thought of doing it through globalstep... will try! Thanks for your mod as reference!