Skip to content

Instantly share code, notes, and snippets.

View simsaens's full-sized avatar

Sim Saëns simsaens

  • Two Lives Left
  • Adelaide, Australia
View GitHub Profile
@simsaens
simsaens / Docs.md
Last active October 1, 2025 13:46
Codea Runtime Documentation (1 Oct 2025)

Codea API

Gravity (const)

ID: Gravity
Group: Detecting Motion

This global variable represents the current direction and amount of gravity relative to the screen orientation while the viewer is running. The y component of this vector will almost always be negative, indicating that the device is being held upright.

Syntax

@simsaens
simsaens / Main.lua
Created September 8, 2025 12:37
Loading while showing progress in Codea
-- Progress Loading Test
-- Demonstrates long loading in setup() with progress updates
local socket = require("socket")
local loadProgress = 0
local isLoading = true
local loadCoroutine
function setup()
print("Starting long loading process...")
@simsaens
simsaens / MainActorIsolationSample.swift
Created July 20, 2024 13:42
Unsure why warnings show in the second example unless the method is marked @mainactor
import AVFoundation
class Foo {
var x: AVAudioFile?
func someOtherMethod() async throws {
x = try AVAudioFile(forReading: URL(fileURLWithPath: "/path/to/file.m4a"))
}
//@MainActor annotation is not needed here and there are no warnings, why is it needed below?
/* global exports:true, module:true, require:true, define:true, global:true */
(function (root, name, factory) {
'use strict';
// Used to determine if values are of the language type `Object`
var objectTypes = {
'function': true
, 'object': true
}
@simsaens
simsaens / JAMLuaTokenizer.swift
Created April 9, 2024 12:31
Codea's Lua UITextInputTokenizer
//
// JAMLuaTokenizer.swift
// JamKit
//
// Created by Sim Saens on 7/4/2024.
// Copyright © 2024 Two Lives Left. All rights reserved.
//
import UIKit
-- Dungeon variables
local dungeonWidth = 16 -- The width of the dungeon in tiles
local dungeonHeight = 16 -- The height of the dungeon in tiles
local tileSize = 40 -- The size of each tile in pixels
local dungeon = {} -- The dungeon map
local rooms = {} -- The list of rooms in the dungeon
local doors = {} -- The list of doors in the dungeon
local traps = {} -- The list of traps in the dungeon
-- Colors
@simsaens
simsaens / SKPayment+Async.swift
Created December 20, 2021 05:39
These three files extend the default StoreKit API to use async in Swift 5.5. Based on the PromiseKit StoreKit extensions
//
// SKPayment+Async.swift
//
// Created by Sim Saens on 15/12/21.
//
import Foundation
import StoreKit
//Adds an async extension to SKPayment to purchase products
@simsaens
simsaens / InstancedSnow.lua
Created April 28, 2021 06:04
Codea project which uses mesh instancing to draw snow
--# Main
-- 3D Snow
function setup()
viewer.mode = FULLSCREEN
parameter.watch("FPS")
parameter.boolean("camOrtho", false)
parameter.number("timeSpeed", 0, 8, 1)
parameter.number("hspread", 0, 50, 50)
@simsaens
simsaens / Main.lua
Last active March 22, 2020 00:08
Updated 3D Asset Viewer #2
-----------------------------------------
-- Models
-- Written by John Millard
-----------------------------------------
-- Description:
-- Domonstrates model loading in Craft.
-----------------------------------------
Tag = class()
@simsaens
simsaens / Main.lua
Created March 21, 2020 23:49
Updated 3D Asset Viewer
-----------------------------------------
-- Models
-- Written by John Millard
-----------------------------------------
-- Description:
-- Domonstrates model loading in Craft.
-----------------------------------------
Tag = class()