-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatcommand.lua
66 lines (60 loc) · 1.72 KB
/
chatcommand.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
local rad = math.rad
-- return number of eagles in aosr
local function iseagle(pos2)
local objs=minetest.get_objects_inside_radius(pos2,aerotest.aosr)
local number = 0
for _,obj in ipairs(objs) do
if not obj:is_player() then
local luaent = obj:get_luaentity()
if luaent and luaent.name
and luaent.name == 'aerotest:eagle' then
number = number + 1
end
end
end
return number
end
-- Add Chatcommand to spawn an eagle
minetest.register_chatcommand("eagle", {
params = "<action>",
description = "Spawn an eagle [idle] to spawn a sitting one",
privs = {server = true},
func = function(name, action)
local player = minetest.get_player_by_name(name)
if not player then return false end
local pos = player:get_pos()
local yaw = player:get_look_horizontal()
pos.y = pos.y + 1
local pos2 = mobkit.pos_translate2d(pos,yaw,3)
if iseagle(pos) < aerotest.maxeagle + 1 then
local obj = minetest.add_entity(pos2, "aerotest:eagle")
if obj and action ~= "idle" then
local pos3 = vector.subtract(pos2,pos)
pos3.y = 4
obj:set_velocity(pos3)
elseif obj and action == "idle" then
obj:set_yaw(rad(math.random(360)))
end
end
return true
end
})
--chatcommand to show what is on eagle'e menu today
minetest.register_chatcommand("eagle_prey", {
params = "",
description = "show what an eagle likes to hunt",
privs = {server = true},
func = function(name)
minetest.chat_send_player(name, dump(aerotest.prey))
end
})
minetest.register_chatcommand("rnd", {
params = "",
description = "test rnd numgen",
privs = {server = true},
func = function(name)
for i = 1,100,1 do
minetest.chat_send_player(name, dump(water_life.random()))
end
end
})