Skip to content

Commit

Permalink
Fix quickbar reading
Browse files Browse the repository at this point in the history
  • Loading branch information
ahicks92 committed Jan 17, 2025
1 parent 55d89df commit 5f0287b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
}
],
"Lua.workspace.userThirdParty": [
"c:\\Users\\Austin\\AppData\\Roaming\\Code\\User\\workspaceStorage\\63b7677c3b16e179985a791a1818f333\\justarandomgeek.factoriomod-debug\\sumneko-3rd"
"c:\\Users\\Austin\\AppData\\Roaming\\Code\\User\\workspaceStorage\\69bddfab45fbf20d083316a7b37bb8d6\\justarandomgeek.factoriomod-debug\\sumneko-3rd"
]
}
7 changes: 4 additions & 3 deletions scripts/quickbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ function mod.read_quick_bar_slot(index, pindex)
page = game.get_player(pindex).get_active_quick_bar_page(1) - 1
local item = game.get_player(pindex).get_quick_bar_slot(index + 10 * page)
if item ~= nil then
local proto = prototypes.item[item.name]
local count = game.get_player(pindex).get_main_inventory().get_item_count(item.name)
local stack = game.get_player(pindex).cursor_stack
if stack and stack.valid_for_read then
count = count + stack.count
printout("unselected " .. fa_localising.get(item, pindex) .. " x " .. count, pindex)
printout("unselected " .. fa_localising.get(proto, pindex) .. " x " .. count, pindex)
else
printout("selected " .. fa_localising.get(item, pindex) .. " x " .. count, pindex)
printout("selected " .. fa_localising.get(proto, pindex) .. " x " .. count, pindex)
end
else
printout("Empty quickbar slot", pindex) --does this print, maybe not working because it is linked to the game control?
Expand Down Expand Up @@ -97,7 +98,7 @@ function mod.read_switched_quick_bar(index, pindex)
page = game.get_player(pindex).get_active_quick_bar_page(index)
local item = game.get_player(pindex).get_quick_bar_slot(1 + 10 * (index - 1))
local item_name = "empty slot"
if item ~= nil then item_name = fa_localising.get(item, pindex) end
if item ~= nil then item_name = fa_localising.get(prototypes.item[item.name], pindex) end
local result = "Quickbar " .. index .. " selected starting with " .. item_name
printout(result, pindex)
end
Expand Down

0 comments on commit 5f0287b

Please sign in to comment.