Questions tagged [lua]

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, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.

Filter by
Sorted by
Tagged with
1
vote
0answers
24 views

Improving a code design of simple game mod for better teamwork [closed]

I've made this module in Lua as a mod for Project Zomboid game. In future I will develop my mods in a small team (of 2-4 programmers). At this moment I have no experience in teamwork, because most of ...
2
votes
1answer
88 views

Convert an integer to 4 bytes without bitshift operators

This code is applicable to either GLSL or C due to virtually identical syntax. Before GLSL 1.3, bitshift operators were not present and I am aiming for backwards compatibility to GLSL 1.2. ...
5
votes
1answer
84 views

Currying in Lua

Just whipped up this quick curry function in Lua, as a building block for partial application and memoization. Any feedback is appreciated. It takes two arguments; ...
3
votes
1answer
90 views

Finite state machine for chasing and attacking a target

My questions are: How can I improve my implementation of the FSM model? Should Finite State Machines have functionality for Adding and Removing states from table? (Since I can only be in one state at ...
5
votes
1answer
195 views

Recursive descent parser for simple arithmetic expressions grammar

What I'd like to see in your review, in order of relevance: Is there any bugs? (I see none, but...) Is the code efficient? (by whatever metric you'd like to use) Is the code easy to understand? ...
0
votes
1answer
61 views

Building a 64 × 64 particle accelerator frame in Minecraft with a computercraft turtle

I dont think this will work anywhere besides in minecraft with computercraft but it's all correct syntax. I just feel like it has some lines of code I could eliminated somehow and made it a cleaner ...
5
votes
1answer
346 views

Collision detection for moving 2D objects

After implementing SAT (separating axis theorem) and not being happy with it only working on stationary shapes, this in theory allowing for fast objects to glitch through others, I came up with this ...
2
votes
1answer
71 views

Faster way of converting a 1-d table to predefined userdata in Lua

I have defined a userdata in Lua (Lua version is 5.1) as shown below- ...
3
votes
1answer
93 views

Serializing a table for filing

I have a table in Lua, which contains two 1-dimensional arrays in which each array contains approximately 800,000 elements. I want to serialize this Lua table to file efficiently. Hence, I planned to ...
5
votes
1answer
303 views

Basic input validation package in Lua

I'm very new to Lua (and programming in general). I wanted to start out with a simple package that validates input based on a set of rules. The code works as intended, but is what I have written is ...
4
votes
1answer
206 views

Simple terminal-based Lua task-tracking/calendar

I am learning Lua and wrote this little calendar/time-tracking script. It allows me to create tasks to do with a deadline, print them, and mark them as being done. A task is a table with the following ...
4
votes
1answer
411 views

Wrapping an IntPtr in a Struct for safer Interop

Consider the following C#/C interop scenario: ...
3
votes
2answers
100 views

Generating a Lua script for a tile map maker

I'm using printwriter to generate a LUA script for a tile map maker. It seems hackish to me, but it works. Purposes are for allowing users to make their own maps for my game. Is there a better ...
5
votes
1answer
232 views

Shutdown-Script for Don't Starve Together Dedicated Server

I have written my first LUA-Script/Function to shut down the Dedicated Server for Don't Starve Together. I wanted to shut down the server in 2 minutes and inform everyone on the server that the server ...
7
votes
2answers
834 views

Convert Lua UINT to hh:mm:ss

I have found the convert_to function in the lua-user wiki, and I created the convert_to_time function which does what I want it to do. Which is, basically: Having a number, return its value in a Time ...
2
votes
0answers
160 views

Redis lua - game leaderboard “overview”

Here is the code I invoke as Lua script in Redis. I use Redis sorted set to store game scores. This function is used to get some kind of overview of leaderboard. It returns id, score and rank of: ...
4
votes
1answer
53 views

Suffixing numeric values

This is a part of my Factorio mod Visual Signals. This code takes a numeric value as input and returns a string for the value, for example: ...
1
vote
2answers
349 views

Pico-8 player and scene

I recently started learning Lua by programming games in Pico-8. It's been fun, but it's time to learn some of the more powerful utilities to get things done smarter and with less redundancy. I'm an ...
2
votes
1answer
57 views

Load/save plain PPMs without error checking

I'm learning Lua. I decided to make a simple plain PPM decoder/encoder without error checks to familiarize myself with the language. I would appreciate any feedback on how could I make the following ...
5
votes
0answers
97 views

brainF*** interperter in lua

For a personal project I may need to load and execute something that will basically be a very simple programming language. Though I am not at all close to this part of the project yet and I can most ...
8
votes
1answer
210 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: ...
11
votes
2answers
641 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. ...
8
votes
3answers
162 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
184 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
361 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 ...
2
votes
1answer
3k 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
56 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
227 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 ...
-2
votes
1answer
392 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
199 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
162 views

Lua/Love2D Resource Loader (Queue)

I made this resource queue in Love2D. ...
5
votes
0answers
251 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
209 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
1k 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
292 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
522 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
93 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
1k 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
72 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 ...
80
votes
1answer
3k 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
554 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. ...
7
votes
2answers
11k 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
159 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
53 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: ...
5
votes
0answers
193 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 ...
6
votes
1answer
3k 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
57 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
68 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
693 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
721 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. ...