This script renders a window with stats to the player as they play. Can someone help me increase the size of the window slightly and the font size? I have attempted a few parameters with no luck
undefined
local messages = {}
local glitter = {}
local glitterCount = 0
function addMessage(text, mood)
for i = math.min(#messages + 1, 4), 2, -1 do
messages[i] = messages[i - 1]
messages[i].targetPos = i
end
messages[1] = { text = text, age = 0, targetPos = 1, currentPos = 1, mood = mood }
if mood == 1 then
for i = 1, 60 do
local dir = vec2(math.random() - 0.5, math.random() - 0.5)
glitterCount = glitterCount + 1
glitter[glitterCount] = {
color = rgbm.new(hsv(math.random() * 360, 1, 1):rgb(), 1),
pos = vec2(80, 140) + dir * vec2(40, 20),
velocity = dir:normalize():scale(0.2 + math.random()),
life = 0.5 + 0.5 * math.random()
}
end
end
end
local function updateMessages(dt)
comboColor = comboColor + dt * 10 * combo
I'm learning Lua and come from a Java background, and have been diving deep into Lua "classes".
Realizing that a Lua "class" is just some clever syntactic sugar, and lacks encapsulation, I've found that closures can act like a Java class and protect it's state. An added bonus is my muscle memory won't struggle with : vs . for function calls, a pitfall I've already wasted time debugging.
I'm new to all this though, is there anything I'm missing? Is a Lua "class" with self and : a better choice than using a closure like a class?
Contribute to itchychips/smalltemplate development by creating an account on GitHub.
Link Actions
Hi everyone!
I just wanted to share a small template library and supporting program I wrote using Lua (specifically wrote against LuaJIT and Lua5.1).
I haven't found any existing template engine that really fit my needs. The main one I saw was Jinja2, but it required pulling in Python, which on a lot of environments was a bit more of an ask than I really wanted to deal with (especially in enterprise environments). Many others I've tried over the years seem not to throw errors when a variable is referenced, but not defined, or at least the ones I could get testing with in about 15 minutes.
Can't promise it's perfect, but it replaced my need to create a templated text document for my RPG character that I had written in M4, and I have had a lot of instances where I wanted an easy-to-use templating engine for configurations.
Current repository: https://codeberg.org/adamnejm/lazy-lua | Extended standard library for Lua
Link Actions
Lazy is a library that extends the standard Lua library.
It exposes function modules such as math, string, table, etc.
It's aimed to fill the gaps of Lua's standard libraries by providing functions such as math.round to round numbers, string.trim to remove leading and trailing white spaces from a string and many many many more.
One important feature of Lazy is that the require path of modules is automatically resolved, which allows you to require the lazy library from virtually anywhere.
For example the lazy folder may be located in the root of your project or any sub-directory.
More so, upon setting your LUA_PATH correctly, lazy can be required anywhere from your PC without having to import it into your project.
Please refer to the GitLab page for more information .
Example usage:
lua
local lazy = require "lazy"
lazy.math.round(1234.5678, 2) --> 1234.57
lazy.os.capture("pwd") --> /home/name/projects/lua/lazy
lazy.string.split("Lua is amazing!", " ")