From 11cc95c3e06028027a31bad9ef867df542bb93ac Mon Sep 17 00:00:00 2001 From: ac-minetest Date: Fri, 27 Nov 2020 17:19:17 +0100 Subject: [PATCH] robot fixes: boost move, books --- basic_robot/commands.lua | 9 +++++---- basic_robot/init.lua | 4 ++-- basic_robot/robogui.lua | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/basic_robot/commands.lua b/basic_robot/commands.lua index 7ee45ad..7ff9b61 100644 --- a/basic_robot/commands.lua +++ b/basic_robot/commands.lua @@ -444,8 +444,9 @@ basic_robot.commands.write_book = function(name,title,text) -- returns itemstack local data = {} if title == "" or not title then title = "program book "..minetest.get_gametime() end - data.title = title or "" - data.text = text or "" + if text == "" or not text then text = "empty" end + data.text = text + data.title = title data.text_len = #data.text data.page = 1 data.description = title or "" @@ -747,7 +748,7 @@ basic_robot.commands.craftcache = {}; basic_robot.commands.craft = function(item, mode, idx,amount, name) amount = amount and tonumber(amount) or 1; - if amount<1 then amount = 1 end + if amount<0 then amount = 1 end if not item then return false end @@ -1152,7 +1153,7 @@ basic_robot.commands.machine = { energy = data.menergy or 0; - if amount>energy then return nil,"energy too low" end + if amount>energy or amount<0 then return nil,"energy too low" end if not tdata.menergy then tdata.menergy = 0 end tdata.menergy = tdata.menergy + amount diff --git a/basic_robot/init.lua b/basic_robot/init.lua index 2b5b0b8..6352e2d 100644 --- a/basic_robot/init.lua +++ b/basic_robot/init.lua @@ -26,7 +26,7 @@ basic_robot.bad_inventory_blocks = { -- disallow taking from these nodes invento basic_robot.http_api = minetest.request_http_api(); -basic_robot.version = "2020/10/14a"; +basic_robot.version = "2020/11/27a"; basic_robot.gui = {}; local robogui = basic_robot.gui -- gui management basic_robot.data = {}; -- stores all robot related data @@ -74,7 +74,7 @@ function getSandboxEnv (name) return end local yaw = obj:get_yaw(); - obj:set_velocity({x=v*math.cos(yaw),y=0,z=v*math.sin(yaw)}); + obj:set_velocity({x=-v*math.sin(yaw),y=0,z=v*math.cos(yaw)}); end, turn = { diff --git a/basic_robot/robogui.lua b/basic_robot/robogui.lua index cdaf651..6c236b4 100644 --- a/basic_robot/robogui.lua +++ b/basic_robot/robogui.lua @@ -172,8 +172,8 @@ 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,amount) crafts item if required materials are present in", - " inventory, mode = 1 returns recipe, optional recipe idx, optional ammount", + " craft(item,idx,mode) 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", },