Lua code problems

User avatar
Christian9
Member
 
Posts: 273
Joined: Fri Sep 19, 2014 20:29
In-game: Christian9

Lua code problems

by Christian9 » Sat Mar 05, 2016 08:15

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

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_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
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-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: 194
Joined: Wed Jun 03, 2015 14:33
GitHub: Qwertymine
In-game: qwertymine3

Re: Lua code problems

by qwertymine3 » Sat Mar 05, 2016 15:02

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

User avatar
Christian9
Member
 
Posts: 273
Joined: Fri Sep 19, 2014 20:29
In-game: Christian9

Re: Lua code problems

by Christian9 » Sat Mar 05, 2016 19:52

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

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

Re: Lua code problems

by Sokomine » Wed Mar 16, 2016 03:49

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.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 7 guests

cron