Guoshima
12-07-2004, 01:47 PM
Hello,
I am quite new to programming in MaxScript and I simply need to set up a simple script so that the artists can store a little bit of extra data according to the mesh so we can chech these while loading the model ingame.
Creating the script was not a problem, but storing the data somehow is. When I have 2 objects in my scene, and both of them have the same script set, max always forgets the set data of the object when I select another one. So my question is rather simple. How can I store and reload the settings done in my dropdownlists, and multilistsboxes when the object is selected again.
Here is my code (part of it which shows the problem)
ExtraDataDef = attributes"extraData" version:1 attribid:#(0x42dfaecb, 0x71356c9f)
(
parameters main rollout:params
(
objecttype type:#string ui:objecttype_dd default:"Base"
)
rollout params "Unit Parameters"
(
dropDownList objecttype_dd "Object Type" pos:[15,24] width:135 height:40 items:#("Base","Option","Weapon")
on objecttype_dd selected i do
(
objecttype = objecttype_dd.items[i]
)
)
)
utility CustAttributeTestUtils "Extra Data Attribute"-- define the utility
(
function GetCustAttribDef Temp attribName=
(
bHasOldDef = false
old_attr_def = undefined
count = custAttributes.count Temp
print count
for i = 1 to custAttributes.count Temp do
(
old_attr_def = custAttributes.getdef Temp i
print old_attr_def.name
if old_attr_def != undefined and old_attr_def.name == attribName do
(
bHasOldDef = true
return old_attr_def
)
)
return undefined
)
rollout ExtraDataPanel "Extra Data"
(
button ExtraDataApply "Set Extra Data" width:122 height:20
button ExtraDataRemove "Remove Extra Data" width:122 height:20
on ExtraDataApply pressed do
(
for item in selection do
(
old_def = GetCustAttribDef item ExtraDataDef.name
if old_def == undefined do
(
custAttributes.add item ExtraDataDef
)
)
)
on ExtraDataRemove pressed do
(
print "Removing CA"
for item in selection do
(
old_def = GetCustAttribDef item ExtraDataDef.name
print old_def
if old_def != undefined do
(
print item.name
custAttributes.delete item old_def
)
)
)
)
on CustAttributeTestUtils open do
(
addRollout ExtraDataPanel
)
on CustAttributeTestUtils close do
(
removeRollout ExtraDataPanel
)
)
Well .. I hope someone can help me because this needs to be possible and easy right ?!?
Just posting a sample which does the same thing is of coarse also oké ..
Thanx in advance,
Kenzo
I am quite new to programming in MaxScript and I simply need to set up a simple script so that the artists can store a little bit of extra data according to the mesh so we can chech these while loading the model ingame.
Creating the script was not a problem, but storing the data somehow is. When I have 2 objects in my scene, and both of them have the same script set, max always forgets the set data of the object when I select another one. So my question is rather simple. How can I store and reload the settings done in my dropdownlists, and multilistsboxes when the object is selected again.
Here is my code (part of it which shows the problem)
ExtraDataDef = attributes"extraData" version:1 attribid:#(0x42dfaecb, 0x71356c9f)
(
parameters main rollout:params
(
objecttype type:#string ui:objecttype_dd default:"Base"
)
rollout params "Unit Parameters"
(
dropDownList objecttype_dd "Object Type" pos:[15,24] width:135 height:40 items:#("Base","Option","Weapon")
on objecttype_dd selected i do
(
objecttype = objecttype_dd.items[i]
)
)
)
utility CustAttributeTestUtils "Extra Data Attribute"-- define the utility
(
function GetCustAttribDef Temp attribName=
(
bHasOldDef = false
old_attr_def = undefined
count = custAttributes.count Temp
print count
for i = 1 to custAttributes.count Temp do
(
old_attr_def = custAttributes.getdef Temp i
print old_attr_def.name
if old_attr_def != undefined and old_attr_def.name == attribName do
(
bHasOldDef = true
return old_attr_def
)
)
return undefined
)
rollout ExtraDataPanel "Extra Data"
(
button ExtraDataApply "Set Extra Data" width:122 height:20
button ExtraDataRemove "Remove Extra Data" width:122 height:20
on ExtraDataApply pressed do
(
for item in selection do
(
old_def = GetCustAttribDef item ExtraDataDef.name
if old_def == undefined do
(
custAttributes.add item ExtraDataDef
)
)
)
on ExtraDataRemove pressed do
(
print "Removing CA"
for item in selection do
(
old_def = GetCustAttribDef item ExtraDataDef.name
print old_def
if old_def != undefined do
(
print item.name
custAttributes.delete item old_def
)
)
)
)
on CustAttributeTestUtils open do
(
addRollout ExtraDataPanel
)
on CustAttributeTestUtils close do
(
removeRollout ExtraDataPanel
)
)
Well .. I hope someone can help me because this needs to be possible and easy right ?!?
Just posting a sample which does the same thing is of coarse also oké ..
Thanx in advance,
Kenzo
