Discuss Scratch

lienzli
Scratcher
39 posts

Add var to list glitch

My browser / operating system: ChromeOS 13904.55.0, Chrome 91.0.4472.102, No Flash version detected

idk how to upload image so here's yt vid https://youtu.be/t0KjCowalCU

when green flag clicked
forever
if <(scratching) = [0]> then
set [(scratching)] to [1]
end
end
dhuls
Scratcher
1000+ posts

Add var to list glitch

I think this may be intentional. Python does the same thing (unless they are both broken).
lienzli
Scratcher
39 posts

Add var to list glitch

Is there a way to fix it?

when green flag clicked
forever
if <(scratching) = [0]> then
set [(scratching)] to [1]
end
end
Thingied
Scratcher
1000+ posts

Add var to list glitch

Blame floating point math(pretty sure that's the cause). Here's the fix though:
when gf clicked
delete all of [e v] :: list
set [e v] to (0.1)
repeat (...)
add (e :: variables) to [e v]
replace item (length of [e v]) of [e v]with (([floor v] of ((e::variables)*(10)))/(10)
change [e v] by (0.1)

Last edited by Thingied (June 26, 2021 03:59:31)

lienzli
Scratcher
39 posts

Add var to list glitch

ty

when green flag clicked
forever
if <(scratching) = [0]> then
set [(scratching)] to [1]
end
end
lienzli
Scratcher
39 posts

Add var to list glitch

Doesnt work, it goes 0.1, 0, 0, 0, 0, 0,

when green flag clicked
forever
if <(scratching) = [0]> then
set [(scratching)] to [1]
end
end
Thingied
Scratcher
1000+ posts

Add var to list glitch

lienzli wrote:

Doesnt work, it goes 0.1, 0, 0, 0, 0, 0,
Uhhhh can you share the project then? It works perfectly fine for me.
EDIT: Make sure you put the variable in the replace blocks instead of the list block.

Last edited by Thingied (June 26, 2021 23:30:12)

Chiroyce
Scratcher
1000+ posts

Add var to list glitch

Scratch uses floating point math, so if there is a glitch with decimal numbers, you can't do anything about it, but to use more complex math as @Thingied said.







April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence

Powered by DjangoBB