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