Lua code problems

Post Reply
User avatar
Christian9
Member
Posts: 338
Joined: Fri Sep 19, 2014 20:29
In-game: Christian9
Location: Hell Creek

Lua code problems

by Christian9 » Post

So I'm working on a australia mod (aussie) and I'm trying to make a brebong (cassowary plum) tree for taming cassowarys. i based it off of the default tree api and at this string of code

Code: Select all

minetest.register_abm({
	nodenames = {"aussie:brebongsapling"},
	interval = 10,
	chance = 50,
	action = function(pos, node)
		if not default.can_grow(pos) then
			return
                end
		local mapgen = minetest.get_mapgen_params().mgname
		if node.name == "aussie:brebongsapling" then
			minetest.log("action", "A sapling grows into a Brebong tree at "..
				minetest.pos_to_string(pos))
			if mapgen == "v6" then
				default.grow_tree(pos, random(1, 4) == 1)
			else
				default.grow_new_brebong_tree(pos)
		end
	end
It gives me this error

Code: Select all

2016-03-05 00:13:58: ERROR[Main]: ModError: Failed to load and run script from /home/cp/.minetest/mods/aussie/init.lua:
2016-03-05 00:13:58: ERROR[Main]: /home/cp/.minetest/mods/aussie/trees.lua:154: 'end' expected (to close 'function' at line 33) near '<eof>'
2016-03-05 00:13:58: ERROR[Main]: stack traceback:
2016-03-05 00:13:58: ERROR[Main]: 	[C]: in function 'dofile'
2016-03-05 00:13:58: ERROR[Main]: 	/home/cp/.minetest/mods/aussie/init.lua:3: in main chunk
2016-03-05 00:13:58: ERROR[Main]: Check debug.txt for details.
thanks in advance

User avatar
qwertymine3
Member
Posts: 202
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: Lua code problems

by qwertymine3 » Post

You forgot an end after the if/else
Avatar by :devnko-ennekappao:

User avatar
Christian9
Member
Posts: 338
Joined: Fri Sep 19, 2014 20:29
In-game: Christian9
Location: Hell Creek

Re: Lua code problems

by Christian9 » Post

1 more thing, how do make a tree have fruit?

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: Lua code problems

by Sokomine » Post

You might be intrested in my trees_lib mod. It allows you to easily add new trees. And if you intend to use the function (or schematic) used by existing trees, it won't be much extra work.
A list of my mods can be found here.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests