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 machine,...
3
votes
1answer
55 views
Hash-optimization and Wilson-maze generation algorithm
I've finished optimization of Wilson algorithm (maze generation) from "silly and slow" algorithm of choosing unvisited cells:
...
1
vote
0answers
35 views
Lua-Torch memory leak [closed]
I have written a data loader for a Neural network using Torch library in lua. I am facing a memory leak in the code. I tried the built-in debug tools and whenever possible I am hinting the garbage ...
8
votes
2answers
151 views
Call a lua function - the C++ way
I'm not that good when it comes to templates, especially when it comes to variadic templates. I want to show you some code where I use both - templates and variadic templates - to call a lua function. ...
7
votes
2answers
74 views
print(fizz..buzz)
I couldn't help but notice we didn't have a FizzBuzz in lua yet.
I've always wanted to take a shot at Lua, so here goes nothing.
Code:
...
0
votes
1answer
64 views
Text based adventure game navigation
I have a problem with my code. I made so much code, and now I need to place ends, which I cannot figure out how to do because I need to line everything up and then place at least 5 or 6 ends in the ...
3
votes
2answers
89 views
Random RPG Battle System in Lua
This is my battle system that I wrote in Lua. Bear with me on this one, this is my first real program that does something besides write hello world. If there is anything that I could have done ...
1
vote
1answer
146 views
Simple four-operation calculator in Lua
I'm a beginner at Lua and programming in general and I just made a simple calculator and I was wondering where I could make improvements.
...
2
votes
1answer
51 views
Module to procedurally generate a map of islands
It chooses for each chunk some points inside that chunk that work as the center of each island. Then for each tile on the map it calculates the distance from the points in the 9 chunks around the tile'...
13
votes
1answer
171 views
Implementing The Proper Undead's Cave Generator
I recently stumbled onto a very old article about procedural dungeon generation on this site. Unfortunately, the author did not provide any code, only a description of the algorithm he used. Wanting ...
-3
votes
1answer
75 views
Lua and complex numbers [closed]
I try to use complex numbers in a lua program.
I need to parse a table of complex numbers printing side by side the name of the complex number and its value. Can't get through it :
I don't ask how ...
1
vote
2answers
81 views
Simple maze game with four rooms
I'm starting to learn Lua and in one part of the book I need to convert a "Maze Game" that uses goto to another one that doesn't use ...
7
votes
1answer
83 views
5
votes
0answers
74 views
Lua implementation of a text-based spreadsheets editor
Disclaimer: While the code in this question looks extremely long, I'm really only interested in reviewing some small parts of it. While I would sure appreciate someone going crazy and reviewing it ...
4
votes
2answers
68 views
Bus Announcement System in ROBLOX Lua
I got bored and decided to create a lua announcement system with the ROBLOX API.
One part is the display code, and the other part is the announcement code.
DISPLAY CODE
...
5
votes
1answer
562 views
Asynchronous request cloning using Lua + openresty
I'm working on a project to clone a subset of requests going to our production servers to one or more non-production endpoints. I opted to do this in Nginx and Lua because at the time, I could not ...
3
votes
1answer
102 views
String tokenization and replacing a numbered field
I created various functions for string manipulation in Lua, where the strings are composed of tokens separated by an ASCII character (which may be the point, comma, semicolon etc.). One of these is ...
7
votes
2answers
229 views
Sum-based sliding rate limiting with Redis and Lua
As I'm new to Redis, I would like to get a review / improvement suggestions from Redis / Lua experts on the following problem and the solution I have found so far.
Problem
The context is: an e-...
4
votes
1answer
60 views
mIRC scripting like string token manipulation in Lua
I'm trying to reproduce in Lua the mIRC scripting manipulating tokens function:
...
5
votes
1answer
465 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 ...
5
votes
1answer
47 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 ...
65
votes
1answer
2k 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 ...
4
votes
1answer
233 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
2answers
3k 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 ...
5
votes
1answer
87 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 "...
3
votes
1answer
50 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:
...
4
votes
0answers
62 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 ...
5
votes
1answer
688 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
1answer
55 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
64 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, ...
4
votes
1answer
310 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 ...
6
votes
0answers
406 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 works perfectly as far as I tested.
...
7
votes
2answers
210 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 ...
6
votes
1answer
164 views
4
votes
0answers
474 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 ...
10
votes
2answers
369 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 ...
12
votes
1answer
175 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 ...
7
votes
2answers
67 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 ...
19
votes
1answer
703 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:
...
5
votes
0answers
154 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
...
5
votes
1answer
186 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
137 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.
...
6
votes
1answer
632 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 ...
7
votes
1answer
198 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. ...
4
votes
1answer
459 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, ...
7
votes
1answer
169 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 ...
9
votes
1answer
125 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 ...
5
votes
0answers
156 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?
...
8
votes
1answer
321 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
60 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"):
...
8
votes
2answers
163 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 ...