|
Element library contains methods that can be used to manipulate elements in 3DMLW document. Methods - int attributeInt( name : string )
An integer representation of value stored in attribute. <document id='doc1' version='1.0' stylesheet='{#default}' v='15'> <script type='text/x-lua'> elem=Reference.get("#doc1"); -- Gets element with id doc1 print(elem:attributeInt("v")); -- Prints out 15 </script> </document> - float attributeFloat( name : string )
A floating point representation of value stored in attribute. <document id='doc1' version='1.0' stylesheet='{#default}' v='15.5'> <script type='text/x-lua'> elem=Reference.get("#doc1"); -- Gets element with id doc1 print(elem:attributeFloat("v")); -- Prints out 15.5 </script> </document> - string attributeString( name : string )
A string representation of value stored in attribute. <document id='doc1' version='1.0' stylesheet='{#default}'> <script type='text/x-lua'> elem=Reference.get("#doc1"); -- Gets element with id doc1 print(elem:attributeString("id")); -- Prints out doc1 </script> </document> - bool attributeBool( name : string )
A boolean representation of value stored in attribute. <document id='doc1' version='1.0' stylesheet='{#default}' v='false'> <script type='text/x-lua'> elem=Reference.get("#doc1"); -- Gets element with id doc1 print(elem:attributeBool("v")); -- Prints out false </script> </document> - putAttribute( name : string , value : any )
<document id='doc1' version='1.0' stylesheet='{#default}' v='false'> <script type='text/x-lua'> elem=Reference.get("#doc1"); -- Gets element with id doc1 elem:putAttribute("v", true); -- Set doc1 attribute v to true print(elem:attributeBool("v")); -- Prints out true </script> </document> - putReference( name : string , value : reference )
<document id='doc1' version='1.0' stylesheet='{#default}' v='false'> <script type='text/x-lua'> elem=Reference.get("#doc1"); -- Gets element with id doc1 elem:putReference("v", "#mesh01:x"); -- Set doc1 attribute v to point to #mesh01:x print(elem:attributeFloat("v")); -- Prints out mesh01 coordinate x </script> </document> - addChild( type : string )
<document id='doc1' version='1.0' stylesheet='{#default}' v='false'> <script type='text/x-lua'> elem=Reference.get("#doc1"); -- Gets element with id doc1 child=elem:addChild("content2d"); -- Adds content2d element to parent </script> </document> - removeChild( type : Element )
<document id='doc1' version='1.0' stylesheet='{#default}' v='false'> <script type='text/x-lua'> elem=Reference.get("#doc1"); -- Gets element with id doc1 child=elem:addChild("content2d"); -- Adds content2d element to parent elem:removeChild(child); -- Removes content2d element from parent </script> </document> - int childCount()
Returns the count of element's child elements.
- Element get( index : int )
Returns the child element with given index.
|