forked from huchenlei/auto-crossbreeding
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathdatabase.lua
60 lines (44 loc) · 1.06 KB
/
database.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
local gps = require('gps')
local scanner = require('scanner')
local config = require('config')
local events = require('events')
local storage = {}
local reverseStorage = {}
local farm = {}
-- ======================== WORKING FARM ========================
local function getFarm()
return farm
end
local function updateFarm(slot, crop)
farm[slot] = crop
end
-- ======================== STORAGE FARM ========================
local function getStorage()
return storage
end
local function resetStorage()
storage = {}
end
local function addToStorage(crop)
storage[#storage+1] = crop
reverseStorage[crop.name] = #storage
end
local function existInStorage(crop)
if reverseStorage[crop.name] then
return true
else
return false
end
end
local function nextStorageSlot()
return #storage + 1
end
return {
getFarm = getFarm,
updateFarm = updateFarm,
getStorage = getStorage,
resetStorage = resetStorage,
addToStorage = addToStorage,
existInStorage = existInStorage,
nextStorageSlot = nextStorageSlot
}