Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Post What's on Your Mind

ZenVirZan":2k55m9xm said:
thats rough man
anything we can help out with?
I've lowkey thought about starting a ko-fi page. I'm too poor to afford it but I'd also feel guilty. I don't produce content though...

If you know anything about excepting missing files in python. Nothing I do works and I don't know the specific error for it.
I'm currently trying
Code:
try:

if open('filename') > 0:

print('file accepted')

else:

print('The file is empty')

except(OSError, IOError) as error:

print('file missing')
Doesn't seem to work though and all my googling powers are worn out now xD
But it's fine if nobody knows. I can just ask in class.
 
youll probably want to store that in a variable first of all
perhaps something like
Python:
try:

    file = open(<span style="color: #483d8b;">"filename")

    text = file.read()

    if(len(text) == 0):

        print(<span style="color: #483d8b;">"File is empty.")

    else:

        print(<span style="color: #483d8b;">"File content read successfully.")

except:

    print(<span style="color: #483d8b;">"File cannot be opened.")

 
 
IOError in the Python Exception list
IOError is the one you're looking for, it covers all file opening, reading and writing operations.
so just use except IOError as error:

EDIT: if you're using Python 3, IOError and OSError became synonymous, so just use OSError instead in that case

EDIT2: im wrong and bad, IOError and OSError should both be checked for when handling IO operations if you can't find exact details on the exception a method might throw

also your code works fine in python 2.7, i dont have python 3 installed at the moment
tLUWPPV.png

EDIT3: turns out i have 3 as well, and it runs fine in that too
20eHL1A.png
 
Aha! It did work! Thank you so much man! I can be done with this AND get a distinction providing my test plan is okay and my report is written nicely. I have been messing with ruby case statements. I need to learn about it in another language, just need to decide which language. We're doing c# in class today...
 
HiPoyion":385r83o7 said:
Aha! It did work! Thank you so much man! I can be done with this AND get a distinction providing my test plan is okay and my report is written nicely. I have been messing with ruby case statements. I need to learn about it in another language, just need to decide which language. We're doing c# in class today...
switch-case statements generally only vary by the fact that they fall through or not (or a language may not include a switch-case statement at all like python).

if you've already done it in ruby and you're learning c#, i cant think of a language that has a switch-case that operates any differently to ruby or c#'s versions. (no fallthrough vs fallthrough)

perhaps you could investigate how ruby supports
case value
when "A", "B", "C"
print("nice")
else
print("not nice")
end

as there is no fallthrough, where other languages only support single case, remedied by fallthrough
switch(value){
case "A":
case "B":
case "C":
print("nice")
break;
default:
print("not nice")
break;
}




in other news, if im using Tiled for my map creation, what would be a good option for event equivalents? i cant really be bothered writing a tool exclusively for something like that, where it loads maps and creates events and exports them etc to be loaded in my engine

EDIT: i might just make a super barebones gui that lets me load lists of commands and write them to a file, then have the game engine load npc and event command files when required via point objects on a tiled map
 
aphadeon":33z8qwjr said:
Out of curiosity, /is/ there a better way to handle transparent surfaces in GL, besides z-sorting and alpha blending? I'd certainly hope so, but I haven't found it yet. Assuming I want to be able to stack an arbitrary number of them.
The "best" technique is still z-sorting with alpha blending; the big point to focus on here is the method of z-sorting. At the moment I've been favouring a real-time BSP tree for Z-sorting as that essentially "inserts" nodes at the correct Z depth and doesn't need to have a big "sort" function called on the entire thing at the end. Traversing it is very easy too. You almost certainly don't want to be qsorting a giant list of transparent surfaces.

If you have multi-sampling buffers (MSAA) then these days you can use alpha to coverage, which doesn't need depth sorting or alpha blending, but it will produce stippled alpha when the alpha of all the overlapping surfaces is greater than the number of MSAA buffers and it will drop surfaces entirely if their alpha contribution is too low. It also loses a lot of accuracy. Alpha to coverage should be used when you're using alpha channel to define extra geometry (like the holes in a chain-fence or the leafs on a tree).

Literally wrote a page about what Minecraft does wrong with its transparent surfaces. Deleted it because ugh too much.

ZenVirZan":33z8qwjr said:
also do you happen to know how inefficient it is passing functions as arguments via std::function? its only being called a few times per frame (under 5) but im wondering how bad this practice is (this is my first c++ project)
These days compilers are smart enough to see your use of std::function and make some clever decisions about it - LLVM in particular does things like converts a frequently assigned std::function variable to just be a regular function call, so no assignment happens.

Lambdas are pretty good in C++, they're no-where near as bad as they are in Java (which allocates an entire object every time, unless your JVM compiler was smart and fungled with your code to do what C++ does). As with anything in C++, use std::function where it makes sense.

If you're passing the same object type every single time and call the same method of that object then you might as well help the compiler out and replace the functor parameter with the lowest common object handle - your debug builds will be faster to step through doing this too.

HiPoyion":33z8qwjr said:
I have been messing with ruby case statements. I need to learn about it in another language, just need to decide which language. We're doing c# in class today...
This is a late reply, so probably useless by now;
There's a bit more nuance to Switch statements in different languages, C is particularly strange.

If you want a bit of history; the Switch statement in C is the primary replacement of the old Goto statement, it actually inherits the quirks of the goto statement. Despite using braces {} the C switch statement doesn't create a new stack-frame, which still catches me out sometimes. If you want to declare new variables for a switch in C/C++ you need to manually make a stack frame.
C:
<div class="c" id="{CB}" style="font-family: monospace;"><ol><span style="color: #b1b100;">switch ( willy ) {

<span style="color: #b1b100;">case RATHER_SMALL:

    <span style="color: #993333;">const <span style="color: #993333;">char * <span style="color: #993333;">const message = "Wow so small!"; // COMPILE ERROR HERE!!!

    [url=http://www.opengroup.org/onlinepubs/009695399/functions/printf.html]printf[/url]( "%s<span style="color: #000099; font-weight: bold;">\n", message );

    <span style="color: #000000; font-weight: bold;">break;

}

 

<span style="color: #b1b100;">switch ( willy ) {

<span style="color: #b1b100;">case RATHER_SMALL:

    {

        // This compiles fine as we added a new stack-frame with {}

        <span style="color: #993333;">const <span style="color: #993333;">char * <span style="color: #993333;">const message = "Wow so small!";

        [url=http://www.opengroup.org/onlinepubs/009695399/functions/printf.html]printf[/url]( "%s<span style="color: #000099; font-weight: bold;">\n", message );

    }

    <span style="color: #000000; font-weight: bold;">break;

}
This behaviour is literally here because the Goto statement jumps within a stack-frame, so the Switch statement operates within the current stack-frame; you cannot declare variables within a stack-frame (when you declare a variable in C/C++ the compiler secretly allocates them at the start of the stack-frame, C99 used to force programmers to declare their variables at the top because of this).

The Switch in C is probably the messiest part of the language. The history of the language collided with modern practices (being able to write variable declarations anywhere within the frame). I know some studios actually have the policy of never use the break statement, which covers most uses for switch statements (use if-else instead).


C/C++ only allows you to use integer types in switch statements - this is something other languages relaxes on (and treats the switch statement as a glorified if-else). Ruby lets you switch on anything, pretty much (including conditional statements; can be something like "when a != b").


I think another language to look at is Swift. C switches have the "break" keyword, which prevents the program from stepping into the next conditional in the switch statement (yes there are times when this is useful). In majority of cases, the programmer wants to break on every conditional, so you end up with breaks everywhere.

In C you can do this:
C:
<div class="c" id="{CB}" style="font-family: monospace;"><ol><span style="color: #b1b100;">switch ( letter ) {

<span style="color: #b1b100;">case 'A':

<span style="color: #b1b100;">case 'a':

    [url=http://www.opengroup.org/onlinepubs/009695399/functions/printf.html]printf[/url]( "<span style="color: #000099; font-weight: bold;">\"A<span style="color: #000099; font-weight: bold;">\"<span style="color: #000099; font-weight: bold;">\n" );

    <span style="color: #000000; font-weight: bold;">break;

}

// Prints A when letter == 'A' or letter == 'a'
In Swift this fails due to a missing statement for case 'A'.

In Swift you can combine with a comma or use the Fallthrough keyword:
Swift:
<div id="{CB}" style="font-family: monospace;"><ol>switch ( letter ) {

case 'A', case 'a':

    print( "\"A\"" )

}

// Prints A when letter == 'A' or letter == 'a'

 

switch ( letter ) {

case 'A':

    fallthrough

case 'a':

    print( "\"A\"" )

}

// Does the same as above
So Swift breaks by default, requires fallthrough otherwise, uses the comma as an easy way to capture multiple cases.

ZenVirZan":33z8qwjr said:
in other news, if im using Tiled for my map creation, what would be a good option for event equivalents? i cant really be bothered writing a tool exclusively for something like that, where it loads maps and creates events and exports them etc to be loaded in my engine

EDIT: i might just make a super barebones gui that lets me load lists of commands and write them to a file, then have the game engine load npc and event command files when required via point objects on a tiled map
The TileD MV Plugin uses the object layer for placing events (you add the event ID as a property, then create the event as normal on an MV map). I can't imagine a better way than this.

So yeah: your idea of using point objects to reference your command list file is what other people are doing, so maybe do this too. I wonder if TileD supports addons like Unity does? If this is the case, you could probably make a TileD editor tool so you don't need to create events separately.
 
Xilef":rsagttqm said:
The TileD MV Plugin uses the object layer for placing events (you add the event ID as a property, then create the event as normal on an MV map). I can't imagine a better way than this.

So yeah: your idea of using point objects to reference your command list file is what other people are doing, so maybe do this too. I wonder if TileD supports addons like Unity does? If this is the case, you could probably make a TileD editor tool so you don't need to create events separately.
i dont actually own mv but i might look into it. im assuming mv doesnt use some sort of marshalling system for their data like the previous gens did?
 
ZenVirZan":3pd2p6hn said:
i dont actually own mv but i might look into it. im assuming mv doesnt use some sort of marshalling system for their data like the previous gens did?
TileD is not a native feature of MV (despite being advertised as one), it's a separate Plugin, I don't think it's worth investigating for your needs.

MV uses JSON, so everything is pretty much exposed and easy to stab at.
 
man after using rpgmakers for so long i really took the number of little windows they used for granted
there are so many different windows you gotta make to emulate the behaviour of their command input options etc
 
ZenVirZan":3832zeys said:
man after using rpgmakers for so long i really took the number of little windows they used for granted
there are so many different windows you gotta make to emulate the behaviour of their command input options etc
These days I just throw in a scripting engine and focus on hooking that up, so then you just need to code up a text editor with some optional event params around it (and pages support, if that's your jam).

The event command system is there for non-programmers, if you're making a project as a programmer then maybe go with something you can use that doesn't require as much time spent developing the tools.
 
Xilef":38880ak5 said:
The event command system is there for non-programmers, if you're making a project as a programmer then maybe go with something you can use that doesn't require as much time spent developing the tools.
yeah at this point im just going to have a popup that asks for values as part of a set of key-value pairs, no fancy input systems, tickers or sliderbars
 
I finished the assignment.
Test plan and report was a fuck. Office 365 can suck my nuts and so can google docs to a lesser extent.
I'm so freaking tired I haven't slept in like 2 days but I'm staying up with a friend until he is done. Only an hour more.
I have to be up early tomorrow though still, we've got a finance talk and if I can get any money from this college HO BOY SIGN ME TF UP! I am struggling so much financially xD
 

Fayte

Sponsor

Mega Flare":1yzascyc said:
We are 100% getting pre release kits this month yay. Also we not getting opus 4 till Monday :(

dang why they stiffing y'all so hard? Also, any ideas what you're gonna be running in this new format?
 

Mega Flare

Awesome Bro

Fayte":fyj2fvrd said:
Mega Flare":fyj2fvrd said:
We are 100% getting pre release kits this month yay. Also we not getting opus 4 till Monday :(

dang why they stiffing y'all so hard? Also, any ideas what you're gonna be running in this new format?
Because they ship it to the usa first then to us that's why. I'm sticking to mono fire because I'm poor. Got a few lists I want to try out. One Ff6 focus, ones runs all bahamut and other has new light cloud and ff7 cards
 

Fayte

Sponsor

Yeah I’ve got so many ideas I want to try out. These new cards along with monsters just opened the game up completely. Soooo many different options and variations.
 
Woke up at 3:00 AM today. I've had insomnia for years and I figured this was just going to be another one of those nights. I popped a melatonin and tried getting back to sleep. Eventually I felt sick to my stomach. I can't sleep if I'm getting ready to throw up. The worst part about being sick is waiting for the inevitable.

...Just realized that could be read much more morbidly than intended.

Amy, which game is this now?

Fayte and Mega Flare, I gotta respect your enthusiasm. I haven't played a CCG since Magic back in 1997 or so. It looks like you guys are having fun.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top