Obvious disclaimer here: this is for more veteran coders for use on the repeated levels (Brawls and such).
I’ve used functions in a couple of cases, which hasn’t actually made the code more concise, but does separate out some of the looping and makes it easier to read the code and debug (especially when you can only look at 10 or so lines of code in the window).
Yesterday I was peeking at someone else’s code from the high scores window (which usually doesn’t work for me, btw, but sometimes does). Unfortunately I can’t find it agan and post it, but I believe it was python with decorators. So even though it was a higher level of (I think) Sarven Treasure, the code was very brief, and most lines started with @, which is beyond my python skillz but I believe those are decorators (fancy functions).
But, I didn’t notice where the decorators/functions were defined. So, immediate question is can I store functions somewhere and then globally access them on individual levels?
And more generally, I’m just looking for any tips for dealing with the fact that it gets to be a pain to edit things in code combat once your program exceeds 30 or so lines. I know copy and paste to an external editor is one option, but I’m looking for other ways, if they exist. Thanks!
What you most likely saw was Coffeescript, another language that is supported.
You can select it from the Hero-Selection-Screen.
Try it out. Though it sometimes behaves a bit… strange, most levels work out of the box. It is a combination of Python and JavaScript. The whole engine is based on it.
Yeah, it might be cool to experiment with other languages but from other threads it sounds like a bit of a pain b/c you lose all your existing code when switching languages. Also, if that’s the case I doubt it actually is any more concise than comparable python code unless coffee script adds the ability to access external/global functions?
In some sense, I’m asking a more general question than just about python: can I make a library and then access it from individual levels? I assume the answer is no but no harm in asking…
This is currently not possible (though there is some work in this direction planned/ongoing). We will inform you (and everybody else) as soon as this is possible. This will most likely happen in it’s own topic though.
Cool, looking forward to that and/or a better text editor! But don’t mean to sound like I’m complaining, it’s nice to see the continual expansion and improvements in other areas.
Yup, as discussed in that thread, everybody likes the idea including “codecombat” themselves, but…
For now, it only saves the code currently in the “code box.” (Well, it also has some sort of copy for the currently submitted ladder game.) (as far as I know it doesn’t keep a history of all your submits, but I could be wrong on that point and even if it does we don’t have direct access to it (you would have to convince Nick to dig it out for you.))
So, for now at least, you have to do your own “source control” where/how-ever you wish to do so.
Well, I just thought of another way…
Change language,
cut code,
"reload" default code,
paste old code at bottom of code-window,
comment out old code (with language appropriate method),
have fun with new language,
reverse/repeat.
All your code for each language is always there in the window (well, except during the cut-reload-paste moment, of course.)
It would actually be myemailaddress+coffee@gmail.com (the stuff after the plus is ignored, not the stuff before the plus). And I think some other email providers also support plus addressing, not just Gmail.