mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-23 18:07:39 +00:00
Merge pull request #360 from Wojbie/Mixed-lua-side-improvements.-Part-2
Mixed-Lua-side-improvements.-Part-2
This commit is contained in:
@@ -63,6 +63,7 @@ function drawLine( startX, startY, endX, endY, nColour )
|
|||||||
end
|
end
|
||||||
|
|
||||||
local minX = math.min( startX, endX )
|
local minX = math.min( startX, endX )
|
||||||
|
local maxX, minY, maxY
|
||||||
if minX == startX then
|
if minX == startX then
|
||||||
minY = startY
|
minY = startY
|
||||||
maxX = endX
|
maxX = endX
|
||||||
@@ -123,6 +124,7 @@ function drawBox( startX, startY, endX, endY, nColour )
|
|||||||
end
|
end
|
||||||
|
|
||||||
local minX = math.min( startX, endX )
|
local minX = math.min( startX, endX )
|
||||||
|
local maxX, minY, maxY
|
||||||
if minX == startX then
|
if minX == startX then
|
||||||
minY = startY
|
minY = startY
|
||||||
maxX = endX
|
maxX = endX
|
||||||
@@ -167,6 +169,7 @@ function drawFilledBox( startX, startY, endX, endY, nColour )
|
|||||||
end
|
end
|
||||||
|
|
||||||
local minX = math.min( startX, endX )
|
local minX = math.min( startX, endX )
|
||||||
|
local maxX, minY, maxY
|
||||||
if minX == startX then
|
if minX == startX then
|
||||||
minY = startY
|
minY = startY
|
||||||
maxX = endX
|
maxX = endX
|
||||||
|
|||||||
@@ -412,12 +412,23 @@ function complete( sSearchText, tSearchTable )
|
|||||||
if string.find( k, sPart, 1, true ) == 1 then
|
if string.find( k, sPart, 1, true ) == 1 then
|
||||||
if not g_tLuaKeywords[k] and string.match( k, "^[%a_][%a%d_]*$" ) then
|
if not g_tLuaKeywords[k] and string.match( k, "^[%a_][%a%d_]*$" ) then
|
||||||
local sResult = string.sub( k, nPartLength + 1 )
|
local sResult = string.sub( k, nPartLength + 1 )
|
||||||
if type(v) == "function" then
|
if nColon then
|
||||||
sResult = sResult .. "("
|
if type(v) == "function" then
|
||||||
elseif type(v) == "table" and next(v) ~= nil then
|
table.insert( tResults, sResult .. "(" )
|
||||||
sResult = sResult .. "."
|
elseif type(v) == "table" then
|
||||||
|
local tMetatable = getmetatable( v )
|
||||||
|
if tMetatable and ( type( tMetatable.__call ) == "function" or type( tMetatable.__call ) == "table" ) then
|
||||||
|
table.insert( tResults, sResult .. "(" )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if type(v) == "function" then
|
||||||
|
sResult = sResult .. "("
|
||||||
|
elseif type(v) == "table" and next(v) ~= nil then
|
||||||
|
sResult = sResult .. "."
|
||||||
|
end
|
||||||
|
table.insert( tResults, sResult )
|
||||||
end
|
end
|
||||||
table.insert( tResults, sResult )
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ while #tProcesses > 0 do
|
|||||||
-- Switch process
|
-- Switch process
|
||||||
local tabStart = 1
|
local tabStart = 1
|
||||||
for n=1,#tProcesses do
|
for n=1,#tProcesses do
|
||||||
tabEnd = tabStart + string.len( tProcesses[n].sTitle ) + 1
|
local tabEnd = tabStart + string.len( tProcesses[n].sTitle ) + 1
|
||||||
if x >= tabStart and x <= tabEnd then
|
if x >= tabStart and x <= tabEnd then
|
||||||
selectProcess( n )
|
selectProcess( n )
|
||||||
redrawMenu()
|
redrawMenu()
|
||||||
|
|||||||
@@ -642,7 +642,7 @@ while bRunning do
|
|||||||
if x > 1 then
|
if x > 1 then
|
||||||
-- Remove character
|
-- Remove character
|
||||||
local sLine = tLines[y]
|
local sLine = tLines[y]
|
||||||
if x > 4 and string.sub(sLine,x-4,x-1) == " " then
|
if x > 4 and string.sub(sLine,x-4,x-1) == " " and not string.sub(sLine, 1, x - 1):find("%S") then
|
||||||
tLines[y] = string.sub(sLine,1,x-5) .. string.sub(sLine,x)
|
tLines[y] = string.sub(sLine,1,x-5) .. string.sub(sLine,x)
|
||||||
setCursor( x - 4, y )
|
setCursor( x - 4, y )
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ local function loadLevel(nNum)
|
|||||||
fLevel = fs.open(sLevelD,"r")
|
fLevel = fs.open(sLevelD,"r")
|
||||||
fLevel.readLine()
|
fLevel.readLine()
|
||||||
for Line=2,Lines-1 do
|
for Line=2,Lines-1 do
|
||||||
sLine = fLevel.readLine()
|
local sLine = fLevel.readLine()
|
||||||
local chars = string.len(sLine)
|
local chars = string.len(sLine)
|
||||||
for char = 1, chars do
|
for char = 1, chars do
|
||||||
local el = string.sub(sLine,char,char)
|
local el = string.sub(sLine,char,char)
|
||||||
@@ -313,7 +313,7 @@ local function drawMap()
|
|||||||
term.setBackgroundColor(cG)
|
term.setBackgroundColor(cG)
|
||||||
term.setCursorPos(XOrgin+x,YOrgin+y+1)
|
term.setCursorPos(XOrgin+x,YOrgin+y+1)
|
||||||
|
|
||||||
sSide = string.sub(st,1,1)
|
local sSide = string.sub(st,1,1)
|
||||||
if sSide == "a" then
|
if sSide == "a" then
|
||||||
print("^")
|
print("^")
|
||||||
elseif sSide == "b" then
|
elseif sSide == "b" then
|
||||||
@@ -348,7 +348,7 @@ local function drawMap()
|
|||||||
term.setBackgroundColor(Cr)
|
term.setBackgroundColor(Cr)
|
||||||
term.setTextColor(colors.white)
|
term.setTextColor(colors.white)
|
||||||
term.setCursorPos(XOrgin+x,YOrgin+y+1)
|
term.setCursorPos(XOrgin+x,YOrgin+y+1)
|
||||||
sSide = string.sub(rb,1,1)
|
local sSide = string.sub(rb,1,1)
|
||||||
if sSide == "a" then
|
if sSide == "a" then
|
||||||
print("^")
|
print("^")
|
||||||
elseif sSide == "b" then
|
elseif sSide == "b" then
|
||||||
|
|||||||
@@ -276,7 +276,6 @@ local tMonsters = {
|
|||||||
local tRecipes = {
|
local tRecipes = {
|
||||||
["some planks"] = { "some wood" },
|
["some planks"] = { "some wood" },
|
||||||
["some sticks"] = { "some planks" },
|
["some sticks"] = { "some planks" },
|
||||||
["some sticks"] = { "some planks" },
|
|
||||||
["a crafting table"] = { "some planks" },
|
["a crafting table"] = { "some planks" },
|
||||||
["a furnace"] = { "some stone" },
|
["a furnace"] = { "some stone" },
|
||||||
["some torches"] = { "some sticks", "some coal" },
|
["some torches"] = { "some sticks", "some coal" },
|
||||||
@@ -753,7 +752,6 @@ function commands.dig( _sDir, _sTool )
|
|||||||
tTool = inventory[ sTool ]
|
tTool = inventory[ sTool ]
|
||||||
end
|
end
|
||||||
|
|
||||||
local room = getRoom( x, y, z )
|
|
||||||
local bActuallyDigging = (room.exits[ _sDir ] ~= true)
|
local bActuallyDigging = (room.exits[ _sDir ] ~= true)
|
||||||
if bActuallyDigging then
|
if bActuallyDigging then
|
||||||
if sTool == nil or tTool.toolType ~= "pick" then
|
if sTool == nil or tTool.toolType ~= "pick" then
|
||||||
|
|||||||
@@ -137,8 +137,6 @@ local function update( )
|
|||||||
end
|
end
|
||||||
|
|
||||||
local newHead = screen[newXPos][newYPos]
|
local newHead = screen[newXPos][newYPos]
|
||||||
term.setCursorPos(1,1);
|
|
||||||
print( newHead.snake )
|
|
||||||
if newHead.snake == true or newHead.wall == true then
|
if newHead.snake == true or newHead.wall == true then
|
||||||
bRunning = false
|
bRunning = false
|
||||||
|
|
||||||
|
|||||||
@@ -87,11 +87,6 @@ elseif sCommand == "host" then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Close the channel
|
|
||||||
print( "Closing channel" )
|
|
||||||
modem.close( gps.CHANNEL_GPS )
|
|
||||||
|
|
||||||
else
|
else
|
||||||
-- "gps somethingelse"
|
-- "gps somethingelse"
|
||||||
-- Error
|
-- Error
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
local tArgs = { ... }
|
local tArgs = { ... }
|
||||||
|
local sTopic
|
||||||
if #tArgs > 0 then
|
if #tArgs > 0 then
|
||||||
sTopic = tArgs[1]
|
sTopic = tArgs[1]
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -473,7 +473,7 @@ local function playGame()
|
|||||||
if testBlockAt(curBlock,curX,curY+1,curRot) then
|
if testBlockAt(curBlock,curX,curY+1,curRot) then
|
||||||
pitBlock(curBlock,curX,curY,curRot)
|
pitBlock(curBlock,curX,curY,curRot)
|
||||||
--detect rows that clear
|
--detect rows that clear
|
||||||
clearRows(rows)
|
clearRows()
|
||||||
|
|
||||||
curBlock=next
|
curBlock=next
|
||||||
curX=4
|
curX=4
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ if sCommand == "host" then
|
|||||||
|
|
||||||
local tUsers = {}
|
local tUsers = {}
|
||||||
local nUsers = 0
|
local nUsers = 0
|
||||||
function send( sText, nUserID )
|
local function send( sText, nUserID )
|
||||||
if nUserID then
|
if nUserID then
|
||||||
local tUser = tUsers[ nUserID ]
|
local tUser = tUsers[ nUserID ]
|
||||||
if tUser then
|
if tUser then
|
||||||
@@ -81,7 +81,7 @@ if sCommand == "host" then
|
|||||||
|
|
||||||
-- Setup ping pong
|
-- Setup ping pong
|
||||||
local tPingPongTimer = {}
|
local tPingPongTimer = {}
|
||||||
function ping( nUserID )
|
local function ping( nUserID )
|
||||||
local tUser = tUsers[ nUserID ]
|
local tUser = tUsers[ nUserID ]
|
||||||
rednet.send( tUser.nID, {
|
rednet.send( tUser.nID, {
|
||||||
sType = "ping to client",
|
sType = "ping to client",
|
||||||
@@ -93,7 +93,7 @@ if sCommand == "host" then
|
|||||||
tPingPongTimer[ timer ] = nUserID
|
tPingPongTimer[ timer ] = nUserID
|
||||||
end
|
end
|
||||||
|
|
||||||
function printUsers()
|
local function printUsers()
|
||||||
local x,y = term.getCursorPos()
|
local x,y = term.getCursorPos()
|
||||||
term.setCursorPos( 1, y - 1 )
|
term.setCursorPos( 1, y - 1 )
|
||||||
term.clearLine()
|
term.clearLine()
|
||||||
@@ -274,7 +274,7 @@ elseif sCommand == "join" then
|
|||||||
local bPingPonged = true
|
local bPingPonged = true
|
||||||
local pingPongTimer = os.startTimer( 0 )
|
local pingPongTimer = os.startTimer( 0 )
|
||||||
|
|
||||||
function ping()
|
local function ping()
|
||||||
rednet.send( nHostID, {
|
rednet.send( nHostID, {
|
||||||
sType = "ping to server",
|
sType = "ping to server",
|
||||||
nUserID = nUserID,
|
nUserID = nUserID,
|
||||||
@@ -296,7 +296,7 @@ elseif sCommand == "join" then
|
|||||||
term.redirect( promptWindow )
|
term.redirect( promptWindow )
|
||||||
promptWindow.restoreCursor()
|
promptWindow.restoreCursor()
|
||||||
|
|
||||||
function drawTitle()
|
local function drawTitle()
|
||||||
local x,y = titleWindow.getCursorPos()
|
local x,y = titleWindow.getCursorPos()
|
||||||
local w,h = titleWindow.getSize()
|
local w,h = titleWindow.getSize()
|
||||||
local sTitle = sUsername.." on "..sHostname
|
local sTitle = sUsername.." on "..sHostname
|
||||||
@@ -307,7 +307,7 @@ elseif sCommand == "join" then
|
|||||||
promptWindow.restoreCursor()
|
promptWindow.restoreCursor()
|
||||||
end
|
end
|
||||||
|
|
||||||
function printMessage( sMessage )
|
local function printMessage( sMessage )
|
||||||
term.redirect( historyWindow )
|
term.redirect( historyWindow )
|
||||||
print()
|
print()
|
||||||
if string.match( sMessage, "^%*" ) then
|
if string.match( sMessage, "^%*" ) then
|
||||||
|
|||||||
@@ -208,13 +208,11 @@ shell.setCompletionFunction( "rom/programs/command/exec.lua", completeExec )
|
|||||||
if turtle then
|
if turtle then
|
||||||
local tGoOptions = { "left", "right", "forward", "back", "down", "up" }
|
local tGoOptions = { "left", "right", "forward", "back", "down", "up" }
|
||||||
local function completeGo( shell, nIndex, sText )
|
local function completeGo( shell, nIndex, sText )
|
||||||
return completeMultipleChoice(sText,tGoOptions)
|
return completeMultipleChoice( sText, tGoOptions, true)
|
||||||
end
|
end
|
||||||
local tTurnOptions = { "left", "right" }
|
local tTurnOptions = { "left", "right" }
|
||||||
local function completeTurn( shell, nIndex, sText )
|
local function completeTurn( shell, nIndex, sText )
|
||||||
if nIndex == 1 then
|
return completeMultipleChoice( sText, tTurnOptions, true )
|
||||||
return completeMultipleChoice( sText, tTurnOptions )
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
local tEquipOptions = { "left", "right" }
|
local tEquipOptions = { "left", "right" }
|
||||||
local function completeEquip( shell, nIndex, sText )
|
local function completeEquip( shell, nIndex, sText )
|
||||||
|
|||||||
Reference in New Issue
Block a user