Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.7.10

This commit is contained in:
Florian Nücke 2017-02-05 16:01:51 +01:00
commit 10853f7a9a
6 changed files with 41 additions and 22 deletions

View File

@ -21,7 +21,7 @@ local function get(pasteId, filename)
end end
io.write("Downloading from pastebin.com... ") io.write("Downloading from pastebin.com... ")
local url = "http://pastebin.com/raw.php?i=" .. pasteId local url = "http://pastebin.com/raw/" .. pasteId
local result, response = pcall(internet.request, url) local result, response = pcall(internet.request, url)
if result then if result then
io.write("success.\n") io.write("success.\n")

View File

@ -15,7 +15,8 @@ function loadfile(filename, mode, env)
end end
table.insert(buffer, data) table.insert(buffer, data)
end end
buffer = table.concat(buffer):gsub("^#![^\n]+", "") -- remove shebang if any buffer[1] = (buffer[1] or ""):gsub("^#![^\n]+", "") -- remove shebang if any
buffer = table.concat(buffer)
return load(buffer, "=" .. filename, mode, env) return load(buffer, "=" .. filename, mode, env)
end end

View File

@ -11,10 +11,10 @@ function internet.request(url, data, headers)
checkArg(2, data, "string", "table", "nil") checkArg(2, data, "string", "table", "nil")
checkArg(3, headers, "table", "nil") checkArg(3, headers, "table", "nil")
local inet = component.internet if not component.isAvailable("internet") then
if not inet then
error("no primary internet card found", 2) error("no primary internet card found", 2)
end end
local inet = component.internet
local post local post
if type(data) == "string" then if type(data) == "string" then
@ -31,7 +31,17 @@ function internet.request(url, data, headers)
error(reason, 2) error(reason, 2)
end end
return function() return setmetatable(
{
["()"] = "function():string -- Tries to read data from the socket stream and return the read byte array.",
close = setmetatable({},
{
__call = request.close,
__tostring = function() return "function() -- closes the connection" end
})
},
{
__call = function()
while true do while true do
local data, reason = request.read() local data, reason = request.read()
if not data then if not data then
@ -47,7 +57,9 @@ function internet.request(url, data, headers)
-- else: no data, block -- else: no data, block
os.sleep(0) os.sleep(0)
end end
end end,
__index = request,
})
end end
------------------------------------------------------------------------------- -------------------------------------------------------------------------------

View File

@ -390,7 +390,13 @@ function term.drawText(value, wrap, window)
local function scroll(_sy,_y) local function scroll(_sy,_y)
return _sy + term.internal.scroll(window,_y-h), math.min(_y,h) return _sy + term.internal.scroll(window,_y-h), math.min(_y,h)
end end
local uptime = computer.uptime
local last_sleep = uptime()
while index <= vlen do while index <= vlen do
if uptime() - last_sleep > 4 then
os.sleep(0)
last_sleep = uptime()
end
local si,ei = value:find("[\t\r\n\a]", index) local si,ei = value:find("[\t\r\n\a]", index)
si = si or vlen+1 si = si or vlen+1
if index==si then if index==si then
@ -401,7 +407,7 @@ function term.drawText(value, wrap, window)
x,y=1,y+1 x,y=1,y+1
sy,y = scroll(sy,y) sy,y = scroll(sy,y)
elseif delim=="\a" and not beeped then elseif delim=="\a" and not beeped then
require("computer").beep() computer.beep()
beeped = true beeped = true
end end
cr_last = delim == "\r" cr_last = delim == "\r"

View File

@ -660,7 +660,7 @@ object Settings {
} }
def checkAccess(ctxOpt: Option[DebugCard.AccessContext]): Option[String] = ctxOpt match { def checkAccess(ctxOpt: Option[DebugCard.AccessContext]): Option[String] = ctxOpt match {
case Some(ctx) => values.get(ctx.player) match { case Some(ctx) => values.get(ctx.player.toLowerCase) match {
case Some(x) => case Some(x) =>
if (x == ctx.nonce) None if (x == ctx.nonce) None
else Some("debug card is invalidated, please re-bind it to yourself") else Some("debug card is invalidated, please re-bind it to yourself")

View File

@ -19,7 +19,7 @@ class DebugCard(val parent: Delegator) extends traits.Delegate {
} }
override def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = { override def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = {
if (player.isSneaking) { if (!world.isRemote && player.isSneaking) {
val data = new DebugCardData(stack) val data = new DebugCardData(stack)
val name = player.getCommandSenderName val name = player.getCommandSenderName