Renamed some variables
This commit is contained in:
parent
682199716a
commit
e2a9b8046d
1 changed files with 9 additions and 9 deletions
18
c4mate
18
c4mate
|
@ -220,9 +220,9 @@ function MatePad:print_log(log)
|
|||
end
|
||||
|
||||
-- Get available items.
|
||||
function MatePad:get_roster()
|
||||
function MatePad:get_offerings()
|
||||
local pipe, ok, exit, signal
|
||||
local roster = {}
|
||||
local offerings = {}
|
||||
-- sed #1: Extract items section and insert newlines between entries.
|
||||
-- sed #2: Extract and print id, name and price. If any extraction fails we
|
||||
-- fail with exit code 1.
|
||||
|
@ -253,7 +253,7 @@ sed -n --sandbox '
|
|||
if item.id == nil then break end
|
||||
item.name = utf8_decode(pipe:read())
|
||||
item.price = tonumber(pipe:read())
|
||||
table.insert(roster, item)
|
||||
table.insert(offerings, item)
|
||||
end
|
||||
|
||||
ok, exit, signal = pipe:close()
|
||||
|
@ -261,11 +261,11 @@ sed -n --sandbox '
|
|||
io.stderr:write("Sorry, there was an error while parsing the API response.\n")
|
||||
-- Empty table will throw no exceptions.
|
||||
return {}
|
||||
elseif roster == nil then -- curl error
|
||||
elseif offerings == nil then -- curl error
|
||||
io.stderr:write("Sorry, there was an error while connecting the API.\n")
|
||||
return {}
|
||||
end
|
||||
return roster
|
||||
return offerings
|
||||
end
|
||||
|
||||
-- Buy given item.
|
||||
|
@ -419,13 +419,13 @@ elseif tonumber(arg[1]) ~= nil then
|
|||
|
||||
else
|
||||
-- Find and buy item.
|
||||
local roster, query, input, ok
|
||||
roster = pad:get_roster()
|
||||
local offerings, query, input, ok
|
||||
offerings = pad:get_offerings()
|
||||
query = table.concat(arg, " "):lower()
|
||||
local menu = {}
|
||||
|
||||
for i = 1, #roster do
|
||||
local item = roster[i]
|
||||
for i = 1, #offerings do
|
||||
local item = offerings[i]
|
||||
if item.name:lower():match(query) then
|
||||
table.insert(menu, item)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue