master
Desour 2020-04-15 20:39:27 +02:00
commit 6d431d49f0
1 changed files with 38 additions and 0 deletions

38
init.lua Normal file
View File

@ -0,0 +1,38 @@
local step_time = 30
local chance = 0.01
--~ local step_time = 5
--~ local chance = 1
local function step()
minetest.after(step_time, step)
-- get all not attached players
local players = {}
do
local all_players = minetest.get_connected_players()
local i = 1
for _, player in ipairs(all_players) do
if not player:get_attach() then
players[i] = player
i = i + 1
end
end
end
if #players < 2 then
return
end
for _, player in ipairs(players) do
if math.random() < chance and not player:get_attach() then
-- rider found, search for horse
local horse = players[math.random(#players)]
player:set_attach(horse, "", vector.new(0, 10, 0), vector.new())
player:set_eye_offset(vector.new(0, 10, 0), vector.new(0, 10, 0))
break
end
end
end
minetest.after(0, step)