ludic/packages/ludic.wildlife/guest.ludic

24 lines
919 B
Text

# guest.ludic - a machine that draws another's animals puts its own away whole, and they come back
# as they were when it stops; in between the list is the copies it is handed (wildlife_make)
export function wildlife_put_away(wildlife_st: mut WildlifeState) -> void {
if wildlife_st.wl_own != null { return }
wildlife_st.wl_own = wildlife_st.wl
wl__empty(wildlife_st.wl_host)
wildlife_st.wl = wildlife_st.wl_host
}
export function wildlife_bring_back(wildlife_st: mut WildlifeState) -> void {
if wildlife_st.wl_own == null { return }
wildlife_st.wl_host = wildlife_st.wl
wildlife_st.wl = wildlife_st.wl_own
wildlife_st.wl_own = null
}
export function wildlife_away(wildlife_st: WildlifeState) -> bool { return wildlife_st.wl_own != null }
# every animal gone from a table, keeping its rows' room for the next party
function wl__empty(w: WildTable) -> void {
tb_clear(w.tab)
imap_clear(w.nids)
}