ComputerAxe's Broken W.I.Ps

ComputerAxe

Member
Jun 7, 2024
38
3
210
South Carolina, USA

ComputerAxe's Broken W.I.Ps​

Since neither my ideas nor code are good enough to a point that I feel comfortable applying for Modder yet, I figured I'd start up a thread in a similar vein to Chilly's Knicknacks but for horribly broken/buggy/not fully thought-out mods. Once I have achieved a quality that I feel is not completely broken, I will apply for Modder and release my big mods that I've had ideas for but am not skilled enough to code.
The reason I posted this in Modding General Discussion instead of Modding Help is that I feel this is more geared towards getting suggestions and/or constructive criticism, rather than just straight up HeLp Me I dOn'T kNoW hOw To CoDe even though it may border on that sometimes. As such:

Constructive criticism is greatly appreciated, and code fixes are appreciated even more!​

If you'd like to contribute, the GitHub for all the mods that are/will be on this thread is here.
Once I release the last mod on this thread, I will apply for modder, and once/if my application is approved, I will open mod commissions.

Alright now for the good(?) stuff:

Current Releases:​

Jukebox: Direct Download

 
Last edited:
When you were asking for suggestions, I expected the code to be pretty horrendous, but it's really not that bad! Here are some recommendations, however generally these can be pretty subjective.

The first thing I noticed is with `cmd_active`, you're making it snake case (which pretty much means replace the space with a _ in a variable name), however everything else is just... multiple words without any form of separation. The snake case is perfectly fine, "currentaudio" and "curmusfilename" aren't great however. If you want to go snake case, I'd rename the variables to "current_audio" and "cur_mus_filename". Most mods that I see don't use snake case (including my mods), most of us use camel case, which makes the start of a new word a capital letter. Using this var naming scheme, that'd be "currentAudio" and "curMusFilename".

A pretty small thing is you don't give the user any feedback to what music file they selected. Pretty sure you'd know how to fix this one : ).

The last thing I have is on line 45 you're checking if the string "curmusfilename" contains something. The problem with this is that string can also be nil, a simple fix would be to check if it's not nil first, here's what that would look like:

Before:
`if (string.find(curmusfilename, ".mp3") or string.find(curmusfilename, ".ogg") or string.find(curmusfilename, ".aiff")) then`

After:
if curmusfilename ~= nil and string.find(curmusfilename, ".mp3") or string.find(curmusfilename, ".ogg") or string.find(curmusfilename, ".aiff") then

I figured I should mention that you don't have to check for nil here, you can instead do `if curmusfilename and ...`. Now I still get confused on if I should do that or not, so it's safe to explicitly check for nil, however the reason it works here is because curmusfilename is a string, and strings when used in that case (I believe) always returns true if it's not nil. Someone else who has a bit more information should discuss this topic, not me :/.

That was all the problems I noticed, very cool stuff! Happy coding : D
 
  • Love
Reactions: ComputerAxe
The most glaring issue that I have with ALL my code is typically just picking my set case/style and sticking with it- thanks for pointing that out!
As for the rest of it, this was pretty bare-bones because I was worried I’d have to completely redo my mod because I’d had made some huge issue regarding the very base of my mod- and that isn’t just me being a worrywart, it’s usually what kills off my projects. Apparently I was wrong in worrying about for once, ha! I’ll go to my computer and implement all that!
Thank you!

EDIT: Oh yeah, and as for the "you don't give the user any feedback to what music file they selected":
I really thought I did, but...
It turns out it's a LOT harder than you'd think, I spent half of yesterday trying to figure it out.
tl;dr: It's a rabbit hole involving root access.
Unless you're referring to resume/play/stop/etc functions. That I can and will do.

Jukebox v1.1.0​

Jukebox allows you to play music in chat, and at its current state isn't really much beyond a glitchy proof-of-concept. Here's some commands:

"/jukeplay [SONGNAME] [true|false]":
SONGNAME can be replaced with any sound file of your choice that is located in the mod's "sound" folder, as long as it is in mp3/ogg/aiff format.
For example, to play the test.ogg file included with the mod, use:
"/jukeplay test.ogg"
If your file is an MP3, you don't have to type the ".mp3" at the end.

"/jukepause"
This command has no arguments, and pauses/resumes the current music file. It can also be used to restart an unlooping music file if used twice.

"/jukestop"
This command has no arguments, and stops and unloads the current music file.

Since that's done, the only other big things to note are that:
  1. The vanilla OST still plays in the background. No clue how to fix this, help would be appreciated.
  2. If you type in the file's name wrong, the game spits out errors which can be viewed by pressing F1.
  3. The code sucks (less, thanks EmeraldLockdown)

Download Here!​

Don't double post! Use that edit button! Post automatically merged:

This is going on about a week-long hiatus.
You’ll see why soon.
 
Last edited:

Users who are viewing this thread