-
Notifications
You must be signed in to change notification settings - Fork 8
/
lib.lua
127 lines (89 loc) · 3.82 KB
/
lib.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
--[[
**********************************************
*** cucina_vegana ***
*** lib.lua ***
**********************************************
]]--
local cv = cucina_vegana
local mt = minetest
local S = cv.get_translator
math.randomseed(os.time())
function cv.lib.register_bottom_abm(node, nextnode, duration, light)
local percent = 1
if(mt.registered_nodes[node]) then
mt.register_abm({
nodenames = {node},
interval = duration,
chance = percent,
catch_up = true,
action = function(pos, node, active_object_count, active_object_count_wider)
local nodepos = pos
if(cv.lib.check_soil(nodepos)) then
if(cv.lib.check_light(nodepos, light)) then
mt.set_node(nodepos, {name = nextnode})
end -- if(cv.check_light
end -- if(cv.lib.check_soil)
end, -- function(
}) -- minetest.register_abm({
end -- if(nodename ~= nil
end
function cv.lib.register_top_abm(node, nextnode, duration, light)
local percent = 1
if(mt.registered_nodes[node]) then
mt.register_abm({
nodenames = {node},
interval = duration,
chance = percent,
catch_up = true,
action = function(pos, node, active_object_count, active_object_count_wider)
local nodepos = pos
if(cv.lib.check_light(nodepos, light)) then
mt.set_node(nodepos, {name = nextnode})
end -- if(cv.check_light
end, -- function(
}) -- minetest.register_abm({
end -- if(nodename ~= nil
end
function cv.lib.check_light(pos, level)
local node = mt.get_node_or_nil(pos)
if(node) then
local light = mt.get_node_light(pos) or 0
if(light >= level) then return true end
end -- if(minetest.get_node_or_nil(
return false
end -- function aqua_farming.check_light
function cv.lib.check_soil(pos)
local below = {x = pos.x, y = pos.y - 1, z = pos.z}
local soil = mt.get_node_or_nil(below)
if(soil and mt.get_item_group(soil, "group:soil")) then
return true
end -- if(minetest.get_node_or_nil(
return false
end -- cv.lib.check_soil
function cv.lib.check_air(pos)
local air = mt.get_node_or_nil(pos)
if (air) and (string.match(air.name,"air")) then
return true
end
return false
end -- cv.lib.check_air
function cv.lib.coffee_effect(playerobject)
if(not playerobject) then return end
local playername = playerobject:get_player_name()
local seconds = cv.settings.coffee_effect_duration
local highspeed = cv.settings.coffee_effect_speed
local normalspeed = 1
playerobject:set_physics_override({speed = highspeed})
minetest.chat_send_player(playername, S("Coffeespeed. @1 Seconds left.", seconds))
minetest.after(seconds/2, function()
local playerobject = minetest.get_player_by_name(playername)
if(not playerobject) then return end
minetest.chat_send_player(playername,S("@1 Seconds left.", seconds/2))
end, playername)
minetest.after(seconds, function()
local playerobject = minetest.get_player_by_name(playername)
if(not playerobject) then return end
minetest.chat_send_player(playername,S("You move normal again."))
playerobject:set_physics_override({speed = normalspeed})
end, playername)
end