| Blockland Forums > General Discussion |
| OH MY GOSH IM LEARNING TO CODE |
| << < (6/12) > >> |
| Electrk:
--- Quote from: Ben Grapevine on September 08, 2012, 02:03:59 AM ---cmdtoserver.killall(9001); --- End quote --- --- Quote from: Kaphonaits² on September 08, 2012, 01:29:52 AM ---I'm going to cut you if you ever try to make programming jokes like this again. --- End quote --- --- Quote from: Incinerate on September 08, 2012, 12:22:08 AM ---C++ I believe. --- End quote --- --- Quote from: Kaphonaits² on September 08, 2012, 01:29:52 AM ---Wrong. --- End quote --- The language is TorqueScript, which is similar to C# but is its own language. |
| Kaphonaits²:
--- Quote from: Electrk on September 08, 2012, 03:11:19 AM --- The language is TorqueScript, which is similar to C# but is its own language. --- End quote --- TorqueScript is correct and you really can only compare it to C-like languages because of how awkwardly stuffty it is sometimes. So, you're trying to set the velocity of an object. You'd think a function like that would take something like three ints, three floats, or a vector3 of some sort. Wrong! It takes a string! --- Code: ---findclientbyname(Kaphonaits).player.addVelocity("0 0 200"); --- End code --- |
| M:
--- Quote from: Kaphonaits² on September 08, 2012, 04:20:12 AM ---TorqueScript is correct and you really can only compare it to C-like languages because of how awkwardly stuffty it is sometimes. So, you're trying to set the velocity of an object. You'd think a function like that would take something like three ints, three floats, or a vector3 of some sort. Wrong! It takes a string! --- Code: ---findclientbyname(Kaphonaits).player.addVelocity("0 0 200"); --- End code --- --- End quote --- Thinking about traditional types in Torquescript is bad Even an integer is a string If you don't use anything that isn't alphanumeric you don't need to use quotes but it's still a string So thinking of static types in Torquescript means you're thinking of it wrong What you should be doing is thinking about string formats .+ - String \d+ - Integer (but also a string) \d+\.\d+ - Float (but also a string) \d+ \d+ - Vector2 (but also a string) \d+ \d+ \d+ - Vector3 (but also a string) If you try to call a method on a string it tries to resolve the string to an object - if it's entirely numeric, it tries as an object ID, then it tries as an object name. In addition, trivia: false and true, if unquoted, are 0 and 1, not "false" and "true". "true" as an explicit string is false. A string like "24 slaves in the field" if used as a number will be 24, not 0, as anything before the first non-numeric character of the string is treated as a number (it doesn't validate the whole string to see if it actually is a number - really this means you can match a Torquescript integer as \d+.*) |
| Kaphonaits²:
--- Quote from: M on September 08, 2012, 04:41:28 AM ----awesomesnip- --- End quote --- Yes but there are reasons that the traditional types exist. So you don't need things like useless duplicates of operators. --- Code: ---if(%blah $= %blergh) { //... } --- End code --- --- Code: ---if(%blah == %blergh) { //... } --- End code --- |
| Isaac Fox:
Why, why, why are my parents forcing me to learn Python? I want to learn TorqueScript, dammit! |
| Navigation |
| Message Index |
| Next page |
| Previous page |