Files
CHOMPStation2/code/modules/scripting/Implementations/_Logic.dm
vageyenaman@gmail.com b5f8eaf8a9 More work done on Telecomms:
▫ Signals can now be rejected by Subspace broadcasters through a specific data[] parameter.
▫ Improved the log browser.
▫ Log browsers and telecommunication monitors no longer require access to use. You do need access to delete logs, however.
▫ Intercoms need power to work. They don't drain power, they just need a constant flow of equipment power. As such, that offline intercom sprite's now finally being put to use.


Scripting language:

▫ Sorry about all the files; they're all necessary! It's important to notice that the basic structure of the scripting language code is not mine; I cannibalized the base structure from some obscure BYOND project. It's pretty well documented, and I'd say easier to browse through than atmos. Here's the basic deal:

A compiler datum manages the relationships between the three main subsystems of a scripting language: the Scanner, the Parser, and the Interpreter. The Scanner splits raw text into token datums that the Parser can read. The Parser transforms the otherwise random bits and strings into ordered AST Trees and nodes for the Interpreter to read. The interpreter actually executes the code and handles scope/functions/code blocks.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3193 316c924e-a436-60f5-8080-3fe189b3f50e
2012-02-25 22:51:31 +00:00

115 lines
2.5 KiB
Plaintext

// 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
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))
var/list/listhaystack = haystack
return listhaystack.Find(needle, start, end)
else
if(istext(haystack))
return findtext(haystack, needle, start, end)
// Clone of length()
/proc/smartlength(var/container)
if(container)
if(istype(container, /list) || istext(container))
return length(container)