![]() |
Named Array Indexes
I'm sure most scripters should know of that array format used when saving object variables to array.
array = {"var1=value1", "var2=value2", "var3=value3", "var4=value4"}; Was wondering if a little feature could be added where if you did: array["var2"] = "newvalue"; It would correctly replace the proper index with the new value after the equal sign. They would also be read in the same manner. |
Associative arrays?
In reality it would be just as easy to use a TStaticVar or something. |
Quote:
|
Client vars are too limited by character to be doing things like that.
|
Quote:
It is only the act of doing /open and applying changes that your vars get trimmed. This has nothing to do with the fact that they are client vars but rather is because anything in the "flags" section of /open gets clipped like such. If you just never use /open (such as scripting your own player editor) then you don't need to worry about such stupid misconceptions. I personally never ever have to use /open for anything what-so-ever. |
Quote:
High five! :fro: |
Valikorlia does not revolve around me, there are plenty of other staff who are going to have to use open at some time or another. And I'm not going to prevent them from doing it just because of my fancy scripting.
The character limit needs when using the /open command needs to be removed, period. I'm not going to script my own player editor because you should not need to get on client to do that, that is what RC is for. |
*sigh* Here we go again..
|
Quote:
Quote:
|
*Bump*
I have renewed interest in this feature. |
array = {{"key", "value"}, {"key", "value"}}
PHP Code:
PHP Code:
|
Well duh.
And I prefer it would work like: array = {"key=value", "key=value"}; Since that is how objects are saved to arrays and such, its more of a standard. Doing array["key"] = value looks much nicer though and would be simple enough to implement. Python makes use of it well. |
Yes. Sadly, this isn't Python or PHP or any other languages that make use of associative arrays. Taken into considering that we're talking about GScript... I would say that it isn't part of the language...
I provided you a way to do this... You can easily call functions, but right now, you just want it to LOOK pretty... Which isn't the purpose of programming language... It just converts it back to the very same thing. And implementing that would mean you'd have to change the lexical of the language... And that's not pretty. There are ways that an associative array can be 'simulated'... So I don't see any more purpose to this than for aesthetic reasons. Stefan is busy enough fixing things that ARE useful. For instance, new features. |
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
I asked for the feature because it would be an easy solution to an irritation, and I'm not going to make functions and bother joining them everytime I use the feature when they could be done much better this way. Using functions would be more troublesome than giving the data specified indexes. Such a feature would also be good for those newer to scripting/programming. I don't think you're doing a good job of explaining why not to add a simple feature present in other languages. |
hmm I doubt Stefan will add it. Stop being an ******* and use the alternative
|
Quote:
I already explained why the alternative was unfavorable, and if you can't read posts and respond properly you will be ignored. |
sado
Infact, instead of trying to help you, just wait for Stefan to release this feature ^^ |
Well you can give array members names now and use obj.getArrayMember(name) although it is not really recommended since it is much slower than using normal variables (obj.(@mycustomvarname)), it is mainly used for xml stuff.
In Flash script (and Javascript?) they just map array["key"] to array.key I also beg to differ, Graal IS a programming language |
Quote:
|
Quote:
|
look in to it deeper @ Crow. You'll see that you're wrong.
|
Quote:
|
I think it's more of a scripting language. Its limited to graal much like javascript is limited to a web browser.
|
Quote:
|
Quote:
|
Quote:
|
Quote:
Quote:
|
Quote:
|
Quote:
|
Quote:
Plus, we'd probably be calling our code 'programs' and not 'scripts' if gscript was a programming language. To top it off, the forum for such 'scripts' is called: NPC scripting. |
And its Gscript :f
|
And it's called C++ script, so what? Please stop those nonsense discussions. Of course Graal scripts are compiled. Java is used for billion dollar transactions, and you don't want to call it a programming language just because it's not compiled into machine code? If you want to say that programming is a higher kind of art than scripting then it's probably to show a difference between a hired programmer and a script kiddie, but scripting languages are still programming languages.
Please stay on-topic (will need to delete those messages anyway I guess). |
For a second I thought this thread was about me...
|
Quote:
|
Quote:
Programming = Code that is Compiled into Computer Language (Assembly) Scripting = Code that is Interpreted by a virtual machine. Scripting provides better diversity ( running on multiple OS without problems ) Programming provides better speed ( doesn't need to be interpreted ) Both are PRACTICAL and both provide their own uses. In speed-critical apps, programming is the choice... In multi-os, scripting is the choice. Neither are superior to each other... Especially when computers are pretty fast and libraries are plenty... The difference between them aren't that great. ( Graal is compiled, yet runs on various OSes... And GScript is interpreted, but doesn't have a huge difference in speed than if it were compiled ) |
Please check out http://en.wikipedia.org/wiki/Scripting_language if you have still confusion about programming languages.
|
| All times are GMT +2. The time now is 10:19 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.