drops abuse fixed
.. replaced with safe string.concat(table of strings, separator)
This commit is contained in:
parent
21158c67eb
commit
a790d0cd62
@ -490,8 +490,8 @@ basic_robot.give_drops = function(nodename, inv) -- gives apropriate drops when
|
|||||||
local i = 0;
|
local i = 0;
|
||||||
for k,v in pairs(drop.items) do
|
for k,v in pairs(drop.items) do
|
||||||
if i > max_items then break end; i=i+1;
|
if i > max_items then break end; i=i+1;
|
||||||
local rare = v.rarity or 1;
|
local rare = v.rarity or 0;
|
||||||
if math.random(1, rare)==1 then
|
if rare>0 and math.random(1, rare)==1 then
|
||||||
dropname = v.items[math.random(1,#v.items)]; -- pick item randomly from list
|
dropname = v.items[math.random(1,#v.items)]; -- pick item randomly from list
|
||||||
inv:add_item("main",dropname);
|
inv:add_item("main",dropname);
|
||||||
|
|
||||||
|
19
init.lua
19
init.lua
@ -16,6 +16,10 @@ basic_robot.dig_require_energy = true; -- does robot require energy to dig stone
|
|||||||
|
|
||||||
basic_robot.bad_inventory_blocks = { -- disallow taking from these nodes inventories to prevent player abuses
|
basic_robot.bad_inventory_blocks = { -- disallow taking from these nodes inventories to prevent player abuses
|
||||||
["craft_guide:sign_wall"] = true,
|
["craft_guide:sign_wall"] = true,
|
||||||
|
["basic_machines:battery_0"] = true,
|
||||||
|
["basic_machines:battery_1"] = true,
|
||||||
|
["basic_machines:battery_2"] = true,
|
||||||
|
["basic_machines:generator"] = true,
|
||||||
}
|
}
|
||||||
----- END OF SETTINGS ------
|
----- END OF SETTINGS ------
|
||||||
|
|
||||||
@ -361,6 +365,18 @@ function getSandboxEnv (name)
|
|||||||
len = string.len, lower = string.lower,
|
len = string.len, lower = string.lower,
|
||||||
upper = string.upper, rep = string.rep,
|
upper = string.upper, rep = string.rep,
|
||||||
reverse = string.reverse, sub = string.sub,
|
reverse = string.reverse, sub = string.sub,
|
||||||
|
|
||||||
|
concat = function(strings, sep)
|
||||||
|
local length = 0;
|
||||||
|
for i = 1,#strings do
|
||||||
|
length = length + string.len(strings[i])
|
||||||
|
if length > 1024 then
|
||||||
|
error("result string longer than 1024")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return table.concat(strings,sep or "")
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
math = {
|
math = {
|
||||||
abs = math.abs, acos = math.acos,
|
abs = math.abs, acos = math.acos,
|
||||||
@ -545,7 +561,7 @@ end
|
|||||||
|
|
||||||
check_code = function(code)
|
check_code = function(code)
|
||||||
--"while ", "for ", "do ","goto ",
|
--"while ", "for ", "do ","goto ",
|
||||||
local bad_code = {"repeat", "until", "_ccounter", "_G", "while%(", "while{", "pcall"} --,"\\\"", "%[=*%[","--[["}
|
local bad_code = {"repeat", "until", "_ccounter", "_G", "while%(", "while{", "pcall",".."} --,"\\\"", "%[=*%[","--[["}
|
||||||
for _, v in pairs(bad_code) do
|
for _, v in pairs(bad_code) do
|
||||||
if string.find(code, v) then
|
if string.find(code, v) then
|
||||||
return v .. " is not allowed!";
|
return v .. " is not allowed!";
|
||||||
@ -1426,6 +1442,7 @@ local on_receive_robot_form = function(pos, formname, fields, sender)
|
|||||||
" code.run(text) compiles and runs the code in sandbox (privs only)\n"..
|
" code.run(text) compiles and runs the code in sandbox (privs only)\n"..
|
||||||
" code.set(text) replaces current bytecode of robot\n"..
|
" code.set(text) replaces current bytecode of robot\n"..
|
||||||
" find_nodes(\"default:dirt\",3) returns distance to node in radius 3 around robot, or false if none\n"..
|
" find_nodes(\"default:dirt\",3) returns distance to node in radius 3 around robot, or false if none\n"..
|
||||||
|
" string.concat({string1,string2,...}, separator) returns concatenated string. maxlength 1024\n"..
|
||||||
"**PLAYERS\n"..
|
"**PLAYERS\n"..
|
||||||
" find_player(3,pos) finds players in radius 3 around robot(position) and returns list, if none returns nil\n"..
|
" find_player(3,pos) finds players in radius 3 around robot(position) and returns list, if none returns nil\n"..
|
||||||
" attack(target) attempts to attack target player if nearby \n"..
|
" attack(target) attempts to attack target player if nearby \n"..
|
||||||
|
Loading…
x
Reference in New Issue
Block a user