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
| const circle1 = 1; | |
| const circle2 = 2; | |
| const circle3 = 3; | |
| let time = 0.0; | |
| let step = 0; | |
| function tick(delta) { | |
| time += delta; | |
| if (time >= 1000) { |
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 circle1 = 1 | |
| local circle2 = 2 | |
| local circle3 = 3 | |
| local time = 0.0 | |
| local step = 0 | |
| function tick(delta) | |
| time = time + delta | |
| if (time >= 1000) then |
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
| vm.globals["addWidget"] = vm.createFunction([ | |
| String.arg, // widget name | |
| Int64.arg, // tag | |
| Number.arg, // x coordinate | |
| Number.arg, // y coordinate | |
| Number.arg, // radius | |
| String.arg // color hex string | |
| ]) { (args) -> SwiftReturnValue in | |
| let (widgetName, widgetTag, xCoordinate, yCoordinate, radius, hexColor) = ( | |
| args.string, args.integer, args.number, args.number, args.number, args.string |
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
| vm.globals["updateProperty"] = vm.createFunction([ | |
| Int64.arg, // tag | |
| String.arg, // attribute name | |
| String.arg // attribute value | |
| ]) { (args) -> SwiftReturnValue in | |
| let (widgetTag, attributeName, attributeValue) = ( | |
| args.integer, args.string, args.string | |
| ) | |
| guard let w = self.vPluginContainer.viewWithTag(Int(widgetTag)) else { return .nothing } |
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
| guard let luaSourcePath = Bundle.main.path(forResource: "luaPluginCode", ofType: "lua") else { | |
| print("LUA file not found") | |
| return | |
| } | |
| do { | |
| let luaCode = try String(contentsOfFile: luaSourcePath) | |
| let result = vm.createFunction(luaCode) | |
| switch result { | |
| case .value(let f): |
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
| import UIKit | |
| import JavaScriptCore | |
| class JSViewController: UIViewController { | |
| @IBOutlet weak var vPluginContainer: UIView! | |
| let jsContext = JSContext()! | |
| var timer: Timer? = nil |
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
| import UIKit | |
| import Lua | |
| class LuaViewController: UIViewController { | |
| @IBOutlet weak var vPluginContainer: UIView! | |
| let vm = Lua.VirtualMachine() | |
| var startFunc: Function? | |
| var tickFunc: Function? | |
| var timer: Timer? |
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
| import Foundation | |
| let circle1 = 1 | |
| let circle2 = 2 | |
| let circle3 = 3 | |
| var time = 0.0 | |
| var step = 0 | |
| public var updateProperty: (_ tag: Int, _ property: String, _ value: Any) -> Void = { (_, _, _) in } |
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
| import UIKit | |
| import DynamicLights | |
| class FrameworkViewController: UIViewController { | |
| @IBOutlet weak var vPluginContainer: UIView! | |
| var timer: Timer? | |
| @IBAction func runPlugin() { | |
| DynamicLights.updateProperty = { [weak self] (tag, property, value) in |
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
| import Foundation | |
| let circle1 = 1 | |
| let circle2 = 2 | |
| let circle3 = 3 | |
| var time = 0.0 | |
| var step = 0 | |
| var updateProperty: (_ tag: Int, _ property: String, _ value: Any) -> Void |