milk_ [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=79548 Code execution order <p>Hello everyone!<br /> I bought PICO-8 some time ago but only recently decided to actually learn it.</p> <p>One (of many) thing that got me a little confused is the order and speed execution.</p> <p>The code below shows the text on screen:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>function _update() cls() print(&quot;hello&quot;,64,64,11) end</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>However, if I change the code as bellow, the text does not show anymore:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>function _update() print(&quot;hello&quot;,64,64,11) cls() end</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>What I got from this is: on the second code, since the last command being processed is the cls(), then the screen ends up 'blank'.</p> <p>But what makes me confused is that I thought since pico-8 runs on an endless loop the cls() and print() will always be called one after another, so I don't understand why in one order the print() is the 'final' and in the other, the cls() is.</p> <p>Can anyone help me understand this better?<br /> I couldn't find anything that explained this behavior (maube because it's too basic, but since I'm new to this it doesn't make sense to me).</p> https://www.lexaloffle.com/bbs/?tid=140998 https://www.lexaloffle.com/bbs/?tid=140998 Fri, 22 Mar 2024 18:16:04 UTC