Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Dewgy
Nov 10, 2005

~🚚special delivery~📦

Tunicate posted:

IIRC Lua doesnt' have a match statement or switch statement built in, right?

Lua doesn’t even know what a constant is, so, yeah basically. But, you can very easily abuse its key/value table system to do more or less the same thing, if you’re trying to be more efficient.

Adbot
ADBOT LOVES YOU

hailthefish
Oct 24, 2010

yeah was gonna say, in lua your options are basically do the ten thousand line if-else, or do some really bonkers table magic poo poo.

Dewgy
Nov 10, 2005

~🚚special delivery~📦

hailthefish posted:

yeah was gonna say, in lua your options are basically do the ten thousand line if-else, or do some really bonkers table magic poo poo.

“Table magic poo poo” is Lua’s major strength so I mean why the hell not. :v:

megane
Jun 20, 2008



You can indeed do table magic poo poo, something like
pre:
match_table = {
  plus = function(x, y) return x + y end
  product = function(x, y) return x * y end
}

function fake_match(x, y, action)
  return match_table[action](x, y)
end

print(fake_match(2, 5, "plus"))
print(fake_match(2, 5, "product"))

j.peeba
Oct 25, 2010

Almost Human
Nap Ghost
All the data in Grimrock games was Lua table magic poo poo too and it was great. Being able to spice up data with the occasional function or defining objects in bulk with for loops for example is a nice luxury to have.

Shoehead
Sep 28, 2005

Wassup, Choom?
Ya need sumthin'?
If it works who cares how you did it? (Please never look at my code)

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Jabor posted:

But it feels like a ton of boilerplate to write it that way when you're starting out with only a half-dozen cases, it's often easier to just start with something that works well at that small scale and then keep growing it.

and once you have a pattern for how you add new content, it's way easier to stick to that pattern than it is to rearchitect everything. And, again, this is fine, it's a simple process, you know where to go to look up how something works. About the worst I can say about it is that it's hard to do comparisons of cards without a lot of scrolling around. The performance penalty of doing thousands of string comparisons every time a card needs to be scored is, honestly, negligible these days.

SystemLogoff
Feb 19, 2011

End Session?

Lua caches strings anyway, so the penalty for string comparison is already reduced as a language feature.

LuaJIT is such a nice language.

Red Mike
Jul 11, 2011

TooMuchAbstraction posted:

About the worst I can say about it is that it's hard to do comparisons of cards without a lot of scrolling around.

And if you end up needing that often enough, the pattern is simple enough that you move your data over to some other tool (like an Excel/Google Sheets spreadsheet), then write a really basic CSV importer that generates a string of that chain of ifs based on the data in the sheet, and you literally run it and copy paste the code in when you're done balancing the numbers. You can even automate it into your build pipeline.

KillHour
Oct 28, 2007


megane posted:

You can indeed do table magic poo poo, something like
pre:
match_table = {
  plus = function(x, y) return x + y end
  product = function(x, y) return x * y end
}

function fake_match(x, y, action)
  return match_table[action](x, y)
end

print(fake_match(2, 5, "plus"))
print(fake_match(2, 5, "product"))

It's weird to call this "magic table poo poo," since that implies to me that it's hacky/messy. It's the same as using a dictionary/hashmap of anonymous/lambda functions, which is extremely common in many languages. I do it all the time and it's a very normal alternative to giant if/else blocks. They don't need to be replaced if they aren't a problem, but this is pretty much the standard for how you would do it.


Edit: My giant conditional blocks are implemented in shaders inside a critical loop that gets run hundreds of millions of times per frame and needs to be as optimized as possible. I use case statements :v:

Double edit: I'm not exaggerating. That case statement is evaluated up to 100 times per function per pixel and there can be up to 32 functions, so that's a worst case of ~26.5 billion evaluations per frame in 4k. Worst case can't really ever happen, but 100s of millions is common. It still runs at several hundred FPS on my 3090 (for now, until I bog it down with more poo poo).

KillHour fucked around with this message at 15:30 on Apr 24, 2024

megane
Jun 20, 2008



Yep. One of the reasons Lua appeals to me it that it gives you one simple-yet-powerful tool, the table, and then you solve pretty much every problem by applying that one tool in clever ways. You can implement Sets by using tables "backwards," with the elements as keys and true/false as the values, for example. That's definitely a downside for many applications, but I enjoy it as a mental exercise.

Your Computer
Oct 3, 2008




Grimey Drawer
but it's 1-indexed! how am i supposed to use a language that's 1-indexed!!!

Chev
Jul 19, 2010
Switchblade Switcharoo
In one of the legacy applications at work the previous dev suffixed every 0-indexed thing with _indexStartsAt0.

As it's written in C#, it makes the source quite a thing to behold.

xzzy
Mar 5, 2009

Congrats on your employer coming up with a code standard that actually self documents!

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
I appreciate how lean and elegant Lua is, but I haaaaate having to bring my own tools (and/or find and install others') to the party. I want a robust standard library that ships with the language. :(

Dieting Hippo
Jan 5, 2006

THIS IS NOT A PROPER DIET FOR A HIPPO
I always have handy this list of curated Love2D libraries for literally everything you can think of for Love2D/Lua gamedev. For objects, 'hump.class' or 'middleclass' are both good picks, and for asset management 'cargo' is pretty much the easiest way to pull in any file data for quick use.

Polo-Rican
Jul 4, 2004

emptyquote my posts or die

the trombone champ background animations are built kinda like this for the same boneheaded reasons: each track having unique effects that couldn't easily be defined in a shared class, plus me being ignorant about a handful of coding fundamentals due to being self-taught

edit: whoa! They deleted the tweet lol

Chrs
Sep 21, 2015

This game I made just won ScoreSpace Choice on ScoreSpace Jam 29.



Play on Itch: https://chrsgr.itch.io/gravoor-infinity
Play on Newgrounds, with online leaderboard: https://www.newgrounds.com/portal/view/927101

So thats obviously very exciting for me lol. Check it out if you guys have a moment free.

Shoehead
Sep 28, 2005

Wassup, Choom?
Ya need sumthin'?
New old enemies today

https://x.com/Shoehead_art/status/1784209586297197016

This guy used to be a severed human head mounted on robot legs but it was goofy as poo poo. Now they are little flesh things that die easily but like to swarm you and will try get over obstacles to get at you.

Splicer
Oct 16, 2006

from hell's heart I cast at thee
🧙🐀🧹🌙🪄🐸

Shoehead posted:

New old enemies today

https://x.com/Shoehead_art/status/1784209586297197016

This guy used to be a severed human head mounted on robot legs but it was goofy as poo poo. Now they are little flesh things that die easily but like to swarm you and will try get over obstacles to get at you.
Strike two

Shoehead
Sep 28, 2005

Wassup, Choom?
Ya need sumthin'?

Splicer posted:

Strike two

Woah woah woah which was strike one?!

edit: Oh yeah

Your Computer
Oct 3, 2008




Grimey Drawer

Shoehead posted:

New old enemies today

https://x.com/Shoehead_art/status/1784209586297197016

This guy used to be a severed human head mounted on robot legs but it was goofy as poo poo. Now they are little flesh things that die easily but like to swarm you and will try get over obstacles to get at you.

can i pet them

Chev
Jul 19, 2010
Switchblade Switcharoo

Chrs posted:

This game I made just won ScoreSpace Choice on ScoreSpace Jam 29.



Play on Itch: https://chrsgr.itch.io/gravoor-infinity
Play on Newgrounds, with online leaderboard: https://www.newgrounds.com/portal/view/927101

So thats obviously very exciting for me lol. Check it out if you guys have a moment free.

Congrats on the win!

Rupert Buttermilk
Apr 15, 2007

🚣RowboatMan: ❄️Freezing time🕰️ is an old P.I. 🥧trick...

Onimwad posted:

I got lucky and caught the Game Maker screenshot saturday tweet. Always on the promotion grind...
So I made a tiny video showing the current look off, and a sneak preview of some of the music that's been made!

https://x.com/Grabbus_Game/status/1766453720638759238?s=20

Ok, weird... Is MWgewehr a goon? I have a lot of goons in my twitter feed, and just as many, if not more, composers and sound designers as well, and while I'm sure those two groups overlap, it's still very rare.

Anyway, I know of them outside of anything forums related, or at least I assumed I did, but at this point, I wouldn't be surprised if they were a goon.

Smik
Mar 18, 2014

Chrs posted:

This game I made just won ScoreSpace Choice on ScoreSpace Jam 29.

Play on Itch: https://chrsgr.itch.io/gravoor-infinity
Play on Newgrounds, with online leaderboard: https://www.newgrounds.com/portal/view/927101

So thats obviously very exciting for me lol. Check it out if you guys have a moment free.

Congratulations! How do you find Newgrounds for posting games? I haven't been a regular there since the days when "The Portal" was a separate entity as opposed to the main part of the site.

Chrs
Sep 21, 2015

I find that on Newgrounds my games get a lot more visibility than on Itch just because they do a lot more to put the games in front of people. For instance theres an approval system when games are submitted to keep the utterly terrible stuff off the site, which means users are encouraged to play new content to vote on it and gain experience on their accounts. Whereas over on Itch I don’t think theres anything of the sort.

I also think that with Newgrounds being less saturated these days compared to Itch you’re more likely to have your game played if it is good because it’s not drowning in a sea of other content.

Using my most recent game as a case study, despite it winning a featured game jam on Itch its only had 361 players on the site. Meanwhile over on Newgrounds where it is just another game like any other the game has already had 3034 players at the time of writing.

I released the game to both at the same time.

Chrs fucked around with this message at 01:44 on Apr 29, 2024

Dieting Hippo
Jan 5, 2006

THIS IS NOT A PROPER DIET FOR A HIPPO
What games are getting released on Newgrounds now that Flash is dead and buried? Is it just HTML5 games, people still doing flash games with a flash emulator, or a mystery third option?

Chrs
Sep 21, 2015

HTML5, which a good few modern engines will export to. All my stuff for example is GameMaker Studio.

Though theres still a few guys on there using Flash which Newgrounds will run through their own emulator.

Smik
Mar 18, 2014

Chrs posted:

HTML5, which a good few modern engines will export to. All my stuff for example is GameMaker Studio.

Though theres still a few guys on there using Flash which Newgrounds will run through their own emulator.

So no downloads for stuff that requires an EXE to run, huh?

Chrs
Sep 21, 2015

Smik posted:

So no downloads for stuff that requires an EXE to run, huh?

Nah nothing like that. They’ve kept the site completely browser based

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
the fact that you can just go to the website and play games is probably why it attracts a big audience of people who just want to go to a website and play games. as opposed to itch which is a whole bunch of other things first, and actually playing games in your browser is a bit of a side hobby.

Chrs
Sep 21, 2015

Yeah you’re probably right. For me I like to develop my games browser first because I don’t have think they’ll make much money anyway if I were to try to sell them and I’d rather just get them played by as many people as possible. And I think making them playable in browser eliminates a lot of blockers that might prevent a person from bothering to give it a go.

Hadlock
Nov 9, 2004

Rust supports compiling to web assembly natively supposedly, never tried it, but building browser games has gotten pretty clever in recent years

Smik
Mar 18, 2014

So ... a ways back in this thread I suggested doing something like "Idea Crafting" as an alternative way for the player character to come to new conclusions about what's going on in the world around them. A few people pointed out some games that used similar mechanics, although nothing quite like what I wanted to implement.

I've got a very rough prototype working now. I've been porting "House in Hellworld" over to RPGMaker specifically because I wanted to test out two concepts:

1. The idea of mimicking the soul-crushing grind of a retail job. This takes place by using RPGMaker's turn-based combat system, and repurposing it so you wait for customers to enter, browse the store, and check out. You can apply "customer service" to do things like greet them and help them find things but all this does is keep the manager from complaining at the end of your shift and for the scope of the game has no impact. It's just there to try to get across the tedium of the player character's day.

2. Idea Crafting. Every major event in the game gives the player information which they can then reflect upon or analyze while they sit at their day job. The player investigates a haunted house at night, trying to find a great treasure rumoured to exist there, only to be driven out by one of the various supernatural horrors within. During the job, they can think about what they encountered and combine it with some other information they have to see if they can puzzle out what's going on.

This is an example used in a battle test run -- normally you wouldn't have all the information in the game. The player combines the horror of the "Tub Head" against a prior experience with a head found in the freezer. One of the conclusions they come to is that the heads are illusionary. (I haven't included any other potential conclusions yet, but if I do the player gets both)

https://i.imgur.com/AgfE00L.mp4

I just wanted to post it here and get people's reactions to it. Ideally I'd prefer to have a drag-and-drop system but that would require creating a new engine or learning a new game engine and I knew I could prototype it in RPGMaker pretty quickly.

The original game was a visual novel in Ren'py.

fuckingusername
Jun 6, 2008
I want to thank various posters here for mentioning Picotron. I had got into a real rut / burnout with my frankly too ambitious 3D Godot project.

I downloaded it on a whim; I had not heard of it before. With no prior experience in Lua, I have a basically functional Pacifism clone after 2 evenings (not a brag, its more that the environment is so frictionless to work in). But that's not really the point - the point is I had an absolute BLAST doing it, to the level that I am counting the hours in between me and my next opportunity to dive in.

It's obviously not for everyone and it's in Alpha anyway. But using it has made me feel creative and alive again!


~all is full of, tables~ (to the bjork melody)

Dewgy
Nov 10, 2005

~🚚special delivery~📦

fuckingusername posted:

I want to thank various posters here for mentioning Picotron. I had got into a real rut / burnout with my frankly too ambitious 3D Godot project.

I downloaded it on a whim; I had not heard of it before. With no prior experience in Lua, I have a basically functional Pacifism clone after 2 evenings (not a brag, its more that the environment is so frictionless to work in). But that's not really the point - the point is I had an absolute BLAST doing it, to the level that I am counting the hours in between me and my next opportunity to dive in.

It's obviously not for everyone and it's in Alpha anyway. But using it has made me feel creative and alive again!


~all is full of, tables~ (to the bjork melody)

Hell yeah welcome to the mad mad world of Lua. :getin:

You should take a crack at Love2D at some point too. You have to put in more work than in Pico-8 or Picotron, but you also have a lot more flexibility.

Adbot
ADBOT LOVES YOU

LeFishy
Jul 21, 2010
Lua has reignited my joy of coding again too! To the point I spent a chunk of my bonus on a Playdate just to make dumb things in lua. The community seems neat and it kind of has “real life pico8” vibes. In terms of the online presence anyway… the thing hasn’t shown up yet so I can’t comment on the device itself

I haven’t actually looked at picotron yet because I’ve been deep in various love2d things getting my feet wet with more advanced lua things but it sounds neat.

Right now I’m trying to work out the maths to make a mode7 ish densha de go clone like Cab Ride on pico… though I might just try doing it in real 3d on the PD anyway. i’m hesitant to actually do much while I’m waiting for the device because the simulator on pc doesn’t match performance at all.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply