parent
0a7c5d33d8
commit
539144f05b
13
commands.lua
13
commands.lua
|
@ -488,11 +488,11 @@ basic_robot.give_drops = function(nodename, inv) -- gives apropriate drops when
|
|||
local i = 0;
|
||||
for k,v in pairs(drop.items) do
|
||||
if i > max_items then break end; i=i+1;
|
||||
local rare = v.rarity or 0;
|
||||
local rare = v.rarity or 1;
|
||||
if rare>0 and math.random(1, rare)==1 then
|
||||
dropname = v.items[math.random(1,#v.items)]; -- pick item randomly from list
|
||||
inv:add_item("main",dropname);
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
|
@ -756,8 +756,11 @@ basic_robot.commands.keyboard = {
|
|||
|
||||
basic_robot.commands.craftcache = {};
|
||||
|
||||
basic_robot.commands.craft = function(item, mode, idx, name)
|
||||
basic_robot.commands.craft = function(item, mode, idx,amount, name)
|
||||
amount = amount and tonumber(amount) or 1;
|
||||
if amount<0 then amount = 1 end
|
||||
if not item then return false end
|
||||
|
||||
|
||||
local cache = basic_robot.commands.craftcache[name];
|
||||
if not cache then basic_robot.commands.craftcache[name] = {}; cache = basic_robot.commands.craftcache[name] end
|
||||
|
@ -820,12 +823,12 @@ basic_robot.commands.craft = function(item, mode, idx, name)
|
|||
local inv = minetest.get_meta(pos):get_inventory();
|
||||
|
||||
for item,quantity in pairs(itemlist) do
|
||||
local stack = ItemStack(item .. " " .. quantity);
|
||||
local stack = ItemStack(item .. " " .. quantity*amount);
|
||||
if not inv:contains_item("main",stack) then return false end
|
||||
end
|
||||
|
||||
for item,quantity in pairs(itemlist) do
|
||||
local stack = ItemStack(item .. " " .. quantity);
|
||||
local stack = ItemStack(item .. " " .. quantity*amount);
|
||||
inv:remove_item("main",stack);
|
||||
end
|
||||
|
||||
|
|
8
init.lua
8
init.lua
|
@ -25,7 +25,7 @@ basic_robot.bad_inventory_blocks = { -- disallow taking from these nodes invento
|
|||
|
||||
basic_robot.http_api = minetest.request_http_api();
|
||||
|
||||
basic_robot.version = "2018/12/24a";
|
||||
basic_robot.version = "2019/01/13a";
|
||||
|
||||
basic_robot.gui = {}; local robogui = basic_robot.gui -- gui management
|
||||
basic_robot.data = {}; -- stores all robot related data
|
||||
|
@ -86,8 +86,8 @@ function getSandboxEnv (name)
|
|||
return commands.pickup(r, name);
|
||||
end,
|
||||
|
||||
craft = function(item, idx,mode)
|
||||
return commands.craft(item, mode, idx, name)
|
||||
craft = function(item, idx,mode, amount)
|
||||
return commands.craft(item, mode, idx, amount, name)
|
||||
end,
|
||||
|
||||
pause = function() -- pause coroutine
|
||||
|
@ -808,7 +808,7 @@ end
|
|||
local function setupid(owner)
|
||||
local privs = minetest.get_player_privs(owner); if not privs then return end
|
||||
local maxid = basic_robot.entry_count;
|
||||
if privs.robot then maxid = basic_robot.advanced_count end -- max id's per user
|
||||
if privs.robot or privs.puzzle then maxid = basic_robot.advanced_count end -- max id's per user
|
||||
basic_robot.ids[owner] = {id = 1, maxid = maxid}; --active id for remove control
|
||||
end
|
||||
|
||||
|
|
|
@ -25,8 +25,18 @@ if not fetch then
|
|||
self.label(os.date("%X") ..', cmd : ' .. req)
|
||||
local i = string.find(req," !")
|
||||
if i then
|
||||
run_commmand(string.sub(req,i+2))
|
||||
local cmd = string.sub(req,i+2)
|
||||
if cmd == "players" then
|
||||
local players = minetest.get_connected_players();
|
||||
out = {};
|
||||
for i = 1,#players do out[i] = players[i]:get_player_name() end
|
||||
MT2web("online players : " .. table.concat(out,", "))
|
||||
else
|
||||
run_commmand(cmd)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -49,6 +59,8 @@ if not fetch then
|
|||
fetch({url = "http://".. address .. "/mtmsg/"..message, timeout = 5}, result)
|
||||
end
|
||||
MT2web("minetest robot started and listening.")
|
||||
|
||||
self.listen(1)
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue