Help! Minetest error problem mod

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

Help! Minetest error problem mod

by judah.jtw » Post

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: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Help! Minetest error problem mod

by Krock » Post

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)
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

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

Re: Help! Minetest error problem mod

by Andrey01 » Post

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.

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

Re: Help! Minetest error problem mod

by AiTechEye » Post

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,
})

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 » Post

Ok thanks. Ill try that.

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 » Post

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

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

Re: Help! Minetest error problem mod

by Andrey01 » Post

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

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

Re: Help! Minetest error problem mod

by Phoenixflo44 » Post

I did not read that when I shared my first mod
Spoiler
I hate my life

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 11 guests