Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions session1/plugin-development-intro/lua-cheatsheet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,18 @@ elseif condition then
else
print("no")
end
Variables
```

## Variables

```lua
local x = 2
two, four = 2, 4
Functions
```

## Functions

```lua
function myFunction()
return 1
end
Expand All @@ -100,7 +108,11 @@ function doAction(action, ...)
end

doAction('write', "Shirley", "Abed")
Lookups
```

## Lookups

```lua
mytable = { x = 2, y = function() .. end }

-- The same:
Expand All @@ -116,7 +128,11 @@ mytable:y(a, b)

function X:y(z) .. end
function X.y(self, z) .. end
Metatables
```

## Metatables

```lua
mt = {}

-- A metatable is simply a table with functions in it.
Expand Down