elayekay [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=10874 Syntax + Runtime errors in Zine #1 particle code <p>Hi. Going through the Smoke Particle section of zine #1 and found an error I couldn't solve. If you copy paste the following code..</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 make_smoke(x,y,init_size,col) local s = {} s.x=x s.y=y s.col=col s.width = init_size s.width_final = init_size + rnd(3)+1 s.t=0 s.max_t = 30+rnd(10) s.dx = (rnd(.8).4) s.dy = rnd(.05) s.ddy = .02 add(smoke,s) return s end function _init() smoke = {} cursorx = 50 cursory = 50 color = 7 end function move_smoke(sp) if (sp.t &gt; sp.max_t) then del(smoke,sp) end if (sp.t &gt; sp.max_t15) then sp.width +=1 sp.width = min(sp.width,sp.width_final) end sp.x = sp.x + sp.dx sp.y = sp.y + sp.dy sp.dy= sp.dy+ sp.ddy sp.t = sp.t + 1 end function _update () foreach(smoke, move_smoke) if btn(0,0) then cursorx=1 end if btn(1,0) then cursorx+=1 end if btn(2,0) then cursory-=1 end if btn(3,0) then cursory+=1 end if btn(4,0) then color = flr(rand(16)) end make_smoke(cursorx,cursory,rnd(4),color) end function draw_smoke(s) circfill(s.x, s.y,s.width, s.col) end function _draw() cls() foreach(smoke, draw_smoke) 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>.. you get 'syntax error line 10. ')' expected near '.4'. I changed the line to </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> s.dx = (rnd(.8))*.4 </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>which seems to have fixed the problem, but then you get 'line 27: attempt to compare nil with number. in _f line 27. in _update line 37'</p> <p>Anyone know a fix?</p> <p>The cartridge that the tutorial points to at the end seems broken as well (<a href="https://www.lexaloffle.com/bbs/?tid=1920">https://www.lexaloffle.com/bbs/?tid=1920</a>)</p> <p>Edit: if you replace 'sp.max_t15' with a number it works ok.</p> https://www.lexaloffle.com/bbs/?tid=3260 https://www.lexaloffle.com/bbs/?tid=3260 Wed, 27 Apr 2016 05:55:37 UTC Syntax errors in zine 3 collision code <p>Hi. I'm trying to learn about collisions using the DOM8VERSE section of zine 3 but I'm getting weird error messages whenever I try and use a foreach.</p> <p>For example, when I try this:</p> <p>function _update()<br /> if btnp(5, 0) then<br /> add(objects, bulletconstruct(player1.position.x,player1.position.y))<br /> end</p> <pre><code>foreach(objects, function(obj) obj.update(obj) end</code></pre> <p>end</p> <p>.. I get ')' expected ( to close '(' at line 0.0003891 near 'end'</p> <p>I've tried adding and taking away brackets, as well as 'end' statements but I can't get it to work. Thought it was strange as I'm copy pasting zine 3 code.</p> <p>Anyone know the solution?</p> https://www.lexaloffle.com/bbs/?tid=3252 https://www.lexaloffle.com/bbs/?tid=3252 Sat, 23 Apr 2016 17:12:22 UTC