Lua verlet integration

lua verlet integration self.canBreak self.restDist, self.breakDist local sep = (p1 – p2) local fac = (self.restDist – sep.magnitude) / sep.magnitude local restore = sep * 0.5 * fac point1.pos = not point1.inert and point1.pos + restore point2.pos = not point2.inert point2.pos – restore if self.canBreak and sep.magnitude > self.breakDist then self:tear() end

Lua verlet integration Read More

Lua variables

lua variables local NumberVariable = 1 local StringVariable = “TextHere” local BooleanVariable = true –// can also do false lua variables — Nil (no value) — Number => Example: 1234567890 — String => Example: “random text” — Function — Userdata — Boolean (true/fanse) — Table — Thread

Lua variables Read More

Lua tables

lua tables local favoritefoods_table = {“hamburger”, “spaghetti”, “pizza”, “potato chips”} –the table– for i, v in pairs(favoritefoods_table) do –loop through the table– print(i) –print the number– print(v) –print the value– end lua tables local Table = { [“TABLE_info”] = “TABLE_response” } for i, v in pairs(Table) do print(v) end

Lua tables Read More

Lua table insert

lua table insert t = { “the”, “quick”, “brown”, “fox” } table.insert (t, 2, “very”) — new element 2 table.insert (t, “jumped”) — add to end of table table.foreachi (t, print) –> 1 the 2 very 3 quick 4 brown 5 fox 6 jumped

Lua table insert Read More