Modifying a type from a function
Blitz3D Forums/Blitz3D Programming/Modifying a type from a function
| ||
O.K. some questions please 1.How do I create a function to modify values in a type without calling the type in the function? e,g, for b.blue_car=each blue_car damage_car(blue_car,20) next function damage_car b.hull=b.hull-20 end function 2.Can one function be used to modify 2 different types? e.g. for b.blue_car =each blue_car damage_car(blue_car,20) next for b.blue_van=each blue_van damage_car(blue_van,20) next or do I have to create a damage_van function?? |
| ||
1.for b.blue_car=each blue_car damage_car(blue_car,20) next function damage_car(b.blue_car,damage) b\hull=b\hull-damage end function 2. No, not directly, you could use the object/handle commands, but it will not be elegant. Instead why not create one type called vehicle, and then have a field called class, that defines whether its a car or, like in your question, a van, or whatever? Hope this helps. |
| ||
o.k. thats good thanks P.S. can your GUI be used for blitz3D |
| ||
Yes, only for Blitz3D, as it uses quads to display it. |
| ||
I was about to ask the same question, but I found this thread first. I have another question, though: What if I have for b.blue_car=each blue_car... and for c.blue_car=each blue_car... How can I access b\hull, c\hull etc. from the same function? Thanks a lot Paolo |
| ||
Oops, the above piece of code was wrong, here is the corrected:for b.blue_car=each blue_car damage_car(b,20) next function damage_car(b.blue_car,damage) b\hull=b\hull-damage end function @mr.ninja You can use the same function like this: for b.blue_car=each blue_car damage_car(b,20) next for c.blue_car=each blue_car damage_car(c,20) next |
| ||
Thanks a lot! Paolo |