ScriptSpot

Forum topic · General Scripting

string as index of array?

By gtafan · 2017-10-11

Description

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 (4)

Dictionary

Swordslayer · 2017-10-12

See the Dictionary Values topic in the maxscript reference.

gtafan · 2017-10-17

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

jahman · 2017-10-11

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 · 2017-10-17

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