Lua is a powerful, fast, lightweight, embeddable scripting language. Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual ...

learn more… | top users | synonyms

22
votes
1answer
405 views

Lua OOP and classically-styled prototypal inheritance

I want to do some object-oriented programming in Lua, and I decided on something like this: ...
18
votes
2answers
1k views

C++ API for interfacing with Lua

I wanted a good way to move objects back and forth between Lua and C++, and I didn't want to use anything like LuaBind or the other available libraries I could find, so I instead wrote this. It's ...
17
votes
1answer
389 views

Tiny Lua library to get char pointer from string

Background I'm using Lua with luaglut to do some OpenGL stuff. The luaglut API is almost identical to the gl/glut C APIs. Sometimes, gl functions want a pointer to some data, for example: ...
14
votes
0answers
254 views

Siamese neural network

I have been studying the architecture of the Siamese neural network introduced by Yann LeCun and his colleagues in 1994 for the recognition of signatures ("Signature verification using a Siamese time ...
12
votes
1answer
178 views

Runtime expression autocompletion

I've written a function that can be used at runtime to suggest how the provided incomplete Lua expression can be completed so that it would make sense (that is, it would evaluate to a non-nil value). ...
11
votes
1answer
232 views

Is this a BSP tree? Am I missing something?

I've been practicing using BSP trees as I hear they are a good start to create procedural spaces such as houses. For ease-of-deployment purposes, I've tested this code in Lua and it seems to work. ...
10
votes
1answer
122 views

Lua bindings for FTGL (FreeType font rendering in OpenGL)

I wrote some Lua bindings for FTGL's C API. This works well enough, but I ended up with lots of macros, one for each Lua function signature. For example, LUD_NUMBER_NUMBER_TO_NUMBER creates a Lua ...
8
votes
2answers
225 views

OpenGL text rendering library for Lua built on freetype-gl

FTGL wasn't making me happy, so I decided to try something else. This isn't completely finished; I plan to work more on layouts and alignment, and add a few other things. It should be far enough along ...
8
votes
1answer
385 views

Object Oriented programming in lua in a functional fashion

I've discovered (and written) a way to object oriented programming in lua in a functional fashion instead of the standard metatable method. It carries much more functionality (no pun intended) but I'm ...
8
votes
1answer
106 views

Basic Game Model in Scripting Language

I've been working with Lua for a little bit, and I have finally come up with some code that can be extended to create the core of a game model. I come from an object oriented background, so working ...
8
votes
1answer
220 views

Garry's Mod custom spectate player

I have been making my own scoreboard, and needed a custom spectate function for it, so I made this: ...
7
votes
2answers
115 views

Lua Formula Code

A friend of mine dabbles in lua, and he recently sent me a code which applies an equation we were discussing. I personally am very mediocre with lua, but my Python senses are tingling - I feel as ...
7
votes
2answers
381 views

Performing non-production analytics on data

I have the following Lua script which I use against my redis environment to perform some non-production analytics on my data. My dataset contains hundreds of millions of records, hence I want to make ...
7
votes
3answers
292 views

Is there a better way of implementing this control structure?

I have the following control structure that I would like to improve: ...
7
votes
1answer
228 views

Loading and Using Lua Scripts

I have been experimenting with integrating Lua into Objective-C. I have tried to do the bare minimum to get Lua to compute values and return them. I did not want to use any external libraries so I ...
6
votes
1answer
156 views

Very basic chatbot

Was the best way to implent this? For example it will only say "It's nice I know." If you first ask "hat" and then answer "yes". This is how I'm thinking: ...
6
votes
2answers
52 views

Some table_handling tools for lua

I'm writing some table.tools to make table handling a little easier for me. But I'm a beginner with Lua, so you might help me a bit, to make the code better. First of all I would like to get the best ...
6
votes
1answer
131 views

Adding Abilities to Cards Dynamically in a Trading Card Game

I have figured out how to pass functions around in Lua, and I am using the technique of inserting functions into tables in order to dynamically assign functions to the cards in a trading card game. ...
6
votes
1answer
103 views

Scripts loading Scripts Dynamically in Lua

I have been working with Lua lately and I have discovered that it is capable of doing some very interesting things. I have created a proof of concept that allows one Lua script to load another Lua ...
5
votes
2answers
978 views

Lua string parsing

The following code takes a string and converts it to it's number equivalent. A=1 ... Z=26, while keeping all other characters intact. It formats the string using two delimiters. One for between ...
5
votes
2answers
100 views

Lua program to clean up phone numbers

How idiomatic is my code? Since Lua does not have classical inheritance such as in OO languages. Feedback on the test and implementation are both appreciated/welcomed. The rules are: If the phone ...
5
votes
1answer
270 views

Parsing Valve Key-Value files

Introduction Valve recently launched the Dota 2 Workshop Tools, which allows players to create their own maps with custom gamemodes, similar to Warcraft 3 in capabilities. Ability and unit ...
5
votes
1answer
52 views

Converting the integers to their equivalent string representations

I have the following function which converts an integer (such as 103) to its string representation ("one hundred three"): ...
5
votes
1answer
95 views

String split and tables

I have a table structured like this: ...
5
votes
1answer
155 views

C++: Generating similar methods with macros

I am currently working on a project that involves Lua. For convenience, I created a wrapper class for the Lua state structure. However, I also added some methods for getting globals and table fields. ...
5
votes
0answers
530 views

Redis rate limiting in Lua

I've implemented a rate limiter for redis in Lua, and I'm wondering if anyone has any suggestions that might improve the performance. An example use: ...
4
votes
1answer
37 views

Pong-like game built in Love2D

I just started learning programming in the past two or three months. I started with Python, and now I'm learning lua. I started game programming this week and this is a game I made with the Love2D ...
4
votes
1answer
28 views

Return table value based on a primitive “priority queue”

I have 2 function in Lua, one to look if a key is present inside a provided table and if true then return the value, else return false. This lookup function is called by another function with a ...
4
votes
1answer
90 views

Minimal entity component system, take 2

Here's a followup to Minimal entity component system. Please see that question for background. ...
4
votes
0answers
67 views

Creating 2D vectors

I've made a little mechanism for creating 2-D vectors in Lua. Vectors have two components i and j, and support addition, dot ...
4
votes
0answers
189 views

Parsing Lua 5.2 strings with patterns

I wrote some code to parse Lua 5.2 strings in Lua 5.1, using patterns. It's a bit too slow, but it works fine as far as I tested. ...
4
votes
0answers
93 views

Pong game built on a minimal entity component system

This simple game is built on the ECS described here: Minimal entity component system, take 2 ...
4
votes
0answers
79 views

Fowler–Noll–Vo hash function in Lua

I recently coded this FNV-1a hash function in Lua. Are there any apparent performance improvements that could be implemented? ...
4
votes
0answers
66 views

Copying folder contents from several folders

I have a file directory which contains folders for every month, and within those folders are several text files. In this context I would like to copy all of the text files from my ...
3
votes
1answer
272 views

Elevator code for a game called ROBLOX

Are there any ways I could improve speed and less code? The elevator that uses this script works fine. Could anything be better? ...
3
votes
1answer
50 views

Form for choosing settings

I've created a form to choose the settings: These settings are automatically saved in a file from the game client in this form: ...
3
votes
1answer
52 views

Recursively delete empty folders in Lua

I have written a script that run in WingFTP Server which has a Lua scripting engine built in. The script recursively deletes empty folders except the specified root folder. ...
3
votes
1answer
114 views

Default value mechanism in Lua using metatables

I am writing a couple of functions accepting tables as input parameters. These tables constitute a range of options, which should either be given or inferred from default tables. Concrete use cases ...
3
votes
1answer
507 views

Generating random strings

I've created the following string manipulation function for randomizing my passed string in Lua: ...
3
votes
1answer
25 views

Repetitive replacement for expressing fractions in LaTeX

I am converting natural math expressions with fractions to Latex code. What I have done seems to work on examples I've tested, but I'm not sure if the algorithm is safe. And maybe the string part ...
3
votes
1answer
186 views

Return one particular element first, when iterating a lua table

I wish to iterate through a Lua table, but want to get one particular element first always (its key is known beforehand). Since the pairs function does not guarantee the order of a table's elements, ...
3
votes
0answers
43 views

Entity component system Lua API

The destruction of the objects are handled by the garbage-collector metamethod. (Does this make sense? This means that an out-of-scope object will stay visible in game until garbage collection.) The ...
3
votes
0answers
165 views

Write premake4.lua file that builds and links to static libraries using premake

I am trying to write a premake4.lua file that builds and links to static libraries using premake. library mbm was originally ...
3
votes
0answers
69 views

Minimal entity component system

I was trying to figure out what a minimal ECS might look like in Lua; here's what I came up with. This is based very loosely on darkf/microecs. ...
3
votes
0answers
141 views

Can this “syntax sweetener” be improved?

I have a Lua project that uses some syntax sugar described in DecoratorsAndDocstrings, near the bottom of the page. It looks like this: ...
3
votes
0answers
131 views

Iterating over JSON docs

This Lua code runs in redis. It iterates over some JSON docs, and applies some logic based on the user (if any) making the request. I'm sure there's a lot I can improve here. ...
2
votes
2answers
167 views

Get file name with extension and get only extension

I have again 2 functions but this time they return either the full file name with extension or just the extension with a dot. Both actions are so similar that I just copy pasted the code from one and ...
2
votes
1answer
44 views

Form for choosing settings for a game

I've created a form to choose the settings. These settings are automatically saved in a file from the game client in this form: ...
2
votes
1answer
57 views

Tracking various stats on character development

The purpose of this code is to track player development on a Multi-User Dungeon I play. It allows saving multiple characters to the same database. It allows for updates on level, hour, tier, morts, ...
2
votes
4answers
77 views

Consolidating array accesses

Is there a better or easier way of doing this? if array[1] and array[2] and array[3] and array[4] and array[5] == false then --somthing end I have a lot of ...