string as index of array?

Is it posible in maxscript to have something like map in C++? I would really like to do something like this in maxscript:

map["name1"]=1
and if I do later something like this:
x=map["name1"]
x should have the value 1.
This is just a simple example.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Swordslayer's picture

Dictionary

See the Dictionary Values topic in the maxscript reference.

gtafan's picture

This Dictionary looks like

This Dictionary looks like exactly what I need, but unfortunately it´s only avaible since Max 2017, which make it useles for me.

jahman's picture

you can access collection

you can access collection members like that, but not the elements of arbitrary array

delete objects
t = teapot()
t.material = standardmaterial name:"abcd"
scenematerials[#abcd] == scenematerials["abcd"] -- returns True
 
(join #() scenematerials)[#abcd] -- Runtime error: array index must be positive number, got: #abcd

read about bsearch in mxs reference or look for examples at cgsociety.org maxscript related section

gtafan's picture

I don´t want to acces scene

I don´t want to acces scene object in this case.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.