This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local function linewrap( str, w ) | |
| if str:sub( 1, w + 1 ):find "\n" then | |
| return str:match "(.-)\n(.+)" | |
| end | |
| if str:sub( 1, w + 1 ):find "%s" then | |
| local pos = w - str:sub( 1, w + 1 ):reverse():find "%s" + 1 | |
| return str:sub( 1, pos), str:sub( pos + 2 ):gsub( "^%s+", "" ) | |
| end | |
| return str:sub( 1, w ), str:sub( w + 1 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --[[ | |
| newTextBody(string text) | |
| - creates a new text object with the given starting text | |
| - note: use :format() once created | |
| :format(int i = 1, int j = #lines) | |
| - updates the formatting on the range of lines given | |
| :insert(int n, string line) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| ["editor:TabWidth"] = 4; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local function copy( a, b ) | |
| if love.filesystem.isDirectory( a ) then | |
| for i, file in ipairs( love.filesystem.getDirectoryItems( a ) ) do | |
| copy( a .. "/" .. file, b .. "/" .. file ) | |
| end | |
| else | |
| love.filesystem.write( b, love.filesystem.read( a ) ) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local function isByte( n ) | |
| return type( n ) == "number" and n >= 0 and n < 256 | |
| end | |
| types.define( "byte", { type = "custom", value = isByte } ) | |
| types.define( "optional byte", "byte | nil" ) | |
| types.define( "colour", "{ byte, byte, byte, optional byte }" ) | |
| print( types.check( { 1, 2 }, "colour" ) ) --> false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Source | |
| int x = math::random() | |
| if x > 5 | |
| print( x < 3 ) | |
| else | |
| print( x > 7 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| types.parseMany [[ | |
| HasPosition: { "source" = string, "line" = number, "character" = number, "strline" = string } | |
| LeftUnaryExpressionOperator: "++" | "--" | "-" | "~" | "#" | "!" | |
| TokenType: "String" | "Integer" | "Number" | "Identifier" | "Symbol" | "Hexadecimal" | "Binary" | "Byte" | |
| ConstantExpressionType: "StringConstant" | "NumberConstant" | "IntegerConstant" | "ByteConstant" | "HexadecimalConstant" | "BinaryConstant" | |
| ThrowExpression: { "type" = "ThrowExpression", "value" = Expression } & HasPosition |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Position: { "source" = string, "line" = number, "character" = number, "strline" = string } | |
| HasPosition: { "position" = Position } | |
| ConstantExpressionType: "CharacterConstant" | "StringConstant" | "FloatConstant" | "IntegerConstant" | "ByteConstant" | "HexadecimalConstant" | "BinaryConstant" | |
| ConstantExpression: { "type" = ConstantExpressionType, "value" = string } & HasPosition | |
| ThrowExpression: { "type" = "ThrowExpression", "value" = Expression } & HasPosition | |
| FunctionExpression: { "type" = "FunctionExpression", "returns" = Type | nil, "parameters" = { number = { "name" = string, "class" = Type } } | {}, "body" = Block | nil } & HasPosition | |
| BracketExpression: { "type" = "BracketExpression", "value" = Expression } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local function concat(t, start, finish) | |
| local s = "" | |
| start = start or 1 | |
| finish = finish or #t | |
| while start <= finish do | |
| s = s .. t[start] | |
| start = start + 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local px = BLANK_PIXEL | |
| for i = 1, width * height do | |
| self.pixels[i] = px | |
| end |
OlderNewer