Nested Types
Blitz3D Forums/Blitz3D Beginners Area/Nested Types
| ||
As I keep running into errors, would I be correct to assume nested TYPEs (even of different TYPEs) are a no-no? eg. for fish.seacreature = each seacreature for seasweed.plant = each plant next next Dumping the nested TYPE out into a function seems to solve this but I'd just like to confirm that its a language limitation, not my bad programming, before I go too much further. :) I didn't find anything in the manual about it. +BlackD |
| ||
As far as I know, nested types are perfectly OK. Your code example shows a nested FOR loop, not a nested type. A nested type would be like this: Type seacreature Field creaturetype Field name Field weight Field length End Type Type seaentity Field entitytype.seacreature Field x Field Y End Type In your FOR loops, make sure that you are not doing something like deleting a type before your loop(s) has finished (just mark them for deletion), or else you may get errors. |
| ||
There is nothing wrong with the above code by itself. You can easily nest for each loops within each other. If you were to provide some more details as to what you are hoping to achieve with this then I could be a little more helpful. |
| ||
hmm.. yeah, did a little further digging and came up with whats erroring.. the code is about 10 pages long, so I'll use another example. I'm beginning to think its to do with how i'm using buffers rather than types..for fish.seacreature = each seacreature fishie=createimage(100,100) setbuffer imagebuffer(fishie) ... draw the fish ... for parts.animals = each animals a$=parts\creature$ b$=parts\imagepath$ if a$ = "fish" then c=LoadImage(b$) Drawimage c,0,0 End If Next SetBuffer BackBuffer() Drawimage fishie,100,100 Flip Freeimage fishie Next Now using that "example", as soon as it finds the first "part" which goes on a fish, and draws it, then no more fishies (in the ..draw fish here.. part) will be drawn.. let alone fish parts. ;) Is it impossible to LOADIMAGE while using an ImageBuffer? I could understand that, but then how come extracting the inside FOR loop out into a function, solves the problem? The ImageBuffer() is still active. +BlackD |
| ||
Pure shot in the dark... what happens if you take the Freeimage command away? You might want to add a a few debug commands in as well so you can trace the loop through your for/each statements. |