Convert lua to make it human-readable and remove obfuscation.

Related tags

Game Development lua
Overview

Muna

Convert lua to make it human-readable and remove obfuscation. Based on luaj parser and lua formatter.

Before

function L1_1(A0_2, A1_2)
  local L2_2, L3_2
  L2_2 = A1_2.type
  L3_2 = EventType
  L3_2 = L3_2.EVENT_1
  if L2_2 == L3_2 then
    L2_2 = A1_2.param3
    if not (50 < L2_2) then
      goto lbl_11
    end
  end
  L2_2 = false
  do return L2_2 end
  ::lbl_11::
  L2_2 = ScriptLib
  L2_2 = L2_2.call
  L3_2 = A0_2
  L2_2 = L2_2(L3_2)
  if 2 < L2_2 then
    L2_2 = false
    return L2_2
  end
  L2_2 = true
  return L2_2
end
condition_EVENT_1 = L1_1

after

function condition_EVENT_1(context, args)
    if args.type == EventType.EVENT_1 then
        if not (50 < args.param3) then goto lbl_11 end
    end
    do return false end
    ::lbl_11::
    local var1 = ScriptLib.call(context)
    if 2 < var1 then return false end
    return true
end

Support

  • assign, only one arg (don't support A,B = C)
  • if-else
  • goto/label/block do ... end
  • func call/define
  • return

TODO: loop (for - both 2 type) statement

How it works?

It assumed that the var in any assign statement is used only once, so that we can use a map to store the value and simplify almost all assign statement. When it is referred in expression and function arg, we will output its real value. Also, not all assign statement can be simplified due to grammar and idempotent.

The details below show how it handles with the code.

And you may see it will meet some problems when it faces with loop, when the var will be used more than once.

-- input
L2_2 = ScriptLib
L2_2 = L2_2.call
-- output
-- store
L2_2 : ScriptLib.call

We will set L2_2 to ScriptLib.call and won't output both of them.

-- input
L5_2 = L1_1.challenge_id_no_record
-- output
-- store
L5_2 : L1_1.challenge_id_no_record

Since L1_1 is a global var, we won't store its value and keep the reference.

-- input
L2_2 = L2_2(L3_2)
-- output
local var1 = ScriptLib.call(context)
-- store
L2_2 : var1

We use a temporal var to hold the result of a func call due to the idempotent.

-- input
L2_2 = {}
L2_2[1] = 1
L2_2[2] = nil
L2_2[3] = 2
...
L4_2 = ScriptLib
L4_2 = L4_2.call
L5_2 = A0_2
L6_2 = {}
L7_2 = L2_2[L3_2]
L6_2.config_id = L7_2
L4_2(L5_2, L6_2)
-- output
local var2 = {1, nil, 2}
ScriptLib.call(context, {config_id = var2[var1]})
-- store
L2_2 : var2
L6_2 : {config_id = var2[var1]}

To avoid grammar error like {1, nil, 2}[var1], we use a temporal var to hold the table when it is indexed.

-- input
function L2_1(A0_2, A1_2)
  ...
end
condition_EVENT1 = L2_1
-- output
function condition_EVENT1(context, args)
    ...
end
-- store
func1 : Function ...
L2_1 : func1
condition_EVENT1 : func1

We use a temporal name funcN to hold the definition of function. When the block's parser is done, we will start to output the functions & global definitions.

The first arg in func will be replaced with context, and the second one is args.

Can I convert to another language?

Of course. I write it out as lua, but you can customize the output language by yourself.

You might also like...
WordleFX - Wordle in JavaFX and Kotlin
WordleFX - Wordle in JavaFX and Kotlin

Wordle This simple game is everywhere right now (the beginning of 2022) and it s

TicTacToe - An android Tic-tac-toe, also known as noughts and crosses
TicTacToe - An android Tic-tac-toe, also known as noughts and crosses

Tic Tac Toe An android Tic-tac-toe, also known as noughts and crosses, or Xs and

Tic Tac Toe is a two-player game in which the objective is to take turns and mark the correct spaces in a 3x3 (or larger) grid
Tic Tac Toe is a two-player game in which the objective is to take turns and mark the correct spaces in a 3x3 (or larger) grid

Tic Tac Toe is a two-player game in which the objective is to take turns and mark the correct spaces in a 3x3 (or larger) grid.

A simple launcher for Meta Quest VR headsets supporting Android/Official Quest/SideQuest apps and games
A simple launcher for Meta Quest VR headsets supporting Android/Official Quest/SideQuest apps and games

Quest PiLauncher This is a simple launcher for Meta Quest VR headsets supporting Android/Official Quest/SideQuest apps and games. Builds, VIdeo Compil

Butterfly - Small and powerful weapons, own it, let your Android are developed like Tiger, Carry whole game!

Butterfly - Small and powerful weapons, own it, let your Android are developed like Tiger, Carry whole game!

 A Ktor-based server that handles game process, user registration and packs provision
A Ktor-based server that handles game process, user registration and packs provision

Polyhoot! Server backend A Ktor-based server that handles game process, user registration and packs provision Deploying server locally You can deploy

A non-linear problem solver using automatic differentiation and penalty methods.

HelixOptimizer Join the discord and contribute! https://discord.gg/kqe74EER A non-linear problem solver using automatic differentiation and penalty me

Multiplayer Dots and Boxes game for Android

Multiplayer Dots and Boxes game for Android. One player is the server, and the rest connect to them. Has player customization and in-game chat! Still in development, but fully compatible with version 2.0 of my NetDot protocol.

A clean-aesthetically pleasing Measuring Application, which uses relevant sensors-converts raw sensor data into human readable formatted outputs-and displays accurate measurements.
A clean-aesthetically pleasing Measuring Application, which uses relevant sensors-converts raw sensor data into human readable formatted outputs-and displays accurate measurements.

Measure App A clean-aesthetically pleasing Measuring Application, which uses relevant sensors-converts raw sensor data into human readable formatted o

CalEF (Calendar Entry Formatter) : Select an entry in Android-Kalender and send/share the entry's content as human readable text.

CalEF (Calendar Entry Formatter) Select an entry in Android-Kalender and send/share the entry's content as human readable text. Usually calendar entri

Speech-Text Converter is a simple task that enable the user to convert the speech to text or convert text to speech (by Mic)
Speech-Text Converter is a simple task that enable the user to convert the speech to text or convert text to speech (by Mic)

Speech-Text Converter About Speech-Text Converter is a simple task that enable the user to convert the speech to text or convert text to speech (by Mi

xLua is a lua programming solution for  C# ( Unity, .Net, Mono) , it supports android, ios, windows, linux, osx, etc.
xLua is a lua programming solution for C# ( Unity, .Net, Mono) , it supports android, ios, windows, linux, osx, etc.

(English Documents Available) C#下Lua编程支持 xLua为Unity、 .Net、 Mono等C#环境增加Lua脚本编程的能力,借助xLua,这些Lua代码可以方便的和C#相互调用。 xLua的突破 xLua在功能、性能、易用性都有不少突破,这几方面分别最具代表性的

LuaBox Helper for call lua scripts on Kotlin

LuaBox Helper for call lua scripts on Kotlin! Big thanks to Luaj library! 1. Create a class for working with LuaBox: class ScriptCore: LuaBox( pat

LiteHttp is a simple, intelligent and flexible HTTP framework for Android. With LiteHttp you can make HTTP request with only one line of code! It could convert a java model to the parameter and rander the response JSON as a java model intelligently.

Android network framework: LiteHttp Tags : litehttp2.x-tutorials Website : http://litesuits.com QQgroup : 42960650 , 47357508 Android网络通信为啥子选 lite-htt

DiskCache - Simple and readable disk cache for kotlin and android applications

DiskCache Simple and readable disk cache for kotlin and android applications (with journaled lru strategy) This is a simple lru disk cache, based on t

AndroidBriefActions - Android library for sending and observing non persistent actions such as showing a message; nice readable way to call navigation actions from ViewModel or Activity/Fragment.

implementation "com.vladmarkovic.briefactions:briefactions:$briefActionsVersion" Benefits Why use brief-actions library pattern: Prevent short-term ac

TaggerString is very light library which allows to build dynamic string resource in much more readable way.

TaggerString TaggerString is very light library which allows to build dynamic string resource in much more readable way. I guess that every Android de

Modern JSON processor with readable Kotlin syntax.

Kq Modern cross-platform JSON processor with readable Kotlin syntax. cat ~/Desktop/bdb.ndjson | kq '.filter{it.bool("muted")}.sortedBy{it.long("size")

Measures human heart rate using camera and flash light.
Measures human heart rate using camera and flash light.

Heart-Rate-Ometer Introduction Measures human heart rate using camera and flash light. How-it-works https://github.com/phishman3579/android-heart-rate

Owner
Akka
Akka
A light-weight Android client for Polyhoot! Written in Kotlin and made with Material 3 and Dynamic Colors support.

A light-weight Android client for Polyhoot! Written in Kotlin and made with Material 3 and Dynamic Colors support.

Polyhoot! 2 May 31, 2022
a 2d Java physics engine, native java port of the C++ physics engines Box2D and LiquidFun

jbox2d Please see the project's BountySource page to vote on issues that matter to you. Commenting/voting on issues helps me prioritize the small amou

jbox2d 1k Jan 2, 2023
Sample source code for Android Pride Rainbow Bounding Box written in Kotlin and OpenGL 🏳️‍🌈

Sample Code for Animated Rainbow Bounding Box in OpenGL A sample app showing how to draw a rainbow bounding box on Android with OpenGL and Kotlin. Blo

Rebecca Franks 28 May 24, 2022
🐦 A flappy bird clone using Compose Web and radio button

?? Compose Bird A flappy bird clone using Compose Web and radio buttons

theapache64 36 Dec 31, 2022
simple game implements with kotlin and jetpack.(covered by unit test)

Simple Spy Game: Source Code ?? Published version ?? This repository contains a detailed game app that implements simple game using Koin, Room, Corout

Reza Darvishian 11 Jul 2, 2022
Spooky house game with monsters and sounds

SHGWMAS Spooky house game with monsters and sounds INSTRUCTIONS to play the game you must: have a brain downloaded the world + jar from the releases t

Team RickRoll 8 Oct 30, 2021
Application for downloading and installing mods for minecraft

Mods Rainbow Application for downloading and installing mods for minecraft. Also user can choose favourites mods. Table of Contents Screenshots Genera

Vladyslav 3 May 8, 2022
Minosoft is an open source minecraft client, written from scratch in kotlin (and java).

Minosoft Minosoft is an open source minecraft client, written from scratch in kotlin (and java). It aims to bring more functionality and stability. No

null 151 Dec 31, 2022
Android-application used as an introduction to Android development and Android APIs.

Android-application used as an introduction to Android development and Android APIs. This application is an implementation of the game Thirty and written in Kotlin.

Oscar Johansson 0 Nov 6, 2021
Terminal Game. Black and White have only pawns. White wins if their pawn moved to 8th line. Black wins if their pawn moves to 1st line. If black or white haven't any move, then no one wins(stalemate))

Only-Pawns-Chess Terminal game for 2 players Regular chess but all sides have only pawns Rules This game extend all the rules of regular chess but it

Pavel Levchenko 0 Nov 23, 2021