mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 15:33:12 +09:00
added json parser for importMany
This commit is contained in:
1 parent
b3aa96cddf
commit
f3c6fdaa3b
2 files changed
+858
-3
No files matched your search
@@ -1,4 +1,5 @@
|
||||
require("config")
|
||||
local json = require("json")
|
||||
|
||||
function HashPosition(position)
|
||||
return 40000 * (position.y) + position.x
|
||||
@@ -256,9 +257,12 @@ remote.add_interface("clusterio",
|
||||
import = function(itemName, itemCount)
|
||||
GiveItemsToStorage(itemName, itemCount)
|
||||
end,
|
||||
importMany = function(items)
|
||||
for itemName, itemCount in pairs(items) do
|
||||
GiveItemsToStorage(itemName, itemCount)
|
||||
importMany = function(jsonString)
|
||||
local items = json:decode(jsonString)
|
||||
for k, item in pairs(items) do
|
||||
for itemName, itemCount in pairs(item) do
|
||||
GiveItemsToStorage(itemName, itemCount)
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user