Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- oldnode = {}
- minetest.register_globalstep(function(dtime)
- for _,player in ipairs(minetest.get_connected_players()) do
- local pos = player:getpos()
- pos.y = pos.y + 0.2
- local newnode = minetest.env:get_node(pos).name
- if oldnode ~= nil then
- if newnode == "default:water_flowing" and oldnode[player:get_player_name()] == "air" or newnode == "default:water_source" and oldnode[player:get_player_name()] == "air" then
- for i = 1,math.random(7,20) do
- minetest.env:add_entity(pos, "testing:bubble")
- end
- minetest.sound_play("splash",
- {
- to_player = player:get_player_name(),
- gain = 1.0,
- })
- end
- end
- oldnode[player:get_player_name()] = newnode
- end
- end)
- bubble = {
- physical = false,
- collisionbox = {0,0,0,0,0,0},
- visual = "sprite",
- textures = {"bubble.png"},
- timer = 0,
- visual_size = {x=0.2, y=0.2}
- }
- bubble.on_activate = function(self)
- local y = math.random()
- local z = math.random(-1,1) * math.random()
- local x = math.random(-1,1) * math.random()
- self.object:setvelocity({x=x,y=y,z=z})
- end
- bubble.on_step = function(self)
- self.timer = self.timer + 0.01
- if self.timer > math.random() then
- self.object:remove()
- end
- end
- minetest.register_entity("testing:bubble", bubble)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement