Pixi.js "fish pond" tutorial in Lua with fengari
Following what I've learned in my earlier effort with the 'Getting Started', I decided to create the [Fish Pond tutorial](https://pixijs.com/8.x/tutorials/fish-pond) using Lua with Fengari.
You will notice adaptations for dealing with js promises, and passing js Array / Object parameters. Other than these adaptations, no major deviation from the tutorial was necessary.
<html><head>
<noscript>Pixi.js fish-pond tutorial (in Lua with fengari)</noscript>
<meta name="viewport" content="width=device-width, user-scalable=no">
<meta http-equiv="Content-Security-Policy" content="worker-src blob:">
<noscript src="pixi.js" type="text/javanoscript"></noscript>
<noscript src="fengari-web.js" type="text/javanoscript"></noscript>
<noscript type="application/lua">
local js=require('js')
local window=js.global
local document=window.document
function await(p)
p['then'](p, resume)
_,result=coroutine.yield()
return result
end
function Objectify(t)
O=js.new(window.Object)
for k,v in pairs(t) do
O[k]=v
end
return O
end
function preload()
local assets = window:Array(
Objectify{ alias='background', src='https://pixijs.com/assets/tutorials/fish-pond/pond_background.jpg' },
Objectify{ alias='fish1', src='https://pixijs.com/assets/tutorials/fish-pond/fish1.png' },
Objectify{ alias='fish2', src='https://pixijs.com/assets/tutorials/fish-pond/fish2.png' },
Objectify{ alias='fish3', src='https://pixijs.com/assets/tutorials/fish-pond/fish3.png' },
Objectify{ alias='fish4', src='https://pixijs.com/assets/tutorials/fish-pond/fish4.png' },
Objectify{ alias='fish5', src='https://pixijs.com/assets/tutorials/fish-pond/fish5.png' },
Objectify{ alias='overlay', src='https://pixijs.com/assets/tutorials/fish-pond/wave_overlay.png' },
Objectify{ alias='displacement', src='https://pixijs.com/assets/tutorials/fish-pond/displacement_map.png' }
)
await(window.PIXI.Assets:load(assets))
end
function addBackground()
local background = window.PIXI.Sprite:from('background')
background.anchor:set(0.5)
if (app.screen.width > app.screen.height) then
background.width = app.screen.width * 1.2
background.scale.y = background.scale.x
else
background.height = app.screen.height * 1.2
background.scale.x = background.scale.y
end
background.x = app.screen.width / 2
background.y = app.screen.height / 2
app.stage:addChild(background)
end
function addFishes(app,fishes)
local fishContainer = js.new(window.PIXI.Container)
app.stage:addChild(fishContainer)
local fishCount = 20
local fishAssets = {'fish1', 'fish2', 'fish3', 'fish4', 'fish5'}
for i=0,fishCount-1 do
local fishAsset = fishAssets[(i%#fishAssets)+1]
local fish = window.PIXI.Sprite:from(fishAsset)
fish.anchor:set(0.5)
fish.direction = math.random() * math.pi * 2
fish.speed = 2 + math.random() * 2
fish.turnSpeed = math.random() - 0.8
fish.x = math.random() * app.screen.width
fish.y = math.random() * app.screen.height
fish.scale:set(0.5 + math.random() * 0.2)
fishContainer:addChild(fish)
fishes[#fishes+1]=fish
end
end
function animateFishes(app, fishes, time)
local delta = time.deltaTime
local stagePadding = 100
local boundWidth = app.screen.width + stagePadding * 2
local boundHeight = app.screen.height + stagePadding * 2
for _,fish in ipairs(fishes) do
fish.direction = fish.direction + fish.turnSpeed * 0.01
fish.x = fish.x + math.sin(fish.direction) * fish.speed
fish.y = fish.y + math.cos(fish.direction) * fish.speed
fish.rotation = -fish.direction - math.pi / 2
if (fish.x < -stagePadding) then
fish.x = fish.x + boundWidth
end
if (fish.x > app.screen.width + stagePadding) then
fish.x = fish.x - boundWidth
end
if (fish.y < -stagePadding) then
fish.y = fish.y + boundHeight
end
if (fish.y > app.screen.height + stagePadding) then
fish.y = fish.y - boundHeight
Following what I've learned in my earlier effort with the 'Getting Started', I decided to create the [Fish Pond tutorial](https://pixijs.com/8.x/tutorials/fish-pond) using Lua with Fengari.
You will notice adaptations for dealing with js promises, and passing js Array / Object parameters. Other than these adaptations, no major deviation from the tutorial was necessary.
<html><head>
<noscript>Pixi.js fish-pond tutorial (in Lua with fengari)</noscript>
<meta name="viewport" content="width=device-width, user-scalable=no">
<meta http-equiv="Content-Security-Policy" content="worker-src blob:">
<noscript src="pixi.js" type="text/javanoscript"></noscript>
<noscript src="fengari-web.js" type="text/javanoscript"></noscript>
<noscript type="application/lua">
local js=require('js')
local window=js.global
local document=window.document
function await(p)
p['then'](p, resume)
_,result=coroutine.yield()
return result
end
function Objectify(t)
O=js.new(window.Object)
for k,v in pairs(t) do
O[k]=v
end
return O
end
function preload()
local assets = window:Array(
Objectify{ alias='background', src='https://pixijs.com/assets/tutorials/fish-pond/pond_background.jpg' },
Objectify{ alias='fish1', src='https://pixijs.com/assets/tutorials/fish-pond/fish1.png' },
Objectify{ alias='fish2', src='https://pixijs.com/assets/tutorials/fish-pond/fish2.png' },
Objectify{ alias='fish3', src='https://pixijs.com/assets/tutorials/fish-pond/fish3.png' },
Objectify{ alias='fish4', src='https://pixijs.com/assets/tutorials/fish-pond/fish4.png' },
Objectify{ alias='fish5', src='https://pixijs.com/assets/tutorials/fish-pond/fish5.png' },
Objectify{ alias='overlay', src='https://pixijs.com/assets/tutorials/fish-pond/wave_overlay.png' },
Objectify{ alias='displacement', src='https://pixijs.com/assets/tutorials/fish-pond/displacement_map.png' }
)
await(window.PIXI.Assets:load(assets))
end
function addBackground()
local background = window.PIXI.Sprite:from('background')
background.anchor:set(0.5)
if (app.screen.width > app.screen.height) then
background.width = app.screen.width * 1.2
background.scale.y = background.scale.x
else
background.height = app.screen.height * 1.2
background.scale.x = background.scale.y
end
background.x = app.screen.width / 2
background.y = app.screen.height / 2
app.stage:addChild(background)
end
function addFishes(app,fishes)
local fishContainer = js.new(window.PIXI.Container)
app.stage:addChild(fishContainer)
local fishCount = 20
local fishAssets = {'fish1', 'fish2', 'fish3', 'fish4', 'fish5'}
for i=0,fishCount-1 do
local fishAsset = fishAssets[(i%#fishAssets)+1]
local fish = window.PIXI.Sprite:from(fishAsset)
fish.anchor:set(0.5)
fish.direction = math.random() * math.pi * 2
fish.speed = 2 + math.random() * 2
fish.turnSpeed = math.random() - 0.8
fish.x = math.random() * app.screen.width
fish.y = math.random() * app.screen.height
fish.scale:set(0.5 + math.random() * 0.2)
fishContainer:addChild(fish)
fishes[#fishes+1]=fish
end
end
function animateFishes(app, fishes, time)
local delta = time.deltaTime
local stagePadding = 100
local boundWidth = app.screen.width + stagePadding * 2
local boundHeight = app.screen.height + stagePadding * 2
for _,fish in ipairs(fishes) do
fish.direction = fish.direction + fish.turnSpeed * 0.01
fish.x = fish.x + math.sin(fish.direction) * fish.speed
fish.y = fish.y + math.cos(fish.direction) * fish.speed
fish.rotation = -fish.direction - math.pi / 2
if (fish.x < -stagePadding) then
fish.x = fish.x + boundWidth
end
if (fish.x > app.screen.width + stagePadding) then
fish.x = fish.x - boundWidth
end
if (fish.y < -stagePadding) then
fish.y = fish.y + boundHeight
end
if (fish.y > app.screen.height + stagePadding) then
fish.y = fish.y - boundHeight
Pixijs
fish-pond | PixiJS
end
end
end
function addWaterOverlay(app)
local texture = window.PIXI.Texture:from('overlay')
overlay = js.new(window.PIXI.TilingSprite,Objectify{
texture= window.PIXI.Texture:from('overlay'),
width=app.screen.width,
height=app.screen.height
})
app.stage:addChild(overlay)
end
function animateWaterOverlay(app, time)
delta = time.deltaTime
overlay.tilePosition.x = overlay.tilePosition.x - delta
overlay.tilePosition.y = overlay.tilePosition.y - delta
end
function addDisplacementEffect(app)
local displacementSprite = window.PIXI.Sprite:from('displacement')
displacementSprite.texture.source.addressMode = 'repeat'
local filter = js.new(window.PIXI.DisplacementFilter,Objectify{
sprite=displacementSprite,
scale = 50,
width = app.screen.width,
height = app.screen.height
})
app.stage.filters = window:Array(filter)
end
function _init()
app=js.new(window.PIXI.Application)
await(app:init(Objectify{background='#1099bb', resizeTo=window}))
document.body:appendChild(app.canvas)
preload()
addBackground()
local fishes = {}
addFishes(app,fishes)
addWaterOverlay(app)
addDisplacementEffect(app)
app.ticker:add(function(self,time)
animateFishes(app, fishes, time)
animateWaterOverlay(app, time)
end)
end
function main()
_init()
end
resume=coroutine.wrap(main)
window:addEventListener("load", resume, false)
</noscript>
</html>
https://redd.it/1fldf9q
@r_lua
end
end
function addWaterOverlay(app)
local texture = window.PIXI.Texture:from('overlay')
overlay = js.new(window.PIXI.TilingSprite,Objectify{
texture= window.PIXI.Texture:from('overlay'),
width=app.screen.width,
height=app.screen.height
})
app.stage:addChild(overlay)
end
function animateWaterOverlay(app, time)
delta = time.deltaTime
overlay.tilePosition.x = overlay.tilePosition.x - delta
overlay.tilePosition.y = overlay.tilePosition.y - delta
end
function addDisplacementEffect(app)
local displacementSprite = window.PIXI.Sprite:from('displacement')
displacementSprite.texture.source.addressMode = 'repeat'
local filter = js.new(window.PIXI.DisplacementFilter,Objectify{
sprite=displacementSprite,
scale = 50,
width = app.screen.width,
height = app.screen.height
})
app.stage.filters = window:Array(filter)
end
function _init()
app=js.new(window.PIXI.Application)
await(app:init(Objectify{background='#1099bb', resizeTo=window}))
document.body:appendChild(app.canvas)
preload()
addBackground()
local fishes = {}
addFishes(app,fishes)
addWaterOverlay(app)
addDisplacementEffect(app)
app.ticker:add(function(self,time)
animateFishes(app, fishes, time)
animateWaterOverlay(app, time)
end)
end
function main()
_init()
end
resume=coroutine.wrap(main)
window:addEventListener("load", resume, false)
</noscript>
</html>
https://redd.it/1fldf9q
@r_lua
Reddit
From the lua community on Reddit: Pixi.js "fish pond" tutorial in Lua with fengari
Explore this post and more from the lua community
Lua Web Development Survey - with a chance to win 100€
Hi everyone, I posted 2 or 3 weeks ago about the beta version of our lua framework for web development. I have put together a short survey (< 4min) to find out if and how web development is done in the Lua community. In addition, of course, what the community would like a perfect lua webdev platform to look like.
The survey is aimed at either developers who use lua for web development or web developers who do not use lua for web development but know lua.
What's in it for you?
If you take the survey you can win 100€ (via PayPal).
Just enter your Reddit username in the last question so I can contact you via reddit chat if you win.
The raffle will run until Wednesday 25 September 2024 and I will then enter all usernames on a raffle draw website (https://wheelofnames.com/) and draw the winner at random. (with video proof)
Link to the survey: https://forms.gle/R2cTJJsDzmPETSN26
Feel free to share this survey with other Lua lovers who might be interested. Only one participation per person.
Thanks for the help <3
https://redd.it/1flpcg4
@r_lua
Hi everyone, I posted 2 or 3 weeks ago about the beta version of our lua framework for web development. I have put together a short survey (< 4min) to find out if and how web development is done in the Lua community. In addition, of course, what the community would like a perfect lua webdev platform to look like.
The survey is aimed at either developers who use lua for web development or web developers who do not use lua for web development but know lua.
What's in it for you?
If you take the survey you can win 100€ (via PayPal).
Just enter your Reddit username in the last question so I can contact you via reddit chat if you win.
The raffle will run until Wednesday 25 September 2024 and I will then enter all usernames on a raffle draw website (https://wheelofnames.com/) and draw the winner at random. (with video proof)
Link to the survey: https://forms.gle/R2cTJJsDzmPETSN26
Feel free to share this survey with other Lua lovers who might be interested. Only one participation per person.
Thanks for the help <3
https://redd.it/1flpcg4
@r_lua
Wheelofnames
Wheel of Names
Enter names, spin wheel to pick a random winner. Customize look and feel, save and share wheels.
Does anyone all 23 words for lua?
If someone would be so kind to tell me all the words and definition I'd greatly appreciate it, also is are there any other form of variables without using words? (I don't know if that makes sense) I'm looking into videos as well if you have any to drop for me.
https://redd.it/1flv21l
@r_lua
If someone would be so kind to tell me all the words and definition I'd greatly appreciate it, also is are there any other form of variables without using words? (I don't know if that makes sense) I'm looking into videos as well if you have any to drop for me.
https://redd.it/1flv21l
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Does anyone have a working example of installing busted via GitHub Action Workflows?
I want to run luarocks and install busted via GitHub. There's apparently already a GItHub Action + that exact example over at https://github.com/leafo/gh-actions-lua?tab=readme-ov-file#full-example The trouble is that example doesn't actually work. (See https://github.com/leafo/gh-actions-lua/issues/53)
Does anyone know of a working "busted install via GitHub" that I can use as reference?
https://redd.it/1flvjxs
@r_lua
I want to run luarocks and install busted via GitHub. There's apparently already a GItHub Action + that exact example over at https://github.com/leafo/gh-actions-lua?tab=readme-ov-file#full-example The trouble is that example doesn't actually work. (See https://github.com/leafo/gh-actions-lua/issues/53)
Does anyone know of a working "busted install via GitHub" that I can use as reference?
https://redd.it/1flvjxs
@r_lua
GitHub
GitHub - leafo/gh-actions-lua: GitHub action for Lua/LuaJIT
GitHub action for Lua/LuaJIT. Contribute to leafo/gh-actions-lua development by creating an account on GitHub.
how 2 make image bigger in love?
Need help with drawing an image and making it visible, despite me drawing the image already.
function love.load()
player = {}
player.x = 400
player.y = 400
speed = 2
score = 0
r = 0.1
earth = love.graphics.newImage('sprites/earth.png')
end
function love.update(dt)
if love.keyboard.isDown("d") then
player.x = player.x + speed
end
if love.keyboard.isDown("a") then
player.x = player.x - speed
end
if love.keyboard.isDown("s") then
player.y = player.y + speed
end
if love.keyboard.isDown("w") then
player.y = player.y - speed
end
r = r + 0.03
end
function love.draw()
love.graphics.circle("fill", player.x, player.y, 15)
love.graphics.draw(earth, 300, 400)
end
https://redd.it/1fm5jhg
@r_lua
Need help with drawing an image and making it visible, despite me drawing the image already.
function love.load()
player = {}
player.x = 400
player.y = 400
speed = 2
score = 0
r = 0.1
earth = love.graphics.newImage('sprites/earth.png')
end
function love.update(dt)
if love.keyboard.isDown("d") then
player.x = player.x + speed
end
if love.keyboard.isDown("a") then
player.x = player.x - speed
end
if love.keyboard.isDown("s") then
player.y = player.y + speed
end
if love.keyboard.isDown("w") then
player.y = player.y - speed
end
r = r + 0.03
end
function love.draw()
love.graphics.circle("fill", player.x, player.y, 15)
love.graphics.draw(earth, 300, 400)
end
https://redd.it/1fm5jhg
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Toogle while function
Hi, I'm trying to make a noscript on Lg HUb to toogle on/off an infinite sequence. The problem is that in the moment it enters the loop it wont receive any more events and cannot stop de noscript until I end the windows task, so it keeps printing "Do something" infinitely. Any suggestions?
local isActive = false
function OnEvent(event, arg)
if event == "MOUSEBUTTONRELEASED" and arg == 4 then
isActive = not isActive
if isActive then
OutputLogMessage("Script activated\n")
else
OutputLogMessage("Script deactivated\n")
end
end
while isActive do
OutputLogMessage("Do something\n")
end
end
https://redd.it/1fmfwcm
@r_lua
Hi, I'm trying to make a noscript on Lg HUb to toogle on/off an infinite sequence. The problem is that in the moment it enters the loop it wont receive any more events and cannot stop de noscript until I end the windows task, so it keeps printing "Do something" infinitely. Any suggestions?
local isActive = false
function OnEvent(event, arg)
if event == "MOUSEBUTTONRELEASED" and arg == 4 then
isActive = not isActive
if isActive then
OutputLogMessage("Script activated\n")
else
OutputLogMessage("Script deactivated\n")
end
end
while isActive do
OutputLogMessage("Do something\n")
end
end
https://redd.it/1fmfwcm
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
What even is noscripting
I gave up on luas complete basics long time ago but i never understood the concept of noscripting in general how does it work and in what way people make it work (would love some extremely basic noscript that kind of showcases that)
https://redd.it/1fmz6b5
@r_lua
I gave up on luas complete basics long time ago but i never understood the concept of noscripting in general how does it work and in what way people make it work (would love some extremely basic noscript that kind of showcases that)
https://redd.it/1fmz6b5
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Garry's Mod Attempt to index boolean value
I'm writing code for a weapon in Garry's Mod, trying to check if a trace didn't hit anything to exit a function early, but for some reason attempting to invert the value of TraceResult's Hit field causes this error. If I do not try to invert it, no error occurs. Failed attempts to invert the value include
Rest of function:
function SWEP:PrimaryAttack()
local owner = self:GetOwner()
print( owner )
local tr = owner:GetEyeTrace()
PrintTable( tr )
if ( not tr.Hit ) then return end
-- More code that never gets run due to erroring conditon
end
https://redd.it/1fn1g7a
@r_lua
I'm writing code for a weapon in Garry's Mod, trying to check if a trace didn't hit anything to exit a function early, but for some reason attempting to invert the value of TraceResult's Hit field causes this error. If I do not try to invert it, no error occurs. Failed attempts to invert the value include
!tr.Hit, not tr.Hit, tr.Hit == false, tr.Hit ~= true, and finally, true ~= tr.Hit. I can't think of any other options to try. How is this code trying to index Hit?Rest of function:
function SWEP:PrimaryAttack()
local owner = self:GetOwner()
print( owner )
local tr = owner:GetEyeTrace()
PrintTable( tr )
if ( not tr.Hit ) then return end
-- More code that never gets run due to erroring conditon
end
https://redd.it/1fn1g7a
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
logitech G-Hub G-Keys remapping?
Can you somehow simulate the press of a G-key? I would need a letter key to be a G-key to make my noscript work. Is this possible I tried remapping via powertoys but it was not registered as a g-key press.
https://redd.it/1fn9g30
@r_lua
Can you somehow simulate the press of a G-key? I would need a letter key to be a G-key to make my noscript work. Is this possible I tried remapping via powertoys but it was not registered as a g-key press.
https://redd.it/1fn9g30
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
How the hell do I install luarocks!?
I want to install luarocks for an existing lua installation I have which is on a different hard drive from my main one.
I have 2 main folders, one called `Lua`, which holds the lua installation (5.4.2 btw) and one called `Luarocks`, which holds the luarocks.exe. In the `luarocks` folder, I have a subfolder, called `rocks` where i want the rocks/plugins/libraries/whatever to go. I don't care about local or global rocks as I'm the only one using this computer.
So far, powershell (im on windows btw) recognizes luarocks. I have 3 main problems though.
1 Plugins are in `AppData\\Roaming` (I want the rocks to go in the `rocks` folder as mentioned earlier)
2 It keeps asking me to set the lua interperter directory whenever typing in `luarocks list` even though i keep doing what it says:Error: Lua 5.4.2 interpreter not found at S:\\Coding\\LanguageInstalls\\Lua\\Lua5.4.2 Please set your Lua interpreter with: luarocks --local config variables.LUA <d:\\path\\lua.exe>
What I put in and still get error afterwards:
luarocks config variables.LUA S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lua.exe
3 Whenever I try to simply require a module, (im requiring lunajson btw) I get this error:
S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lua.exe: test.lua:4: module 'lunajson' not found:
no field package.preload'lunajson'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lua\lunajson.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lua\lunajson\init.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lunajson.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lunajson\init.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\..\share\lua\5.4\lunajson.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\..\share\lua\5.4\lunajson\init.lua'
no file '.\lunajson.lua'
no file '.\lunajson\init.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lunajson.dll'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\..\lib\lua\5.4\lunajson.dll'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\loadall.dll'
no file '.\lunajson.dll'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lunajson54.dll'
no file '.\lunajson54.dll'
stack traceback:
C: in function 'require'
test.lua:4: in main chunk
C: in ?
With this noscript:
local lunajson = require("lunajson")
https://redd.it/1fnvhhw
@r_lua
I want to install luarocks for an existing lua installation I have which is on a different hard drive from my main one.
I have 2 main folders, one called `Lua`, which holds the lua installation (5.4.2 btw) and one called `Luarocks`, which holds the luarocks.exe. In the `luarocks` folder, I have a subfolder, called `rocks` where i want the rocks/plugins/libraries/whatever to go. I don't care about local or global rocks as I'm the only one using this computer.
So far, powershell (im on windows btw) recognizes luarocks. I have 3 main problems though.
1 Plugins are in `AppData\\Roaming` (I want the rocks to go in the `rocks` folder as mentioned earlier)
2 It keeps asking me to set the lua interperter directory whenever typing in `luarocks list` even though i keep doing what it says:Error: Lua 5.4.2 interpreter not found at S:\\Coding\\LanguageInstalls\\Lua\\Lua5.4.2 Please set your Lua interpreter with: luarocks --local config variables.LUA <d:\\path\\lua.exe>
What I put in and still get error afterwards:
luarocks config variables.LUA S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lua.exe
3 Whenever I try to simply require a module, (im requiring lunajson btw) I get this error:
S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lua.exe: test.lua:4: module 'lunajson' not found:
no field package.preload'lunajson'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lua\lunajson.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lua\lunajson\init.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lunajson.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lunajson\init.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\..\share\lua\5.4\lunajson.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\..\share\lua\5.4\lunajson\init.lua'
no file '.\lunajson.lua'
no file '.\lunajson\init.lua'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lunajson.dll'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\..\lib\lua\5.4\lunajson.dll'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\loadall.dll'
no file '.\lunajson.dll'
no file 'S:\Coding\LanguageInstalls\Lua\Lua5.4.2\lunajson54.dll'
no file '.\lunajson54.dll'
stack traceback:
C: in function 'require'
test.lua:4: in main chunk
C: in ?
With this noscript:
local lunajson = require("lunajson")
https://redd.it/1fnvhhw
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Hi,I have a problem when trying to download the saitek panel plugin for the zibo.
https://redd.it/1fo0s5h
@r_lua
https://redd.it/1fo0s5h
@r_lua
Tables and json
Hello, so basically what i am trying to achieve is to save the contents of a table to a .json file and make the table update and save from that file. For example, let’s say i have a table called Redtest how would i go about saving the contents of this table to a .json file and also use the contents within that file to update the current table. So if there are interruptions like crashes or something, i would have the data stored separately ready to use again and not lose all the data. Is there an efficient way of doing this? Any help would greatly be appreciated. Also if it helps i am using CfxLua.
https://redd.it/1fo3el3
@r_lua
Hello, so basically what i am trying to achieve is to save the contents of a table to a .json file and make the table update and save from that file. For example, let’s say i have a table called Redtest how would i go about saving the contents of this table to a .json file and also use the contents within that file to update the current table. So if there are interruptions like crashes or something, i would have the data stored separately ready to use again and not lose all the data. Is there an efficient way of doing this? Any help would greatly be appreciated. Also if it helps i am using CfxLua.
https://redd.it/1fo3el3
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
"Go to Symbols in Workspace" is too slow in VSCode with Lau extension by sumneko
I am working on project where there are are roughly 5000+ lua files.
I am using VSCode (moving from Sublime) with extension Lua by sumneko. While all the other things are working well, what I see a huge drawback is the symbol search in workspace.
When I start typing a function name, it take like good 10-15s for it to show results. And any incremental char in the search field also takes some 10-15s. In Sublime it used to be fast even without any extension (VS code doesn't do it work without extension).
Has anybody faced this? Are there settings which can cache the result and show it faster?
Or any other extension which can do this better way?
https://redd.it/1fp1lu6
@r_lua
I am working on project where there are are roughly 5000+ lua files.
I am using VSCode (moving from Sublime) with extension Lua by sumneko. While all the other things are working well, what I see a huge drawback is the symbol search in workspace.
When I start typing a function name, it take like good 10-15s for it to show results. And any incremental char in the search field also takes some 10-15s. In Sublime it used to be fast even without any extension (VS code doesn't do it work without extension).
Has anybody faced this? Are there settings which can cache the result and show it faster?
Or any other extension which can do this better way?
https://redd.it/1fp1lu6
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
How to declare dependencies in lua packages
I am new to lua.
I am writing a lua module where I would like to implement some interfaces that are exposed by another third-party module that I have no control over.
How can I declare a dependency on that third-party module so that I can implement the exposed interface?
I did some digging and found that "luarocks" can help manage dependencies. But, I am uncertain if that's the preferred way?
At the end of the day, people using the third-party library can load my implementation of the third-party interface in their application. So, I believe, at runtime it'll be fine as people can define dependencies on both modules. But, for my local development, I don't know how to go about it.
I don't know if I'm sounding stupid.
Thanks for your help!
https://redd.it/1fplr7s
@r_lua
I am new to lua.
I am writing a lua module where I would like to implement some interfaces that are exposed by another third-party module that I have no control over.
How can I declare a dependency on that third-party module so that I can implement the exposed interface?
I did some digging and found that "luarocks" can help manage dependencies. But, I am uncertain if that's the preferred way?
At the end of the day, people using the third-party library can load my implementation of the third-party interface in their application. So, I believe, at runtime it'll be fine as people can define dependencies on both modules. But, for my local development, I don't know how to go about it.
I don't know if I'm sounding stupid.
Thanks for your help!
https://redd.it/1fplr7s
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
is there a way to implement scanner on lua?
I was just wondering if you could put a scanner like java.
https://redd.it/1fq32tc
@r_lua
I was just wondering if you could put a scanner like java.
https://redd.it/1fq32tc
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Modding games
Okay so i know the games have an API that supports Lua, my book says to embed into the program i have to "Initialize The Lua State: #include<lua.h> ... " and gives code. my problem is the game is an executable how do i put that in the game. i feel like i am going about this wrong. Like Hades 2 everything is exposed cool. Starbound its JSON files and i managed. or do i just create a mod folder by it and drop files in that.
if anyone has any good sources for me to read or watch let me know, i want to learn to do this and i cant afford college.
https://redd.it/1fq9gjn
@r_lua
Okay so i know the games have an API that supports Lua, my book says to embed into the program i have to "Initialize The Lua State: #include<lua.h> ... " and gives code. my problem is the game is an executable how do i put that in the game. i feel like i am going about this wrong. Like Hades 2 everything is exposed cool. Starbound its JSON files and i managed. or do i just create a mod folder by it and drop files in that.
if anyone has any good sources for me to read or watch let me know, i want to learn to do this and i cant afford college.
https://redd.it/1fq9gjn
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Need resources
Can i get recommendations for books or websites or youtube guides that help with self learning. I've picked up alot of python, but im not sure how to use the concepts i've learned. So im trying learn lua to dive into modding. Need a few sources.
https://redd.it/1fr1sq2
@r_lua
Can i get recommendations for books or websites or youtube guides that help with self learning. I've picked up alot of python, but im not sure how to use the concepts i've learned. So im trying learn lua to dive into modding. Need a few sources.
https://redd.it/1fr1sq2
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community
Is luarocks compatible with luau?
I have downloaded and ran luau on my computer, but when i tried to use it with luarocks (normal lua works fine) the require function gave an error:
test.lua:1: error requiring module
stacktrace:
C function require
test.lua:1
any ideas?
https://redd.it/1fri1bf
@r_lua
I have downloaded and ran luau on my computer, but when i tried to use it with luarocks (normal lua works fine) the require function gave an error:
test.lua:1: error requiring module
stacktrace:
C function require
test.lua:1
any ideas?
https://redd.it/1fri1bf
@r_lua
Reddit
From the lua community on Reddit
Explore this post and more from the lua community