LuaBox Helper for call lua scripts on Kotlin

Related tags

App LuaBox
Overview

LuaBox

Helper for call lua scripts on Kotlin!

Big thanks to Luaj library!

1. Create a class for working with LuaBox:

class ScriptCore: LuaBox(
    path = "${System.getProperty("user.home")}${File.separator}LuaBoxFolder${File.separator}"
) {
    
}

2. Add new indexes:

If you want to add some Kotlin or Java object to your lua scripts use the addIndex(key: String, value: Any) function:

Kotlin:

// ScriptCore.kt

companion object {
    const val greeting = "Hello!"
    fun printHi() = println("Hi!")
}

init {
    addIndex("kotlinObject", Companion)
    addIndex("greeting", greeting)
}

Lua:

kotlinObject:printHi()
print(greeting) --Hello!

3. Call script:

val script = ScriptCore().newScript("Script.lua")
script.call()

In this case, the Script.lua should be located in C:/Users/User/LuaBoxFolder/Script.lua

4. Call function:

Kotlin:

val script = ScriptCore().newScript("Script.lua")

script.callFunction("function_name")

script.callFunction(
    "function_with_args",
    CoerceJavaToLua.coerce("You Got LuaBoxed!!!"),
    CoerceJavaToLua.coerce(711)
)

Lua:

function function_name()
    --some code
end

function function_with_args(arg1, arg2)
    print(arg1 == "You Got LuaBoxed!!!") --true
    print(arg2 == 711) --true
end
You might also like...
A collection of custom Android/Kotlin lint checks we use in our Android and Kotlin code bases at Slack.

slack-lints This repository contains a collection of custom Android/Kotlin lint checks we use in our Android and Kotlin code bases at Slack. This repo

This is a practical project for Professional Android Developers that covers clean Architecture basics using the following: skills: Real-like coding with Kotlin, MVVM Design pattern, Kotlin Coroutines, Room database, Navigation Controller, Jetpack compose, Use cases, and Dependency injection using Dagger-Hilt. Primeiro aplicativo desenvolvido na linguagem kotlin, durante o Hackathon no curso de Android Kotlin da Cel.Lep em parceria com Estação Hack from Facebook
Primeiro aplicativo desenvolvido na linguagem kotlin, durante o Hackathon no curso de Android Kotlin da Cel.Lep em parceria com Estação Hack from Facebook

Tela Splash: Nome do aplicativo e uma imagem: Tela Main, principal tela do aplicativo: Um campo para o usuário informar a medida; Um spinner com os ti

MVVM + Kotlin + Jetpack Compose +Navigation Compose + Hilt + Retrofit + Unit Testing + Compose Testing + Coroutines + Kotlin Flow + Io mockK
MVVM + Kotlin + Jetpack Compose +Navigation Compose + Hilt + Retrofit + Unit Testing + Compose Testing + Coroutines + Kotlin Flow + Io mockK

MvvmKotlinJetpackCompose Why do we need an architecture even when you can make an app without it? let's say you created a project without any architec

A general purpose kotlin library that use kotlin coroutines, flows and channels to provide timer features with the most easy and efficient way

Timer Timer is a general purpose kotlin library that use kotlin coroutines, flows and channels to provide timer features with the most easy and effici

Solution to the 2021 Advent of code challenge in Kotlin. aoc-2021-in-kotlin

advent-of-code-2021 Welcome to the Advent of Code1 Kotlin project created by aniobistanley using the Advent of Code Kotlin Template delivered by JetBr

Android-basics-kotlin-tip-time-app - Tip Time app from Android Basics in Kotlin
Android-basics-kotlin-tip-time-app - Tip Time app from Android Basics in Kotlin

Tip Time Tip Time app from Android Basics in Kotlin at developers.google.com. It

Coinbase-pro-feed-kotlin - Kotlin Coinbase Pro Level 2 Order Book Feed
Coinbase-pro-feed-kotlin - Kotlin Coinbase Pro Level 2 Order Book Feed

Kotlin Coinbase Pro Level 2 Order Book Feed Quick start Depending on your OS run

Kotlin-basic-calculator - Basic calculator to understand syntax and the methods of Kotlin

KotlinBasicCalculator I always love to create a calculater for understand the sy

Owner
Мяучер
мяучер#5234
Мяучер
Linuxcnc probescripts - Collection of scripts for several touch-probe routines

linuxcnc_probescripts Collection of scripts for several touch-probe routines. Al

Multifuchs UG (haftungsbeschränkt) 0 Jan 30, 2022
AndroidEssentials is an android library that creates helper functions for performing common tasks in Android

AndroidEssentials is an android library that creates helper functions for performing common tasks in Android such as managing preferences, managing files, showing alerts, showing toasts, checking user country & checking network connection of users. All the methods of the class are static and should be accessed directly from the AndroidEssentials class.

Isaac Sichangi 3 Jul 7, 2022
Helper tool for calculating scales for Teenage Engineering Pocket Operator PO-33/133 & PO-35/137 series.

I heard you like Pocket Operators, so I made Pocket Scale Calculator for your Pocket Operator. This console app is a helper tool for calculating scale

null 8 Nov 7, 2022
A handy phone call manager with phonebook, number blocking and multi-SIM support

Simple Dialer A lightweight app for handling your calls, no matter where are you. Comes with a handy call log for easy call initiation. There is a qui

Simple Mobile Tools 422 Nov 23, 2022
Initiate immediate phone call for React Native on iOS and Android.

react-native-immediate-call-library Initiate immediate phone call for React Native on iOS and Android. Getting started Using npm: npm install react-na

null 7 Sep 7, 2022
⏺ A simple android app to browse your phone call recordings

⏺ Reky A simple android app to browse your phone call recordings [Under Construction] ✅ TODO Support more file name formats ?? Built-with MVVM with Si

theapache64 12 Feb 8, 2022
Vibrate on a call answer or end.

Vibe Vibrate on a call answer or end. Tiny app to vibrate when a call is answered and/or has ended. Tested: Phone (com.android.dialer) Google Phone (c

lucky 8 Aug 27, 2022
A weather application using One Call API 3.0

Weather Application Hello Everyone! In this project, I developed a weather application using One Call API 3.0 from

ERHAN ŞEN 2 Sep 6, 2022
A full-stack application showing the power 💪 of KOTLIN. Entire android app + backend Apis written in Kotlin 🔥

Gamebaaz ?? A full-stack application showing the power ?? of KOTLIN. Entire android app + backend Apis written in Kotlin ?? Android Backend Jetpack Co

Sarnava Konar 85 Nov 17, 2022
An simple image gallery app utilizing Unsplash API to showcase modern Android development architecture (MVVM + Kotlin + Retrofit2 + Hilt + Coroutines + Kotlin Flow + mockK + Espresso + Junit)

Imagine App An simple image gallery app utilizing Unsplash API. Built with ❤︎ by Wajahat Karim and contributors Features Popular photos with paginatio

Wajahat Karim 306 Nov 26, 2022