Tiny Type prob
Blitz3D Forums/Blitz3D Beginners Area/Tiny Type prob
| ||
I wish to let a variable 'equal' a sprite entity that is included in a type. This isn't my exact code, but it's all the relevant stuff: Type My_type Field X Field Y Field Z Field Sprite End Type For f=1 to 10 Type_data.My_Type=New My_type Type_data/X=rnd(10,20) Type_data/Y=rnd(10,20) Type_data/Z=rnd(10,20) Type_data/Mesh=LoadSprite("My_Sprite"+f+".png") Next ;Further on in my program, I need to retrieve the FIRST Sprite handle. (The handle of the sprite in the first occurence. I can guarantee there WILL always be a valid entity) target_sprite=My_Type/Sprite --------- target_sprite=My_Type/Sprite --------- Is that the correct syntax? How can I specify it to be just the first if I have more than one occurence? (Jst when I thought I was getting to grips with types!) |
| ||
Type_data = First My_Type target_sprite=Type_data\spriteAlso, you need to use the backslash character for types: My_data\x=456 |
| ||
Ah- thanks! Also, I am concerned whether the program will still remember that I used the syntax of "Type_data" earlier. Since this was only when creating the types. I will give it a try! |
| ||
If you want the first type, do this:FirstMy_type.My_type=First My_type |
| ||
Excellent! Works a treat, Thanks :) |
| ||
Check if no types exists:If First My_type=null Then Text 10,10,"NO TYPES Available" Insert one at top/bottom: ;at top Insert MyType.My_type before First My_type ;at bottom Insert MyType.My_type After Last My_type |
| ||
Hmm new problem. The following code stops at where I have inserted the [*] with the error "Expected End Of Line" can anyone help? I have 3 varieties of Types. Any of which may be selected by 'targetentity'. What I need to do is allow targetentity to scroll through them, and if it reaches the FIRST one way or the LAST the other way, it will change to a different Type. .Change_target_back PlaySound radar_change If targetentity=First setup_star[*]\sprite Then targetentity=Last setup_object\mesh :Exit: Return If targetentity=First setup_planet\mesh Then targetentity=Last setup_star\sprite :Exit: Return If targetentity=First setup_object\mesh Then targetentity=Last setup_planet\mesh :Exit: Return For check_targets.setup_star = Each setup_star If targetentity=check_targets/sprite Then targetentity=Before check_targets/sprite Next For check_targetp.setup_planet = Each setup_planet If targetentity=check_targetp/mesh Then targetentity=Before check_target/mesh Next For check_targeto.setup_object = Each setup_object If targetentity=check_targeto/mesh Then targetentity=Before check_target/mesh Next Return .Change_target_forward PlaySound radar_change If targetentity=Last setup_star\sprite Then targetentity=First setup_planet\mesh :Exit: Return If targetentity=Last setup_planet\mesh Then targetentity=First setup_object\mesh : Exit:Return If targetentity=Last setup_object\mesh Then targetentity=First setup_star\sprite :Exit: Return For check_targets.setup_star = Each setup_star If targetentity=check_targets\sprite Then targetentity=After check_targets\sprite Next For check_targetp.setup_planet = Each setup_planet If targetentity=check_targetp\mesh Then targetentity=After check_target\mesh Next For check_targeto.setup_object = Each setup_object If targetentity=check_targeto\mesh Then targetentity=After check_target\mesh Next Return ----------------------------- Due to cross-posting, the IS NULL idea might actually sort this new prob out! thanks! |
| ||
Sussed it!!! I'ts good practice for types! here's what I ended up with: .Change_target_back PlaySound radar_change radar_sorter_1.sector_star=First sector_star radar_sorter_2.sector_planet=First sector_planet radar_sorter_3.sector_object=First sector_object radar_sorter_4.sector_star=Last sector_star radar_sorter_5.sector_planet=Last sector_planet radar_sorter_6.sector_object=Last sector_object If targetentity=radar_sorter_1\sprite targetentity=radar_sorter_6\mesh Return EndIf If targetentity=radar_sorter_2\mesh targetentity=radar_sorter_4\sprite Return EndIf If targetentity=radar_sorter_3\mesh targetentity=radar_sorter_5\mesh Return EndIf For check_targets.sector_star = Each sector_star If targetentity=check_targets\sprite check_targets=Before check_targets targetentity=check_targets\sprite Exit EndIf Next For check_targetp.sector_planet = Each sector_planet If targetentity=check_targetp\mesh check_targetp=Before check_targetp targetentity=check_targetp\mesh Exit EndIf Next For check_targeto.sector_object = Each sector_object If targetentity=check_targeto\mesh check_targeto=Before check_targeto targetentity=check_targeto\mesh Exit EndIf Next Return .Change_target_forward PlaySound radar_change radar_sorter_1.sector_star=First sector_star radar_sorter_2.sector_planet=First sector_planet radar_sorter_3.sector_object=First sector_object radar_sorter_4.sector_star=Last sector_star radar_sorter_5.sector_planet=Last sector_planet radar_sorter_6.sector_object=Last sector_object If targetentity=radar_sorter_4\sprite targetentity=radar_sorter_2\mesh Return EndIf If targetentity=radar_sorter_5\mesh targetentity=radar_sorter_3\mesh Return EndIf If targetentity=radar_sorter_6\mesh targetentity=radar_sorter_1\sprite Return EndIf For check_targets.sector_star = Each sector_star If targetentity=check_targets\sprite check_targets=After check_targets targetentity=check_targets\sprite Exit EndIf Next For check_targetp.sector_planet = Each sector_planet If targetentity=check_targetp\mesh check_targetp=After check_targetp targetentity=check_targetp\mesh Exit EndIf Next For check_targeto.sector_object = Each sector_object If targetentity=check_targeto\mesh check_targeto=After check_targeto targetentity=check_targeto\mesh Exit EndIf Next Return |