bugfixes & shorthand methods on turtles

This commit is contained in:
Scott Richmond 2025-07-08 16:05:54 -04:00
parent edd21bec5e
commit b7e4aebb95

View File

@ -1299,7 +1299,11 @@ let pd! = pendown!
fn pencolor! { fn pencolor! {
"Changes the turtle's pen color. Takes a single grayscale value, an rgb tuple, or an rgba tuple. Alias: `pencolour!`, `pc!`" "Changes the turtle's pen color. Takes a single grayscale value, an rgb tuple, or an rgba tuple. Alias: `pencolour!`, `pc!`"
(color as :keyword) -> add_command! (:turtle_0, (:pencolor, color)) (color as :keyword) -> {
if color (colors)
then add_command! (:turtle_0, (:pencolor, color))
else panic! ("There is no color named {color} in the colors dict.")
}
(gray as :number) -> add_command! (:turtle_0, (:pencolor, (gray, gray, gray, 255))) (gray as :number) -> add_command! (:turtle_0, (:pencolor, (gray, gray, gray, 255)))
((r as :number, g as :number, b as :number)) -> add_command! (:turtle_0, (:pencolor, (r, g, b, 255))) ((r as :number, g as :number, b as :number)) -> add_command! (:turtle_0, (:pencolor, (r, g, b, 255)))
((r as :number, g as :number, b as :number, a as :number)) -> add_command! (:turtle_0, (:pencolor, (r, g, b, a))) ((r as :number, g as :number, b as :number, a as :number)) -> add_command! (:turtle_0, (:pencolor, (r, g, b, a)))
@ -1368,16 +1372,29 @@ fn loadstate! {
fn turtle_listener () -> { fn turtle_listener () -> {
receive { receive {
(:forward!, steps as :number) -> add_command! (self (), (:forward, steps)) (:forward!, steps as :number) -> add_command! (self (), (:forward, steps))
(:fd!, steps as :number) -> add_command! (self (), (:forward, steps))
(:back!, steps as :number) -> add_command! (self (), (:back, steps)) (:back!, steps as :number) -> add_command! (self (), (:back, steps))
(:bk!, steps as :number) -> add_command! (self (), (:back, steps))
(:left!, turns as :number) -> add_command! (self (), (:left, turns)) (:left!, turns as :number) -> add_command! (self (), (:left, turns))
(:lt!, turns as :number) -> add_command! (self (), (:left, turns))
(:right!, turns as :number) -> add_command! (self (), (:right, turns)) (:right!, turns as :number) -> add_command! (self (), (:right, turns))
(:rt!, turns as :number) -> add_command! (self (), (:right, turns))
(:penup!) -> add_command! (self (), (:penup)) (:penup!) -> add_command! (self (), (:penup))
(:pu!) -> add_command! (self (), (:penup))
(:pendown!) -> add_command! (self (), (:pendown)) (:pendown!) -> add_command! (self (), (:pendown))
(:pencolor!, color as :keyword) -> add_command! (self (), (:pencolor, color)) (:pd!) -> add_command! (self (), (:pendown))
(:pencolor!, color as :keyword) -> if color (colors)
then add_command! (self (), (:pencolor, color))
else panic! ("There is no color {color} in the colors dict.")
(:pencolor!, gray as :number) -> add_command! (self (), (:pencolor, (gray, gray, gray, 255))) (:pencolor!, gray as :number) -> add_command! (self (), (:pencolor, (gray, gray, gray, 255)))
(:pencolor!, (r as :number, g as :number, b as :number)) -> add_command! (self (), (:pencolor, (r, g, b, 255))) (:pencolor!, (r as :number, g as :number, b as :number)) -> add_command! (self (), (:pencolor, (r, g, b, 255)))
(:pencolor!, (r as :number, g as :number, b as :number, a as :number)) -> add_command! (self (), (:pencolor, (r, g, b, a))) (:pencolor!, (r as :number, g as :number, b as :number, a as :number)) -> add_command! (self (), (:pencolor, (r, g, b, a)))
(:pc!, color as :keyword) -> add_command! (self (), (:pencolor, color))
(:pc!, gray as :number) -> add_command! (self (), (:pencolor, (gray, gray, gray, 255)))
(:pc!, (r as :number, g as :number, b as :number)) -> add_command! (self (), (:pencolor, (r, g, b, 255)))
(:pc!, (r as :number, g as :number, b as :number, a as :number)) -> add_command! (self (), (:pencolor, (r, g, b, a)))
(:penwidth!, width as :number) -> add_command! (self (), (:penwidth, width)) (:penwidth!, width as :number) -> add_command! (self (), (:penwidth, width))
(:pw!, width as :number) -> add_command! (self (), (:penwidth, width))
(:home!) -> add_command! (self (), (:home)) (:home!) -> add_command! (self (), (:home))
(:goto!, x as :number, y as :number) -> add_command! (self (), (:goto, (x, y))) (:goto!, x as :number, y as :number) -> add_command! (self (), (:goto, (x, y)))
(:goto!, (x as :number, y as :number)) -> add_command! (self (), (:goto, (x, y))) (:goto!, (x as :number, y as :number)) -> add_command! (self (), (:goto, (x, y)))