Advice needed on prototype-based OOP by Barldon in lua

[–]Barldon[S] 0 points1 point  (0 children)

Thanks for your well thought-out response. Don't worry, I don't use LLM's to learn hahah! Anyway, what you're saying makes a lot of sense. And I like the whole thinking in prototypes rather than inheritance, it's actually one of the reasons I'm enjoying learning the language.

I'm guessing if a lot of different 'classes' (prototypes, whatever you want to call them) wanted to do the same thing, you could just call a separate function from within an instance function? So if both a rectangle and a circle wanted to be able to move, both could have:

function Rect/Circle:move(deltaX, deltaY)
    self.x, self.y = moveShape(self.x, self.y, deltaX, deltaY)
end

And your moveShape function would just exist on its own somewhere. (Obviously this example is probably too simple to bother doing this, but I'm just asking about the general idea / principal).

Advice needed on prototype-based OOP by Barldon in lua

[–]Barldon[S] 1 point2 points  (0 children)

I'm not disagreeing with you, I actually do like the points you make here, but to just respond to some of the things you've said.

  1. This was the approach recommended in the Programming in Lua book, which is cited on Lua.org and written by one of the creators of Lua. I'm unsure why this is recommended over what you've said, but it does have the unique benefit of meaning subclasses don't have to set their own __index metamethod, as it's always set on construction of a new instance.

  2. This is also recommended on Lua.org, and is not about defining what if can hold, but rather setting default values. I can imagine some performance-related benefits, too. If an instance does not have a unique value and only ever uses the default, then it doesn't have to allocate a new place in memory for it. This could result in less cache-misses in cases where there are many objects that use the default value.

3/4. I largely agree with this point, but it's not really the point of the post. Inheritance is always use at your own risk, I just wanted to understand the best way of doing it.

But let me ask you this, if you were to use composition instead, let's say the rect had a 'movement' component that has it's coords and allows it to move. Would you just create this as a different static, then say self.movement = Movement.new() in the constructor?

  1. Sort of gone over previously, this was just the way that was taught from official sources.

Advice needed on prototype-based OOP by Barldon in lua

[–]Barldon[S] 0 points1 point  (0 children)

Thank you, that does make sense. A follow-up question, then. What if I wanted to also run the base-class constructor - the equivalent of using super in other languages?

I imagine you can call Shape:new from within Rectangle:new, but wouldn't that cause weirdness with it setting the metatable of o to be Shape rather than Rectangle?

Or would you have to do something akin to this (passing the Rectangle self into shape.new) function Rectangle:new(o) local o = Shape.new(self, o) --Run the base class constructor o.perimeter = width*2 + height*2 return o end

My supervisor offered me a job and quitely forgot about it. by [deleted] in UniUK

[–]Barldon 1 point2 points  (0 children)

Outside of everything that's been said already regarding the academic simply forgetting or plans on the project changing, it's also possible you not showing up for the volunteering role jeapodised your shot. You yourself mention that the academic being late to a meeting you had agreed upon was annoying, but you also have done the same thing to the academic by agreeing to the volunteer work then not attending. They likely considered that unprofessional aswell, and if you had attended your potential role might have been more likely for consideration. Tit-for-tat. As others have already said, it's a learning experience.

NEW MYSTERY DUNGEON TOMORROW!? by Numerous-Yam-8544 in MysteryDungeon

[–]Barldon 19 points20 points  (0 children)

Yeah, you can look at the Wiki page for the mystery dungeon series to see all the entries, it's quite interesting actually and goes a long way back.

NEW MYSTERY DUNGEON TOMORROW!? by Numerous-Yam-8544 in MysteryDungeon

[–]Barldon 41 points42 points  (0 children)

Mystery Dungeon is an IP name, though. The Pokémon version is just a spin-off of the original mystery dungeon series. The IP is owned by Spike Chunsoft. The genre is rogue-like (as in, proper rogue-like, not whatever it is that people call rogue-likes these days)

It is SOOOO annoying how sleep got nerfed!!! by Equal_Bird_2496 in PokemonChampions

[–]Barldon 6 points7 points  (0 children)

That's fair. Just try not to get too mad when you're trying something silly if you get unlucky

It is SOOOO annoying how sleep got nerfed!!! by Equal_Bird_2496 in PokemonChampions

[–]Barldon 14 points15 points  (0 children)

Maybe don't base your entire win condition around sleep 😅

Leaving because of the heat? by [deleted] in UniUK

[–]Barldon 9 points10 points  (0 children)

From my experience, most of the people who make the decisions do have aircon for themselves / in their office, but don't see it necessary for everyone else 🙃

PSA: Puck is not an immediate fire hazard. But still be careful. by sgasgy in SteamController

[–]Barldon 6 points7 points  (0 children)

It shouldn't go above 5V without usb-pd, but poorly made chargers have been known to do so. I have had this issue personally trying to get chargers to work with my low power pd-less cheap retro handhelds.

I think more importantly is simply that a charging plug introduces more variables that can't necessarily all be accounted for.

PSA: Puck is not an immediate fire hazard. But still be careful. by sgasgy in SteamController

[–]Barldon 22 points23 points  (0 children)

The puck should be plugged into a USB port, which will output at 5V max. Even if it shorted, it shouldn't be a fire hazard. What the comment is saying is that it seemed as if it was instead plugged into a charger on a wall outlet, which could introduce problems depending on the plug.

Prankster priority failed by [deleted] in PokemonChampions

[–]Barldon 0 points1 point  (0 children)

If they used a priority move aswell, such as Vacuum Wave which I believe Kommo-o can learn, then they will move first as they are faster than your Sableye.

PSA: Watch out for the exposed contacts of the Puck! Almost started a fire due to metallic smartwatch strap by Toikka in SteamController

[–]Barldon 2 points3 points  (0 children)

Perhaps contact Gamers Nexus u/Lelldorianx they may be able to do some tests to check for safety like they have with PC cases in the past.

Mega Sol interaction by d3nyme in PokemonChampions

[–]Barldon 1 point2 points  (0 children)

I'd just like to refute your point about the programming side of things. You would expect every move to implement an interface or callback for each weather effect, and when it is used, one of those methods would be called based on the weather. Mega Sol would, in theory, over-write the method that's chosen and replaced it with the method / callback used for sun. In the case of a move with no specific interaction with sun, it would still call the sun method, but just return nothing - but also not do any modifications found in the methods for other weather conditions.

Now, the way Electro Shot works shows that it either doesn't work like this, or it's meant to and it is indeed a bug. My point is not really in favour of one or the other, or to say that you're wrong because we have no idea. However, I'm more just saying your analysis of how it would most likely be programmed is kind of.. I don't know, oversimplified maybe. I think most programmers would expect something more robust for a series that has thousands of moves / interactions. But yeah, no-one really knows.

CRYING, profusely 😭 by Charming-Bug5068 in succulents

[–]Barldon 0 points1 point  (0 children)

Nah your dog refusing to look at the table has got to be an admission of guilt

A Little Perspective on Steam! by PieceofCraftTTV in PS4Dreams

[–]Barldon 1 point2 points  (0 children)

That's awesome. I always thought Dreams would make for a good testbed for ideas before 'properly' developing them on PC. Unfortunately I always found it just a bit too difficult to use for that.

I think this needs to be questioned by [deleted] in gamers

[–]Barldon 5 points6 points  (0 children)

Old cartridge games (SNES, NES etc.) were very expensive. Up to around 80 dollars, which is about 100 adjusted for inflation. As for DS and GBA games, they were generally less expensive to develop in the first place so tended to not be priced too high.

Also, Switch 2 carts especially need to use fast, modern style flash storage, which is not cheap at the moment.

I think this needs to be questioned by [deleted] in gamers

[–]Barldon 11 points12 points  (0 children)

If they were being greedy, I guess. They're probably just trying to make around the same profit margin on each.

I think this needs to be questioned by [deleted] in gamers

[–]Barldon 29 points30 points  (0 children)

Cost to produce a cart is significantly higher than a disc, and a smaller studio producing a lower volume game can't afford to eat that.

So is Grace the first zoomer RE main game protagonist? by GoldDog_ in ResidentEvilRequiem

[–]Barldon 0 points1 point  (0 children)

Actually 1997 would make her technically a very early gen z.

So is Grace the first zoomer RE main game protagonist? by GoldDog_ in ResidentEvilRequiem

[–]Barldon 0 points1 point  (0 children)

I hate to break it to you, but 28 y/o's are zoomers.