Mod Tool: Difference between revisions

1,218 bytes added ,  7 September 2012
m
scripting: UserDataBlob (creating own properties) (part 1)
mNo edit summary
m (scripting: UserDataBlob (creating own properties) (part 1))
Line 582: Line 582:
  ' '''[21] building a form (PPG)'''
  ' '''[21] building a form (PPG)'''


{| border=0 cellpadding=0 align=right
| [http://i305.photobucket.com/albums/nn207/unknownfuture/Oni_Galore_Images/3D_modding/UserDataBlob.png http://i305.photobucket.com/albums/nn207/unknownfuture/Oni_Galore_Images/3D_modding/UserDataBlob_tn.png]
|}


  ' '''[22] UserDataBlob'''
  ' '''[22] UserDataBlob'''
   
   
  ' you can attach data to objects, e.g. properties of Trigger Volumes
  ' you can attach data to objects, e.g. new properties for the scene root or Oni Trigger Volumes
  ' the so-called "UserDataBlob" can't be saved in *.dae, so save the whole scene to keep your progress
  ' the so-called "UserDataBlob" can't be saved in *.dae, so save the whole scene to keep your progress
  ' [...]
  '
' check if my property exist
found_my_prop = 0
set oProps = ActiveProject.ActiveScene.Root
logmessage "root name: " & ActiveProject.ActiveScene.Root
for each prop in oProps.Properties
' remove apostroph in line beneth to log all root properties
  'LogMessage prop.Name
if instr(1, prop.Name, "my_prop") = 1 then
found_my_prop = 1
end if
next
' prop doesn't exist, create it
if found_my_prop = 0 then
' create property (must also have content, in this case "yes")
oProps.AddProperty( "UserDataBlob", , "my_prop" ).value = "yes"
logmessage "created my new prop"
end if
' prop exists, change/read its value
if found_my_prop = 1 then
' change property
oProps.Properties( "my_prop" ).value = "no"
' read property
logmessage oProps.Properties( "my_prop" ).value
' if you want to read a property from another script be sure that it was already created
' reuse code under "check if my property exist"
end if




8,452

edits