Skip to content

Fix 2 bugs in craft function #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ basic_robot.commands.keyboard = {
basic_robot.commands.craftcache = {};

basic_robot.commands.craft = function(item, mode, idx,amount, name)
amount = amount and tonumber(amount) or 1;
amount = amount and math.floor(tonumber(amount)) or 1;
if amount<0 then amount = 1 end
if not item then return false end

Expand Down Expand Up @@ -832,7 +832,9 @@ basic_robot.commands.craft = function(item, mode, idx,amount, name)
inv:remove_item("main",stack);
end

inv:add_item("main",ItemStack(output))
output = ItemStack(output)
output:set_count(output:get_count() * amount)
inv:add_item("main",output)
return true
end

Expand Down
2 changes: 1 addition & 1 deletion robogui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ local help_pages = {
" activate.direction(mode) activates target block",
" pickup(r) picks up all items around robot in radius r<8 and returns list",
" or nil",
" craft(item,idx,mode) crafts item if required materials are present in",
" craft(item,idx,mode,amount) crafts item if required materials are present in",
" inventory, mode = 1 returns recipe, optional recipe idx",
" take.direction(item, inventory) takes item from target inventory into",
" robot inventory",
Expand Down