Convert Object to User Type Value
BlitzMax Forums/BlitzMax Programming/Convert Object to User Type Value
| ||
I need to use an Object Value to Create a Type Value. How do I create a Local Value for a User Type from an Object Value? Local TypID:TTypeId For Local ObjTyp:Object = EachIn ActObj If TypId.ForObject( ObjTyp ).Name() = "Ladder" 'I am Having trouble creating a Type Value from an Object. Local Lad:Ladder = ObjTyp 'Active Ladder Local UsrRot:Vector3df = Nde.GetRotation() 'User Node Rotation 'Physics '*End of Ladder '*Next Ladder 'Climb Ladder '*The Compiler Returns and Error. Lad.Nde.GetPosition() End If Next Thank you. |
| ||
Why are you using Reflection for this? Why not just do For Local Lad:Ladded = EachIn ActObj? |
| ||
To sort out different User Types. Not all Values in the "ActObj" Array are the same. |
| ||
Local Lad:Ladder = Ladder(ObjTyp) |
| ||
To sort out different User Types. Not all Values in the "ActObj" Array are the same. For Local Lad:Ladder = EachIn ActObj will give you only the ladders. Still want to do it the hard way?Strict Type A Field a = 5 End Type Type B Field a = 10 End Type Local actobj:Object[32] For Local i:Int = 0 To 31 Step 2 actobj[i] = New A actobj[i+1] = New B Next For Local woo:A = EachIn actobj Print woo.a Next For Local woo:B = EachIn actobj Print woo.a Next |
| ||
Very handy! |