-
-
Save xyzz/c70a17afcb37e6aa8865 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export ^ | |
class Rat extends Mob | |
name: "mobs:rat" | |
interval: 5 | |
step: => | |
x = math.random! - 0.5 | |
z = math.random! - 0.5 | |
y = 0 | |
if math.random! > 0.8 | |
-- jump | |
y = 5 | |
@velocity {x: x, y: y, z: z} | |
Rat\register! | |
-- ported from 0.3 | |
minetest.register_abm { | |
nodenames: {"default:tree", "default:jungletree", "group:tree"}, | |
interval: 10, | |
chance: 200, | |
action: (pos, node, active_object_count, active_object_count_wider) -> | |
if active_object_count_wider != 0 | |
return | |
p1 = vector.add(pos, { | |
x: math.random(-2, 2), | |
y: 0, | |
z: math.random(-2, 2) | |
}) | |
n1 = minetest.get_node p1 | |
n1b = minetest.get_node vector.add(p1, {x: 0, y: -1, z: 0}) | |
if n1.name == "air" and do | |
(n1b.name == "default:dirt_with_grass" or minetest.get_item_group(n1b.name, "grass")) | |
Rat(p1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment