Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 781 782 [783] 784 785 ... 795

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 818136 times)

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11730 on: April 12, 2020, 07:44:22 pm »

Data-driven games scale much better however, so what feels initially like more work pays for itself pretty soon.

mko

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11731 on: April 13, 2020, 01:06:52 pm »

Any idea whatever Unity has sane package system? I am failing to find way to import local package from a package.

Any packaging system known to me allows to do something like that: program imports package A, package A imports package B.

But in Unity? Apparently B must be from Asset Store, it will not work otherwise ("Version 'file:../../MeshMaker_Package' is invalid. Expected a 'SemVer' compatible value.").

grumble, grumble, grumble - turns out that git submodules are superior and I probably should switch to them.
« Last Edit: April 13, 2020, 01:12:44 pm by mko »
Logged

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11732 on: April 13, 2020, 03:05:06 pm »

I remember being able to create my own Unity packages and then import them from the local filesystem. Granted this was several versions ago, and I've long since stopped bothering to create my own Unity packages.



Papyrus, the scripting language used by Fallout 4 and Skyrim, is interesting. Exceedingly poor documentation, but I have a particular fondness for narrow-scope, special purpose languages like this--languages meant for exactly one job in one problem space in one program.

I wish the compiler gave more specific error messages though. Instead of telling me that I had an incorrect number of parameters, or that the object didn't have the function I was trying to call, it told me that I should add a right parentheses at line 18, column 41. ::)
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

McTraveller

  • Bay Watcher
  • This text isn't very personal.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11733 on: April 13, 2020, 03:20:17 pm »

I wish the compiler gave more specific error messages though. Instead of telling me that I had an incorrect number of parameters, or that the object didn't have the function I was trying to call, it told me that I should add a right parentheses at line 18, column 41. ::)

My "favorite" wrong error is from Matlab.  I once had an m-script give the error "The operands to && or || must be logical values".  The actual error was that a file couldn't be found but some other code caught the file-not-found exception* and then just returned a null, and so the code evaluating something out of the file was trying to do a boolean operation on null and threw that exception.  The best part is the file wasn't found because of a typo - so instead of saying "The file '<mistyped filename>' wasn't found" you got the exception "operands are of the wrong type."

*This code base is full of "exceptions as control flow" too... many many WTFs there, but this is by far my favorite because it hid a user-solvable problem behind a meaningless exception message.
Logged

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11734 on: April 13, 2020, 03:37:43 pm »

That's why I tend not to bother throwing exceptions myself--if there's a problem, I want it to fail as spectacularly (I prefer the term "easy to notice") and as early as possible, so that my attention is pointed directly at the problem from the word go. Even if I were to get off my lazy ass and finish something instead of tinkering, I doubt anything I make would be so complex or so large that I need to define my own exceptions.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

mko

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11735 on: April 13, 2020, 03:46:12 pm »

I remember being able to create my own Unity packages and then import them from the local filesystem. Granted this was several versions ago, and I've long since stopped bothering to create my own Unity packages.
Oh, you can import packages from disk. But only into Unity project.

You apparently can't do it in package. Not sure about the preferred workaround.
Logged

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: if self.isCoder(): post() #Programming Thread
« Reply #11736 on: April 13, 2020, 08:10:17 pm »

I wonder what would happen if there was massively available and free server space/time? I mean like, imagine if you could just go onto the super server hosting site, and just make an instance and do whatever you want with it, and at a minimum every household at at least a small server. I have no idea what people would do with that but there's lots of times when I would have really liked to just be able to have a free server
Logged

mko

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11737 on: April 13, 2020, 08:44:27 pm »

I wonder what would happen if there was massively available and free server space/time? I mean like, imagine if you could just go onto the super server hosting site, and just make an instance and do whatever you want with it, and at a minimum every household at at least a small server. I have no idea what people would do with that but there's lots of times when I would have really liked to just be able to have a free server

It is already true. Heroku, Amazon, Google Cloud, even some hosting sites all have free tier (or at least had in 2020). Not amazingly performant but you can actually do something with that. For basically nothing you can have performant servers.

Though Amazon has nice caveat: you made bug/you are DDoSed and your bill is now 100k $? Amazon will expect you to pay.

Heroku had caveat of server being unable to stay up for 24/7.

----------

And on topic of performace: we have USB-C chargers more powerful than Apollo 11 guidance computer: https://forrestheller.com/Apollo-11-Computer-vs-USB-C-chargers.html

Please, see at least the starting table.
« Last Edit: April 13, 2020, 08:47:09 pm by mko »
Logged

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11738 on: April 14, 2020, 10:45:31 pm »

Dipped my toe into Visual Studio build events. Very useful stuff; previously I assumed I would have to somehow copy any non-code files into the output directory by myself, although I knew that that didn't make any damn sense.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

bloop_bleep

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11739 on: April 15, 2020, 12:28:32 pm »

I have just learned that user-defined literals exist in C++ since C++11.

What in the world.
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

WealthyRadish

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11740 on: April 15, 2020, 01:00:25 pm »

I have just learned that user-defined literals exist in C++ since C++11.

What in the world.

Quote from: Example
Code: [Select]
int main(){
    double x = 90.0_deg;
    std::cout << std::fixed << x << '\n';
    mytype y = 123_mytype;
    std::cout << y.m << '\n';
    0x123ABC_print;
}
Code: [Select]
Output:

1.570796
123
0x123ABC

I know C++ is the ultimate mongrel language (and I actually think that's great), but my first reaction is that this is something incredibly gross that I hope to never see in the wild.
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #11741 on: April 16, 2020, 09:30:22 am »

the _print is definitely dumb and bad and stupid and wrong, so probably/hopefully just used for the example to show that it does technically work but plz plz pretty plz never do dis.

_km and such is neat assuming it also allows you to infer conversions between extensions (e.g define that _km / _s gives a type of _kmps). That can be useful to avoid things like the fate that befell a certain probe.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11742 on: April 16, 2020, 09:56:46 am »

I'm certain that this doesn't allow implicit types of the km/s type. They're not actually types, they're operators.

WRadish left out the guts that show how this actually works.

Quote
constexpr long double operator"" _deg ( long double deg )
{
    return deg * 3.14159265358979323846264L / 180;
}

The good thing is that this is a constexpr, so it's guaranteed to be evaluated at compile time, not run time. Note that all this does is implicitly spit out a scalar value in radians, not an encoded "degree" type, so there's no way to chain this with an _s definition to make for example radial velocity in degrees per second. However, note that this is exactly the same as having an inline degtorad() function, and degtorad would actually be clearer as to the meaning.

What you want is template meta-programming to make things like km/s work, btw remember I gave an example of working code for that a couple of pages back, which can take a km template and an s template, and spits out a novel km/s template representation, while also forcing type consistency, all at compile time, so no overhead. Or, you could come up with a runtime equivalent that would be more flexible but of course slower.
« Last Edit: April 16, 2020, 10:09:09 am by Reelya »
Logged

MorleyDev

  • Bay Watcher
  • "It is not enough for it to just work."
    • View Profile
    • MorleyDev
Re: if self.isCoder(): post() #Programming Thread
« Reply #11743 on: April 16, 2020, 10:18:11 am »

You'd still have to wrap it in structures to handle it and so a generic solution would still need to use more code and template metaprogramming. But from what I can see, would let you use light-weight structs and functions instead of heavier classes, like in the example with
Code: [Select]
struct mytype
{
    unsigned long long m;
};

So as I understand it you could define:

Code: [Select]
struct km { long double v; };
struct s { long double v; };
struct kmps {long double v; };

constexpr km  operator"" _km ( long double v ){ return km{v} }
constexpr km  operator"" _s ( long double v ){ return s{v} }

constexpr kmps operator/ (km k, s sec){ return kmps{(k / s)} }

...

kmps res = 5_km / 2_s
« Last Edit: April 16, 2020, 10:24:26 am by MorleyDev »
Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #11744 on: April 16, 2020, 10:31:34 am »

There are standards-defined literals too.

This means that you can write 1.5+2.5i as actually 1.5+2.5i and not std::complex<double>(1.5,2.5).

My primary confusion is why I hadn't heard of this before. I did spend some time floating obliviously in C++98-land but I thought I caught up on C++11 capabilities at least.
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.
Pages: 1 ... 781 782 [783] 784 785 ... 795