Hints and Tips
-
@Discostew The string slice tricks you posted came in handy!
-
On the Programs screen, you can toggle between the example programs and your own programs from the keyboard using CTRL-R and CTRL-L. Handy to avoid having to reach for a controller.
-
I don't think you actually need the CTRL key. Just "r" or "l" on the keyboard works for me.
-
One thing to take into account when working with any language that runs under an interpreter is that every character in code counts towards CPU usage. For instance, a variable name that is 16 characters long is going to take longer to parse in the interpreter prior to processing its contents than a variable name that's only 4 characters long. I do believe that comments are ignored, so they shouldn't interfere with the parsing scheme, thus won't affect CPU usage.Just be sure to comment on what things do if you do decide to shorten variable names. Don't want to forget what something does because the name becomes less readable.I was quick in my assumption that this was the case, but it is not. Variable name length doesn't have an impact on speed.
-
In relation to my post above, be sure to use the keyword
local
when defining variables in functions that also have a global counterpart. I just ran through an interesting collision of this when I threwc = controls(0)
out of the main loop (soc
could be global), and it screwed up my entire MML program during playback. That was because for shortening code in various functions I made, where I'd usec
to define a channel that was to be processed. It was odd though because technically, I was done using controls by the time it came to execute my MML_update() function, and once I was done using thec
variable in my functions, I write-back to the channel structure, so ifc
was rewritten, it shouldn't have affected anything. But it did. -
this local keyword doesn't exist. what you are experiencing there is not by design but a fault in the parser.
-
@MikeDX Huh, well in either case, it did something to prevent it from screwing up, even if unintentional. But if it has been fixed in the update, then I'll need to clean my code to remove it.
-
@Discostew Not sure this is really true. Depends on the interpreter's implementation. If it parses to bytecode before execution, this might be a non-issue; variable names are probably not kept and likely simply become pointers under the hood. If it's a syntax-directed interpreter, you may be right.
-
I usually strip out identifiers at the lexical analysis phase, so they're gone before parsing begins. The token stream produced retains the begin and end indexes into the original source code file for each token, which allows for things like printing error messages that reference the line and column where something blew up, recovering the name of a function, etc.
Anyway there are so many ways to do it that I think we should resolve to measure the performance of FUZE on shared benchmark programs before making any assumptions about its performance characteristics: otherwise we're operating on pure speculation/superstition.
-
@Zero-Division Dunno why I didn't do a simple test until now, but my assumption was wrong in thinking that shorter variable names produced faster results. I must have done some small but significant change with my code at the same time that resulted in faster processing.
-
On nitendo swotch this would be R1 (right top button) (user section) or L1 (preset Pgms)
-
@Discostew I suspected as much. We really need a way to get the text of a program off of the switch to share online that's less onerous than screenshots. Then we can really start to science the performance characteristics of FUZE with benchmarks.
-
This post is deleted! -
This post is deleted! -
@Discostew I was totally unaware of this, thanks!
EDIT: I posted before I read that the "local" thing might be a fluke. Either way, very interesting!
-
Moved discussion on the performance of varaibles within loops to it's own topic as need to keep the pinned Hints and Tips as clean as possible and free from general discussion:
https://fuzearena.com/forum/topic/522/for-loops-discussion -
For anyone trying to get a USB keyboard working with the Switch while undocked:
Not all USB-C to USB A/micro/mini converters will work.
There is a youtube video for hooking up a keyboard while undocked stating that any USB OTG hub will allow you to connect a keyboard, even if its a Micro USB hub connected to the Switch via a USB C to USB Micro adapter, but I have tried getting this to work with no success (I've tried a combination of 2 different USB-C-To-Micro adapters, 3 different micro-to-standard adapters/hubs, both OTG and normal, and two different keyboards).
However, it seems regular (non OTG) USB-C to USB-A adapter will work as long as it is USB 3.1 (which is weird because the keyboards I tried were USB 2, so the other adapters should have worked).
Anyway, if you want to connect a keyboard without the dock, here are the adapters I've found so far that work:
IHome USB-C to USB-A adapter
AmazonBasics USB Type-C to USB 3.1 Gen1 Female Adapter Cable
Nintendo Switch Lite Dual USB Playstand By HORI - Officially Licensed by Nintendo (also works for the regular Switch)
HORI Nintendo Switch Multiport USB Playstand -
I think I have a decent 'tip' for you.
Create/Code a game for YOU, not for your friends/family.
I say this because I made a 4 player game for my family to play and the feedback I got off them was beyond discouraging, of course they didn't mean to be rude or cruel and they aren't really gamers but things like 'it took you how long?', 'really? how can something that looks like that, take you so long?', 'why are the graphics so old?' and 'that was ok dear but why don't you make us a game like mario kart now?' just made me wonder why I even bothered. in fact it honked me off so much that I didn't touch Fuze for the next 3-4 days.
Now I'm coming to the conclusion that you need to create things for yourself, sod everyone else.
-
@SteveZX81 dangs that is rough, but true. Unfortunately it just comes down to a lack of understanding of how in-depth creating a game can be. That makes sense though, sometimes I already start to imagine what others will think when creating anything (music, art, games) and it can be cumbersome sometimes... lol
-
@SteveZX81 They obviously have absolutely no idea how much work goes into making a computer game