Hi I'm doing a project at school on coding in JavaScript and I was wondering if some of you could please post maybe some of your code for me. Like a script you have somewhere that is in JavaScript(preferably +-300 lines). The reason I want it is to do research on the variety of how different people code and structure/style/order/etc. So If you do send it there's no need to tidy up the code! Just copy and paste or send the file. Also please only code that is used in Unity as my project is about Unity and JavaScript. Thank you! Apologies for bad English.
#1 - It's UnityScript not JavaScripts. #2 - Don't take this the wrong way but I'd recommend doing some google searches to learn the code, it's really that simple man. That's how I learned at least how Unity works, I'd go to Youtube and Google and refuse to ask questions and just figured it out. very rarely do/did I ask a question, because with enough searching on google - you will find your answers you are looking for.
Thanx for answering This is for a project not for learning etc. My project is about how people align/structure/prioritize.Let me make an example. Let's say I'm doing a project on art. Now If every guy goes on google and searches "how to draw a house" then it defeats the purpose because I want to see how YOU draw a house. I'm not sure if I'm making any sense. I want code examples in JavaScript/Unity-script to do just that.
There are a ton of examples here. http://forum.unity3d.com/forums/scripting.12/ There are even some very lengthy discussions about code structure. Or you could browse public projects on GitHub or BitBucket or the Wiki. You'll also be contending with the fact that almost no serious projects are done in UnityScript these days. The language is the province of beginners and maintaining old projects.
Getting a bunch of random people to send you code snippets is not going to answer that question for you. It will give you code but it won't give you the hows or whys. What you need to do is find some JavaScript programmers (probably not Unity because it's not really JavaScript), and interview them and talk about their process. That's the only way you're going to get the information you're looking for.
Well really taught me how to learn coding just in general was to just find various code snippets online and to disect each one to find out their outcomes in the end. Like example, when I first started C# I didn't have a freaking clue what a float was, or a double, etc. But as I read more into what specific needs were to what I was trying to do (E.G. - Move player). I'd go to google and type in "Unity - How to move player with Rigidody" as I prefer rigidbody over crappy Character Controllers any day lol. And I'd get thousands upon thousands of examples and figure out which one I understood easier and figured it out. I learn better when I have something I can actually see interacting, you can't tell me what to put and expect me to understand it if I can't see it do anything, I mean I can now - but not when I first started learning to code. So find some good questions on google to ask - something that can show you how things work and learn how to do whatever it is you're trying to accomplish. It's better than just asking us to post snippets of code without explanation as to why we did what we did.
I know what you mean. That said, I do think that doing searches for some open-sourced or publicly shared code is a reasonable way to get this. What specifically are you trying to find out by doing this? Structure? Design? Style?