1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-30 04:30:58 +02:00
This commit is contained in:
grilledham 2018-11-25 11:52:50 +00:00
parent f4612a7046
commit 4e0f30db17

View File

@ -135,15 +135,20 @@ function Public.set_data(data_set, key, value)
message = table.concat({data_set_tag, '{data_set:"', data_set, '",key:"', key, '"}'})
elseif vt == 'string' then
message = table.concat({data_set_tag, '{data_set:"', data_set, '",key:"', key, '",value:"\\"', value, '\\""}'})
elseif vt == 'number' or vt == 'boolean' then
elseif vt == 'number' then
message = table.concat({data_set_tag, '{data_set:"', data_set, '",key:"', key, '",value:"', value, '"}'})
elseif vt == 'boolean' then
message =
table.concat({data_set_tag, '{data_set:"', data_set, '",key:"', key, '",value:"', tostring(value), '"}'})
elseif vt == 'function' then
error('value cannot be a function')
else
value = serpent.line(value)
message = table.concat({data_set_tag, '{data_set:"', data_set, '",key:"', key, '",value:"', value, '"}'})
value = value:gsub("'", "\\'")
message = table.concat({data_set_tag, '{data_set:"', data_set, '",key:"', key, "\",value:'", value, "'}"})
end
game.print(message)
raw_print(message)
end
@ -208,4 +213,31 @@ function Public.get_tracked_data_sets()
game.print(message)
end
function Public.try_get_data(data_set, key, callback_token)
if type(data_set) ~= 'string' then
error('data_set must be a string')
end
if type(key) ~= 'string' then
error('key must be a string')
end
if type(callback_token) ~= 'number' then
error('callback_token must be a number')
end
local message = table.concat {data_get_tag, callback_token, ' {', 'data_set:"', data_set, '",key:"', key, '"}'}
raw_print(message)
end
function Public.try_get_all_data(data_set, callback_token)
if type(data_set) ~= 'string' then
error('data_set must be a string')
end
if type(callback_token) ~= 'number' then
error('callback_token must be a number')
end
local message = table.concat {data_get_all_tag, callback_token, ' {', 'data_set:"', data_set, '"}'}
raw_print(message)
end
return Public