creating a plant

pixelface
New member
 
Posts: 9
Joined: Fri Oct 17, 2014 08:23

creating a plant

by pixelface » Sun Oct 19, 2014 17:05

Hello,
this time I'm having trouble to grow a plant on a specific type of node.
The coral grass should be spawned on top of the coral block.
I'm getting this error message inside the client: Image
And there is no coral top showing up.

That is 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
minetest.register_node("korallen:pinkcoral", {
   tiles = {"koralle_block_pink.png"},
   groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,falling_node=1},
})

minetest.register_node("korallen:bluecoral", {
   tiles = {"koralle_block_blue.png"},
   groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,falling_node=1},
})

minetest.register_abm({
   nodenames = {"default:dirt"},
   neighbors = {"group:water"},
   interval = 45,
   chance = 100,
   action = function(pos)
      pos.y=pos.y+1
      minetest.add_node(pos, {name="korallen:pinkcoral"})
   end,
})

minetest.register_abm({
   nodenames = {"default:dirt"},
   neighbors = {"group:water"},
   interval = 60, -- interval per secnd
   chance = 300, -- propability 1= always
   action = function(pos)
      pos.y=pos.y+1
      minetest.add_node(pos, {name="korallen:bluecoral"})
   end,
})

minetest.register_craftitem("korallen:pink_coral_grass",{
   description = "pink colored coral top",
   inventory_image = "koralle_top_pink.png",
   wield_image = "koralle_top_pink.png"
   --on_drop = function(itemstack, dropper, pos)
   --itemstack:take_item()
   --return itemstack
   })


minetest.register_abm({
   nodenames = {"korallen:pinkcoral"},
   neighbors = {"group:water"},
   interval = 45,
   chance = 50,
   action = function(pos)
      pos.y=pos.y+1
      minetest.add_node(pos, {name="korallen:pink_coral_grass"})
   end,
})
   

minetest.register_craftitem("korallen:pink_coral_stick",{
   description = "a pink colored coral piece",
   inventory_image = "koralle_stick_pink.png",
   wield_image = "koralle_block_pink.png"
   --on_drop = function(itemstack, dropper, pos)
   --itemstack:take_item()
   --return itemstack
   })

minetest.register_craft({
    output = 'korallen:pink_coral_stick',
   recipe = {
      {'korallen:pinkcoral', '', ''},
      {'korallen:pinkcoral', '', ''},
      {'korallen:pinkcoral', '', ''},
}
})

minetest.register_tool('korallen:coral_pick', {
    description = 'coral pickaxe',
    inventory_image = 'default_tool_diamondpick.png',
    tool_capabilities = {
        max_drop_level=3,
        groupcaps= {
            cracky={times={[1]=4.00, [2]=1.50, [3]=1.00}, uses=70, maxlevel=1}
        }
    }
})

minetest.register_craft({
    output = 'korallen:coral_pick',
   recipe = {
      {'korallen:pinkcoral', 'korallen:pinkcoral', 'korallen:pinkcoral'},
      {'', 'korallen:pink_coral_stick', ''},
      {'', 'korallen:pink_coral_stick', ''},
}
})

minetest.register_craftitem("korallen:blue_coral_stick",{
   description = "a blue colored coral piece",
   inventory_image = "koralle_stick_blue.png",
   wield_image = "koralle_block_pink.png"
   --on_drop = function(itemstack, dropper, pos)
   --itemstack:take_item()
   --return itemstack
   })



Thans for your help! :)
 

Hashlime
Member
 
Posts: 12
Joined: Fri Oct 17, 2014 23:36

Re: creating a plant

by Hashlime » Sun Oct 19, 2014 17:34

What are you trying to do ?
The ADM defined here (the first and second one) pops a blue/pink coral above a dirt node if there is water near the dirt node. Is it what you want ?
 

pixelface
New member
 
Posts: 9
Joined: Fri Oct 17, 2014 08:23

Re: creating a plant

by pixelface » Sun Oct 19, 2014 18:10

I'd like to spawn the pink coral grass ontop of the pink block.
This does not seem to work.

The change+intervall should be lower for the pink grass, so it can find a free pink block to spawn no top of it.
The code for this is below the pink and blue spawnig block code.
But, well, the grass dosen't show up.

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_craftitem("korallen:pink_coral_grass",{
   description = "pink colored coral top",
   inventory_image = "koralle_top_pink.png",
   wield_image = "koralle_top_pink.png"
   --on_drop = function(itemstack, dropper, pos)
   --itemstack:take_item()
   --return itemstack
   })


minetest.register_abm({
   nodenames = {"korallen:pinkcoral"},
   neighbors = {"group:water"},
   interval = 45,
   chance = 50,
   action = function(pos)
      pos.y=pos.y+1
      minetest.add_node(pos, {name="korallen:pink_coral_grass"})
   end,
})
 

Hashlime
Member
 
Posts: 12
Joined: Fri Oct 17, 2014 23:36

Re: creating a plant

by Hashlime » Sun Oct 19, 2014 18:33

`korallen:pink_coral_grass` is registered as a craftitem so it can't be placed as a node
You have two solutions :
1) Register `korallen:pink_coral_grass` as a node
2) Don't modify `korallen:pink_coral_grass` and drop an ItemStack with minetest.add_item
 

pixelface
New member
 
Posts: 9
Joined: Fri Oct 17, 2014 08:23

Re: creating a plant

by pixelface » Sun Oct 19, 2014 18:38

Thanks for your answer! :D
What's the best way to add it as a plant? I've never created a plant-object in minetest before.
I'd like to have something similar to the the grass that's growing on dirt in the regular game.
 

Hashlime
Member
 
Posts: 12
Joined: Fri Oct 17, 2014 23:36

Re: creating a plant

by Hashlime » Sun Oct 19, 2014 18:52

Probably something like this (this code is in minetest_game/mods/default/nodes.lua)
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_node("default:grass_1", {
   description = "Grass",
   drawtype = "plantlike",
   waving = 1,
   tiles = {"default_grass_1.png"},
   -- use a bigger inventory image
   inventory_image = "default_grass_3.png",
   wield_image = "default_grass_3.png",
   paramtype = "light",
   walkable = false,
   is_ground_content = true,
   buildable_to = true,
   groups = {snappy=3,flammable=3,flora=1,attached_node=1},
   sounds = default.node_sound_leaves_defaults(),
   selection_box = {
      type = "fixed",
      fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
   },
   on_place = function(itemstack, placer, pointed_thing)
      -- place a random grass node
      local stack = ItemStack("default:grass_"..math.random(1,5))
      local ret = minetest.item_place(stack, placer, pointed_thing)
      return ItemStack("default:grass_1 "..itemstack:get_count()-(1-ret:get_count()))
   end,
})
 

pixelface
New member
 
Posts: 9
Joined: Fri Oct 17, 2014 08:23

Re: creating a plant

by pixelface » Sun Oct 19, 2014 19:07

Thanks a lot! :D
I'll try that.
 

User avatar
Topywo
Member
 
Posts: 1718
Joined: Fri May 18, 2012 20:27

Re: creating a plant

by Topywo » Sun Oct 19, 2014 20:01

I think the problem is you created a craftitem you want to add as a node:

You could try to change:
minetest.register_craftitem("korallen:pink_coral_grass",{
into:
minetest.register_node("korallen:pink_coral_grass", {
 

pixelface
New member
 
Posts: 9
Joined: Fri Oct 17, 2014 08:23

Re: creating a plant

by pixelface » Sun Oct 19, 2014 20:20

Isn't a node always in square form?
 

User avatar
Evergreen
Member
 
Posts: 2131
Joined: Sun Jan 06, 2013 01:22
GitHub: 4Evergreen4
IRC: EvergreenTree
In-game: Evergreen

Re: creating a plant

by Evergreen » Sun Oct 19, 2014 20:37

pixelface wrote:Isn't a node always in square form?

No, not at all. http://dev.minetest.net/Node_Drawtypes
"Help! I searched for a mod but I couldn't find it!"
http://krock-works.16mb.com/MTstuff/modSearch.php
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 7 guests

cron