// Script -> BYOND code procs // --- List operations (lists known as vectors in n_script) --- // Clone of list() /proc/n_list() var/list/returnlist = list() for(var/e in args) returnlist.Add(e) return returnlist // Clone of pick() /proc/n_pick() var/list/finalpick = list() for(var/e in args) if(isobject(e)) if(istype(e, /list)) var/list/sublist = e for(var/sube in sublist) finalpick.Add(sube) continue finalpick.Add(e) return pick(finalpick) // Clone of list[] /proc/n_listpos(var/list/L, var/pos, var/value) if(!istype(L, /list)) return if(isnum(pos)) if(!value) if(L.len >= pos) return L[pos] else if(L.len >= pos) L[pos] = value else if(istext(pos)) if(!value) return L[pos] else L[pos] = value // Clone of list.Copy() /proc/n_listcopy(var/list/L, var/start, var/end) if(!istype(L, /list)) return return L.Copy(start, end) // Clone of list.Add() /proc/n_listadd() var/list/chosenlist var/i = 1 for(var/e in args) if(i == 1) if(isobject(e)) if(istype(e, /list)) chosenlist = e else if(chosenlist) chosenlist.Add(e) // Clone of list.Remove() /proc/n_listremove() var/list/chosenlist var/i = 1 for(var/e in args) if(i == 1) if(isobject(e)) if(istype(e, /list)) chosenlist = e else if(chosenlist) chosenlist.Remove(e) // Clone of list.Cut() /proc/n_listcut(var/list/L, var/start, var/end) if(!istype(L, /list)) return return L.Cut(start, end) // Clone of list.Swap() /proc/n_listswap(var/list/L, var/firstindex, var/secondindex) if(!istype(L, /list)) return if(L.len >= secondindex && L.len >= firstindex) return L.Swap(firstindex, secondindex) // Clone of list.Insert() /proc/n_listinsert(var/list/L, var/index, var/element) if(!istype(L, /list)) return return L.Insert(index, element) // --- Miscellaneous functions --- // Clone of sleep() /proc/delay(var/time) sleep(time) // Clone of prob() /proc/prob_chance(var/chance) return prob(chance) // Merge of list.Find() and findtext() /proc/smartfind(var/haystack, var/needle, var/start = 1, var/end = 0) if(haystack && needle) if(isobject(haystack)) if(istype(haystack, /list)) if(length(haystack) >= end && start > 0) var/list/listhaystack = haystack return listhaystack.Find(needle, start, end) else if(istext(haystack)) if(length(haystack) >= end && start > 0) return findtext(haystack, needle, start, end) // Clone of copytext() /proc/docopytext(var/string, var/start = 1, var/end = 0) if(istext(string) && isnum(start) && isnum(end)) if(length(string) >= end && start > 0) return copytext(string, start, end) // Clone of length() /proc/smartlength(var/container) if(container) if(istype(container, /list) || istext(container)) return length(container)