mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.7.10
This commit is contained in:
commit
10853f7a9a
@ -21,7 +21,7 @@ local function get(pasteId, filename)
|
||||
end
|
||||
|
||||
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)
|
||||
if result then
|
||||
io.write("success.\n")
|
||||
|
@ -15,7 +15,8 @@ function loadfile(filename, mode, env)
|
||||
end
|
||||
table.insert(buffer, data)
|
||||
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)
|
||||
end
|
||||
|
||||
|
@ -11,10 +11,10 @@ function internet.request(url, data, headers)
|
||||
checkArg(2, data, "string", "table", "nil")
|
||||
checkArg(3, headers, "table", "nil")
|
||||
|
||||
local inet = component.internet
|
||||
if not inet then
|
||||
if not component.isAvailable("internet") then
|
||||
error("no primary internet card found", 2)
|
||||
end
|
||||
local inet = component.internet
|
||||
|
||||
local post
|
||||
if type(data) == "string" then
|
||||
@ -31,23 +31,35 @@ function internet.request(url, data, headers)
|
||||
error(reason, 2)
|
||||
end
|
||||
|
||||
return function()
|
||||
while true do
|
||||
local data, reason = request.read()
|
||||
if not data then
|
||||
request.close()
|
||||
if reason then
|
||||
error(reason, 2)
|
||||
else
|
||||
return nil -- eof
|
||||
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
|
||||
local data, reason = request.read()
|
||||
if not data then
|
||||
request.close()
|
||||
if reason then
|
||||
error(reason, 2)
|
||||
else
|
||||
return nil -- eof
|
||||
end
|
||||
elseif #data > 0 then
|
||||
return data
|
||||
end
|
||||
elseif #data > 0 then
|
||||
return data
|
||||
-- else: no data, block
|
||||
os.sleep(0)
|
||||
end
|
||||
-- else: no data, block
|
||||
os.sleep(0)
|
||||
end
|
||||
end
|
||||
end,
|
||||
__index = request,
|
||||
})
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
@ -390,7 +390,13 @@ function term.drawText(value, wrap, window)
|
||||
local function scroll(_sy,_y)
|
||||
return _sy + term.internal.scroll(window,_y-h), math.min(_y,h)
|
||||
end
|
||||
local uptime = computer.uptime
|
||||
local last_sleep = uptime()
|
||||
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)
|
||||
si = si or vlen+1
|
||||
if index==si then
|
||||
@ -401,7 +407,7 @@ function term.drawText(value, wrap, window)
|
||||
x,y=1,y+1
|
||||
sy,y = scroll(sy,y)
|
||||
elseif delim=="\a" and not beeped then
|
||||
require("computer").beep()
|
||||
computer.beep()
|
||||
beeped = true
|
||||
end
|
||||
cr_last = delim == "\r"
|
||||
|
@ -660,7 +660,7 @@ object Settings {
|
||||
}
|
||||
|
||||
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) =>
|
||||
if (x == ctx.nonce) None
|
||||
else Some("debug card is invalidated, please re-bind it to yourself")
|
||||
|
@ -19,7 +19,7 @@ class DebugCard(val parent: Delegator) extends traits.Delegate {
|
||||
}
|
||||
|
||||
override def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = {
|
||||
if (player.isSneaking) {
|
||||
if (!world.isRemote && player.isSneaking) {
|
||||
val data = new DebugCardData(stack)
|
||||
val name = player.getCommandSenderName
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user