Problem trying to make new plants

User avatar
durtective6
Member
 
Posts: 167
Joined: Sun Aug 12, 2012 14:19
In-game: derplez

Problem trying to make new plants

by durtective6 » Sat Dec 28, 2013 12:28

I'm trying to make a new plant which can be grown like wheat, however when i go to place it i get this error:

Image

Is there anything i can do/what is wrong?
Any help would be appreciated

Also heres the code if needed:

[spoiler]-- placing seeds

local function place_seed(itemstack, placer, pointed_thing, plantname)
local pt = pointed_thing
-- check if pointing at a node
if not pt then
return
end
if pt.type ~= "node" then
return
end

local under = minetest.get_node(pt.under)
local above = minetest.get_node(pt.above)

-- return if any of the nodes is not registered
if not minetest.registered_nodes[under.name] then
return
end
if not minetest.registered_nodes[above.name] then
return
end

-- check if pointing at the top of the node
if pt.above.y ~= pt.under.y+1 then
return
end

-- check if you can replace the node above the pointed node
if not minetest.registered_nodes[above.name].buildable_to then
return
end

-- check if pointing at soil
if minetest.get_item_group(under.name, "soil") <= 1 then
return
end

-- add the node and remove 1 item from the itemstack
minetest.add_node(pt.above, {name=plantname})
if not minetest.setting_getbool("creative_mode") then
itemstack:take_item()
end
return itemstack
end

-- xurvine

minetest.register_craftitem("techno:xurvine_seed", {
description = "Xurvine Seed",
inventory_image = "xurvine_seed.png",
on_place = function(itemstack, placer, pointed_thing)
return place_seed(itemstack, placer, pointed_thing, "farming:crop")
end,
})

minetest.register_craftitem("techno:xurvine", {
description = "Xurvine",
inventory_image = "xurvine.png",
})

for i=1,8 do
local drop = {
items = {
{items = {'techno:xurvine'},rarity=9-i},
{items = {'techno:xurvine'},rarity=18-i*2},
{items = {'techno:xurvine_seed'},rarity=9-i},
{items = {'techno:xurvine_seed'},rarity=18-i*2},
}
}
minetest.register_node("techno:xurvine_"..i, {
drawtype = "plantlike",
tiles = {"techno_xurvine_"..i..".png"},
paramtype = "light",
waving = 1,
walkable = false,
buildable_to = true,
is_ground_content = true,
drop = drop,
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
},
groups = {snappy=3,flammable=2,plant=1,xurvine=i,not_in_creative_inventory=1,attached_node=1},
sounds = default.node_sound_leaves_defaults(),
})
end

minetest.register_abm({
nodenames = {"group:xurvine"},
neighbors = {"group:soil"},
interval = 90,
chance = 2,
action = function(pos, node)
-- return if already full grown
if minetest.get_item_group(node.name, "xurvine") == 8 then
return
end

-- check if on wet soil
pos.y = pos.y-1
local n = minetest.get_node(pos)
if minetest.get_item_group(n.name, "soil") < 3 then
return
end
pos.y = pos.y+1

-- check light
if not minetest.get_node_light(pos) then
return
end
if minetest.get_node_light(pos) < 13 then
return
end

-- grow
local height = minetest.get_item_group(node.name, "xurvine") + 1
minetest.set_node(pos, {name="techno:xurvine_"..height})
end
})[/spoiler]
Last edited by durtective6 on Sat Dec 28, 2013 12:29, edited 1 time in total.
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Sat Dec 28, 2013 14:21

The error means you try to call set_node() or add_node() with a not registered node.
 

User avatar
Casimir
Member
 
Posts: 1101
Joined: Fri Aug 03, 2012 16:59

by Casimir » Sat Dec 28, 2013 16:01

If you run Minetest from a terminal you will have more output on what the error is. Also [ code ] tags help reading the 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
-- xurvine

minetest.register_craftitem("techno:xurvine_seed", {
        description = "Xurvine Seed",
        inventory_image = "xurvine_seed.png",
        on_place = function(itemstack, placer, pointed_thing)
                return place_seed(itemstack, placer, pointed_thing, "farming:crop")
        end,
})

"farming:crop" seems to be not defined.
Last edited by Casimir on Sat Dec 28, 2013 16:01, edited 1 time in total.
 

User avatar
durtective6
Member
 
Posts: 167
Joined: Sun Aug 12, 2012 14:19
In-game: derplez

by durtective6 » Sat Dec 28, 2013 16:08

I'll try some of the things that have been suggested, thanks.

The farming:crop was just for when i quickly changed names to test

EDIT: on_construct got rid of the error but it doesnt place the item
Last edited by durtective6 on Sat Dec 28, 2013 16:12, edited 1 time in total.
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 7 guests

cron