Help! Minetest error problem mod

judah.jtw
New member
 
Posts: 8
Joined: Mon Jul 16, 2018 18:39
In-game: Tails

Help! Minetest error problem mod

by judah.jtw » Mon Jul 16, 2018 18:47

Hi! I am a new modder, and i need help with this code! So please help! :)

minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
if node.name == "particle:ore_ore" then
minetest.register_abm({
nodenames = {"particle:ore_ore"}, --makes small particles emanate from the beginning of a beam
interval = 1,
chance = 2,
action = function(pos, node)
minetest.add_particlespawner(
32, --amount
4, --time
{x=pos.x-0.25, y=pos.y-0.25, z=pos.z-0.25}, --minpos
{x=pos.x+0.25, y=pos.y+0.25, z=pos.z+0.25}, --maxpos
{x=-0.8, y=-0.8, z=-0.8}, --minvel
{x=0.8, y=0.8, z=0.8}, --maxvel
{x=0,y=0,z=0}, --minacc
{x=0,y=0,z=0}, --maxacc
0.5, --minexptime
1, --maxexptime
1, --minsize
2, --maxsize
false, --collisiondetection
"particle_particle.png" --texture
)
end
end
})



Its says things like "2018-07-16 13:34:19: ERROR[Main]: ...ograms\minetest-0.4.17.1-win64\bin\..\mods\particle\init.lua:528: '}' expected (to close '{' at line 506) near 'end'
and
"2018-07-16 13:34:02: ERROR[Main]: ...ograms\minetest-0.4.17.1-win64\bin\..\mods\particle\init.lua:528: unexpected symbol near 'end"


Thanks in Advance, Tails"
 

User avatar
Krock
Developer
 
Posts: 4107
Joined: Thu Oct 03, 2013 07:48
Location: Switzerland
GitHub: SmallJoker

Re: Help! Minetest error problem mod

by Krock » Mon Jul 16, 2018 19:23

Why do you register an ABM inside another callback? That must be accidental copy&paste leftovers.

Code: Select all
minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
   if node.name == "particle:ore_ore" then
      minetest.add_particlespawner(
         32, --amount
         4, --time
         {x=pos.x-0.25, y=pos.y-0.25, z=pos.z-0.25}, --minpos
         {x=pos.x+0.25, y=pos.y+0.25, z=pos.z+0.25}, --maxpos
         {x=-0.8, y=-0.8, z=-0.8}, --minvel
         {x=0.8, y=0.8, z=0.8}, --maxvel
         {x=0,y=0,z=0}, --minacc
         {x=0,y=0,z=0}, --maxacc
         0.5, --minexptime
         1, --maxexptime
         1, --minsize
         2, --maxsize
         false, --collisiondetection
         "particle_particle.png" --texture
      )
   end
end)
Mod Search Engine - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
 

User avatar
Andrey01
Member
 
Posts: 2134
Joined: Wed Oct 19, 2016 15:18
Location: Russia, Moscow
GitHub: Andrey2470T
In-game: Andrey01

Re: Help! Minetest error problem mod

by Andrey01 » Mon Jul 16, 2018 20:49

First mistake: any arguments are passed through the function should be in table, that is it should be so: minetest.add_particlespawner({...}).

Second mistake: you did not close minetest.register_abm() function (between "end ... end" shouls be "})".

Well and third mistake: you put unnecessary "}" symbol after "end" words.

And btw, you should use BBcode "Code" button (Well, that being upwards when you composing a message and set comments in the code to know about site of the error.
DL9Eh7xVBw7DXwLAMX1lStE21bSD2XUQ
 

User avatar
AiTechEye
Member
 
Posts: 570
Joined: Fri May 29, 2015 21:14
Location: Sweden
GitHub: AiTechEye

Re: Help! Minetest error problem mod

by AiTechEye » Mon Jul 16, 2018 21:26

the currently function you made adds a new "abm" every time someone is punching a "particle:ore_ore"
all abm's will keep running until you quit the game, this will make your game lag a lot or freeze

its better to start a timer in the node itself

Code: Select all
minetest.register_node("particle:ore_ore", {
   description = "test ore",
   tiles = {"default_steel_block.png"},
   groups = {cracky = 3},
   on_punch = function(pos, node, puncher, pointed_thing)
      minetest.get_node_timer(pos):start(1)
   end,
   on_timer = function (pos, elapsed)
      if math.random(1,2)~=1 then return true end
      minetest.add_particlespawner({
         amount = 32,
         time = 4,
         minpos = {x=pos.x-0.25, y=pos.y-0.25, z=pos.z-0.25},
         maxpos = {x=pos.x+0.25, y=pos.y+0.25, z=pos.z+0.25},
         minvel = {x=-0.8, y=-0.8, z=-0.8},
         maxvel = {x=0.8, y=0.8, z=0.8},
         minacc = {x=0, y=0, z=0},
         maxacc = {x=0, y=0, z=0},
         minexptime = 0.5,
         maxexptime = 1,
         minsize = 2,
         maxsize = 2,
         collisiondetection = false,
         texture = "particle_particle.png",
      })
      return true
   end,
})
Mods content repository YouTube Music Im taking a break from all coding & modding
 

judah.jtw
New member
 
Posts: 8
Joined: Mon Jul 16, 2018 18:39
In-game: Tails
 

judah.jtw
New member
 
Posts: 8
Joined: Mon Jul 16, 2018 18:39
In-game: Tails

Re: Help! Minetest error problem mod

by judah.jtw » Tue Jul 17, 2018 00:36

Thanks! how do i share a mod? I would like to show the community my mods! :)
 

User avatar
Andrey01
Member
 
Posts: 2134
Joined: Wed Oct 19, 2016 15:18
Location: Russia, Moscow
GitHub: Andrey2470T
In-game: Andrey01

Re: Help! Minetest error problem mod

by Andrey01 » Tue Jul 17, 2018 06:48

Yes, minetest.register_abm() is not needed as minetest.add_particlespawner() already adds interval between every particles deflation.

judah.jtw@gmail.com wrote:Thanks! how do i share a mod? I would like to show the community my mods! :)


You need to post your mods in WIP mods section: viewforum.php?f=9
And you need to read it before posting: viewtopic.php?f=11&t=1271
DL9Eh7xVBw7DXwLAMX1lStE21bSD2XUQ
 

Phoenixflo44
Member
 
Posts: 547
Joined: Fri Jul 28, 2017 15:01
Location: Behind my PC, in Germany
In-game: Phoenixflo44

Re: Help! Minetest error problem mod

by Phoenixflo44 » Fri Jul 20, 2018 09:50

I did not read that when I shared my first mod
You can't see it here. I'm doing everything wrong anyway.
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 4 guests