1 --Register beanstalk nodes
2 minetest
.register_node("magicbeans:leaves", {
3 tiles
= {"magicbeans_leaves.png"},
4 drawtype
= "plantlike",
8 groups
= {dig_immediate
= 3},
11 minetest
.register_node("magicbeans:blank", {
12 tiles
= {"magicbeans_blank.png"},
13 drawtype
= "plantlike",
17 groups
= {dig_immediate
= 3},
20 minetest
.register_node("magicbeans:stem", {
21 tiles
= {"magicbeans_stem.png"},
23 groups
= {dig_immediate
= 3},
26 minetest
.register_node("magicbeans:cloud", {
27 tiles
= {"default_cloud.png"},
31 sunlight_propagates
= true,
32 groups
= {dig_immediate
= 3},
36 { "Magic Jumping Beans", "jumping", 1, 5, 1},
37 { "Magic Flying Beans", "flying", 2, 1, 0.02},
38 { "Magic Running Beans", "running", 3, 1, 1},
39 { "Magic Beanstalk Beans", "beanstalk", 1, 1, 1},
42 for i
in ipairs(magicbeans_list
) do
44 local beandesc
= magicbeans_list
[i
][1]
45 local bean
= magicbeans_list
[i
][2]
46 local beanspeed
= magicbeans_list
[i
][3]
47 local beanjump
= magicbeans_list
[i
][4]
48 local beangrav
= magicbeans_list
[i
][5]
51 minetest
.register_craftitem("magicbeans:"..bean
, {
52 description
= beandesc
,
53 inventory_image
= "magicbeans_"..bean
..".png",
54 on_place
= function(itemstack
, placer
, pointed_thing
)
55 if pointed_thing
.above
then
56 if bean
~= "beanstalk" then
57 minetest
.env
:add_item(pointed_thing
.above
, {name
="magicbeans:"..bean
})
60 minetest
.chat_send_player(placer
:get_player_name(),"It's gonna grow - wait for it!")
61 math
.randomseed(os
.time())
62 local stalk
= pointed_thing
.above
65 local height
= 127 - stalk
.y
66 local c
= {1, 1, 1, 1, 2, 1, 1, 1, 1}
67 local d
= {1, 2, 3, 6}
68 local e
= {9, 8, 7, 4}
74 if blank
> 4 then blank
= 1 end
83 node
= "magicbeans:leaves"
84 if i
== d
[blank
] or i
== e
[blank
] then node
= "magicbeans:blank" end
86 node
= "magicbeans:stem"
90 minetest
.set_node({x
=ex1
, y
=why1
, z
=zed1
},{name
=node
})
94 -- Build cloud platform
99 minetest
.set_node({x
=ex1
, y
=why1
, z
=zed1
},{name
="magicbeans:cloud"})
103 itemstack
:take_item()
107 on_use
= function(itemstack
, user
, pointed_thing
)
108 if bean
== "beanstalk" then
109 minetest
.chat_send_player(user
:get_player_name(),"You can't eat magic beanstalk beans - you have to plant them.")
112 user
:set_physics_override(beanspeed
, beanjump
, beangrav
)
113 minetest
.chat_send_player(user
:get_player_name(),"Whoa, that was a strong magic "..bean
.." bean!")
114 local normjump
= function()
115 user
:set_physics_override(1, 1, 1)
116 minetest
.chat_send_player(user
:get_player_name(),"Looks like you're back to normal now - no more crazy "..bean
.."!")
118 minetest
.after(30, normjump
)
119 itemstack
:take_item()
127 minetest
.register_abm(
128 {nodenames
= {"default:dirt_with_grass"},
131 action
= function(pos
)
133 math
.randomseed(os
.time())
134 local j
= math
.random(4)
135 local bean
= magicbeans_list
[j
][2]
136 minetest
.env
:add_item(pos
, {name
="magicbeans:"..bean
})