swapd0 Posted February 7, 2021 Share Posted February 7, 2021 Quote enemy_ia for i = 0 to 7 a = enemy_state on a gosub _egg, _hatch, _born next. return _egg return _hatch return _born return How can I make this work?, I have also tried with on ... goto and then jump before the next but it doesn't work. Thanks Quote Link to comment Share on other sites More sharing options...
swapd0 Posted February 7, 2021 Author Share Posted February 7, 2021 This way I get no errors Quote enemy_ia for i = 0 to 7 a = rand;enemy_state if a = 0 then gosub _egg : goto _loop_ia if a = 1 then gosub _hatch : goto _loop_ia if a = 3 then gosub _born : goto _loop_ia ; on a goto _egg, _hatch, _born _loop_ia next return _egg return _hatch return _born return Quote Link to comment Share on other sites More sharing options...
CloakeD Posted February 7, 2021 Share Posted February 7, 2021 In your first example is the (.) after next in your source code? Quote Link to comment Share on other sites More sharing options...
swapd0 Posted February 7, 2021 Author Share Posted February 7, 2021 16 minutes ago, CloakeD said: In your first example is the (.) after next in your source code? No, it was a typo Also, why this doesn't work? if yenemy[i] = 16*8 then enemy_state[i] = STATE_MOVE but this works a = yenemy[i] if a = 16*8 then enemy_state[i] = STATE_MOVE Quote Link to comment Share on other sites More sharing options...
+Muddyfunster Posted February 7, 2021 Share Posted February 7, 2021 2 hours ago, swapd0 said: How can I make this work?, I have also tried with on ... goto and then jump before the next but it doesn't work. Thanks you have a comma after each goto destination Try something like : on a gosub _egg _hatch _born Quote Link to comment Share on other sites More sharing options...
+Muddyfunster Posted February 7, 2021 Share Posted February 7, 2021 49 minutes ago, swapd0 said: No, it was a typo Also, why this doesn't work? if yenemy[i] = 16*8 then enemy_state[i] = STATE_MOVE but this works a = yenemy[i] if a = 16*8 then enemy_state[i] = STATE_MOVE I'm not 100% sure here, but I think 7800Basic can't test an array value directly against an array value so you need to load your first value into a temp variable, which you have done in the second example. (more or less - There might be a more technical explanation but that's how I understand it). Quote Link to comment Share on other sites More sharing options...
swapd0 Posted February 7, 2021 Author Share Posted February 7, 2021 7 minutes ago, Muddyfunster said: you have a comma after each goto destination Try something like : on a gosub _egg _hatch _born It works, lol I looked at the docs many times but I didn't realized about the comma XD 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.