5 Dec 2016 |
| level27geek | 01:03:41 |
level27geek | thanks dddaaannn, I really need to learn about those Boolean operators, because this is over my head... | 01:03:41 |
| level27geek | 01:03:58 |
level27geek | let me show you what I have: | 01:03:58 |
| level27geek | 01:04:10 |
level27geek | function flash2colors(one,two)
local i = rnd(1)
if i < 0.5 then
return one
else
return two
end
end | 01:04:10 |
| level27geek | 01:04:45 |
level27geek | then I use this to flash different colors by calling this function on update. | 01:04:45 |
| level27geek | 01:05:17 |
level27geek | ...and now I figured it out, I can solve it by adding a frame_num%2 check 😛 | 01:05:17 |
dddaaannn | Yup. The one-liner version of your function would be: rnd(1) < 0.5 and one or two | 01:57:57 |
| dddaaannn | 01:57:57 |
| level27geek | 02:22:03 |
level27geek | so, I could technically do: frame_num%2 and one or two | 02:22:03 |
| level27geek | 02:23:18 |
level27geek | how would I do so the color flashes slower, but still 50% one color 50% the other? When I do something like %3 one color is dominant | 02:23:18 |
| level27geek | 02:29:16 |
level27geek | hmmm... that gives me "unexpected symbol near <" when I try rnd(1) < 0.5 and one or two | 02:29:16 |
| dddaaannn | 06:49:01 |
dddaaannn | You might need parentheses around some things | 06:49:01 |
| dddaaannn | 06:49:19 |
dddaaannn | I don’t recall Lua’s order of precedence but you can look it up, or just use extra parens 🙂 | 06:49:19 |
dddaaannn | As for slowing down the flashes, you can divide the frame number by the frame duration, round down, then do the %2==0 thing | 06:50:18 |
| dddaaannn | 06:50:18 |
| dddaaannn | 06:51:42 |
dddaaannn | or something like that. (Doesn’t quite work as described.) | 06:51:42 |
| dddaaannn | 06:52:53 |
dddaaannn | sorry, best not to overcomplicate it: frame_num % 6 < 3 for swapping every three frames. | 06:52:53 |
| dddaaannn | 06:54:24 |
| level27geek | 15:09:56 |