mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 18:32:03 +00:00
More work on NTSL and world/Topic()
Includes a plethora of new NTSL functions, courtesy of Donkieyo (thread: http://nanotrasen.com/phpBB3/viewtopic.php?f=16&t=8153) Bugfix for a weird runtime generated when an AI tries to interact with telecomms machinery directly. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3347 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
@@ -106,7 +106,9 @@
|
|||||||
if(stat & (BROKEN|NOPOWER) || !on)
|
if(stat & (BROKEN|NOPOWER) || !on)
|
||||||
return
|
return
|
||||||
|
|
||||||
var/obj/item/device/multitool/P = user.equipped()
|
var/obj/item/device/multitool/P = null
|
||||||
|
if(!issilicon(user))
|
||||||
|
P = user.equipped()
|
||||||
|
|
||||||
user.machine = src
|
user.machine = src
|
||||||
var/dat
|
var/dat
|
||||||
@@ -142,10 +144,12 @@
|
|||||||
|
|
||||||
dat += "<br> <a href='?src=\ref[src];input=freq'>\[Add Filter\]</a>"
|
dat += "<br> <a href='?src=\ref[src];input=freq'>\[Add Filter\]</a>"
|
||||||
dat += "<hr>"
|
dat += "<hr>"
|
||||||
if(P.buffer)
|
|
||||||
dat += "<br><br>MULTITOOL BUFFER: [P.buffer] ([P.buffer.id]) <a href='?src=\ref[src];link=1'>\[Link\]</a> <a href='?src=\ref[src];flush=1'>\[Flush\]"
|
if(P)
|
||||||
else
|
if(P.buffer)
|
||||||
dat += "<br><br>MULTITOOL BUFFER: <a href='?src=\ref[src];buffer=1'>\[Add Machine\]</a>"
|
dat += "<br><br>MULTITOOL BUFFER: [P.buffer] ([P.buffer.id]) <a href='?src=\ref[src];link=1'>\[Link\]</a> <a href='?src=\ref[src];flush=1'>\[Flush\]"
|
||||||
|
else
|
||||||
|
dat += "<br><br>MULTITOOL BUFFER: <a href='?src=\ref[src];buffer=1'>\[Add Machine\]</a>"
|
||||||
|
|
||||||
dat += "</font>"
|
dat += "</font>"
|
||||||
temp = ""
|
temp = ""
|
||||||
@@ -164,7 +168,9 @@
|
|||||||
if(stat & (BROKEN|NOPOWER) || !on)
|
if(stat & (BROKEN|NOPOWER) || !on)
|
||||||
return
|
return
|
||||||
|
|
||||||
var/obj/item/device/multitool/P = usr.equipped()
|
var/obj/item/device/multitool/P = null
|
||||||
|
if(!issilicon(usr))
|
||||||
|
P = usr.equipped()
|
||||||
|
|
||||||
if(href_list["input"])
|
if(href_list["input"])
|
||||||
switch(href_list["input"])
|
switch(href_list["input"])
|
||||||
@@ -220,17 +226,19 @@
|
|||||||
|
|
||||||
if(href_list["link"])
|
if(href_list["link"])
|
||||||
|
|
||||||
if(P.buffer)
|
if(P)
|
||||||
if(!(src in P.buffer.links))
|
|
||||||
P.buffer.links.Add(src)
|
|
||||||
|
|
||||||
if(!(P.buffer in src.links))
|
if(P.buffer)
|
||||||
src.links.Add(P.buffer)
|
if(!(src in P.buffer.links))
|
||||||
|
P.buffer.links.Add(src)
|
||||||
|
|
||||||
temp = "<font color = #666633>-% Successfully linked with \ref[P.buffer] [P.buffer.name] %-</font color>"
|
if(!(P.buffer in src.links))
|
||||||
|
src.links.Add(P.buffer)
|
||||||
|
|
||||||
else
|
temp = "<font color = #666633>-% Successfully linked with \ref[P.buffer] [P.buffer.name] %-</font color>"
|
||||||
temp = "<font color = #666633>-% Unable to acquire buffer %-</font color>"
|
|
||||||
|
else
|
||||||
|
temp = "<font color = #666633>-% Unable to acquire buffer %-</font color>"
|
||||||
|
|
||||||
if(href_list["buffer"])
|
if(href_list["buffer"])
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,21 @@
|
|||||||
s["host"] = host ? host : null
|
s["host"] = host ? host : null
|
||||||
s["players"] = list()
|
s["players"] = list()
|
||||||
var/n = 0
|
var/n = 0
|
||||||
|
var/admins = 0
|
||||||
|
|
||||||
for(var/mob/M in world)
|
for(var/mob/M in world)
|
||||||
|
|
||||||
if(M.client)
|
if(M.client)
|
||||||
|
if(M.client.holder && M.client.authenticated)
|
||||||
|
if(!M.client.stealth)
|
||||||
|
admins++
|
||||||
|
|
||||||
s["player[n]"] = M.client.key
|
s["player[n]"] = M.client.key
|
||||||
n++
|
n++
|
||||||
s["players"] = n
|
s["players"] = n
|
||||||
return list2params(s)
|
|
||||||
|
// 7 + s["players"] + 1 = index of s["revinfo"]
|
||||||
|
s["revision"] = revdata.revision
|
||||||
|
s["admins"] = admins
|
||||||
|
|
||||||
|
return list2params(s)
|
||||||
|
|||||||
@@ -157,6 +157,25 @@
|
|||||||
interpreter.SetProc("prob", /proc/prob_chance)
|
interpreter.SetProc("prob", /proc/prob_chance)
|
||||||
interpreter.SetProc("substr", /proc/docopytext)
|
interpreter.SetProc("substr", /proc/docopytext)
|
||||||
|
|
||||||
|
// Donkie~
|
||||||
|
// Strings
|
||||||
|
interpreter.SetProc("lower", /proc/n_lower)
|
||||||
|
interpreter.SetProc("upper", /proc/n_upper)
|
||||||
|
interpreter.SetProc("explode", /proc/string_explode)
|
||||||
|
interpreter.SetProc("repeat", /proc/n_repeat)
|
||||||
|
interpreter.SetProc("reverse", /proc/n_reverse)
|
||||||
|
interpreter.SetProc("tonum", /proc/n_str2num)
|
||||||
|
|
||||||
|
// Numbers
|
||||||
|
interpreter.SetProc("tostring", /proc/n_num2str)
|
||||||
|
interpreter.SetProc("sqrt", /proc/n_sqrt)
|
||||||
|
interpreter.SetProc("abs", /proc/n_abs)
|
||||||
|
interpreter.SetProc("floor", /proc/n_floor)
|
||||||
|
interpreter.SetProc("ceil", /proc/n_ceil)
|
||||||
|
interpreter.SetProc("round", /proc/n_round)
|
||||||
|
interpreter.SetProc("clamp", /proc/n_clamp)
|
||||||
|
interpreter.SetProc("inrange", /proc/n_inrange)
|
||||||
|
// End of Donkie~
|
||||||
|
|
||||||
|
|
||||||
// Run the compiled code
|
// Run the compiled code
|
||||||
@@ -165,7 +184,7 @@
|
|||||||
// Backwards-apply variables onto signal data
|
// Backwards-apply variables onto signal data
|
||||||
/* sanitize EVERYTHING. fucking players can't be trusted with SHIT */
|
/* sanitize EVERYTHING. fucking players can't be trusted with SHIT */
|
||||||
|
|
||||||
signal.data["message"] = trim(copytext(sanitize(interpreter.GetVar("$content")), 1, MAX_MESSAGE_LEN))
|
signal.data["message"] = interpreter.GetVar("$content")
|
||||||
signal.frequency = interpreter.GetVar("$freq")
|
signal.frequency = interpreter.GetVar("$freq")
|
||||||
|
|
||||||
var/setname = ""
|
var/setname = ""
|
||||||
@@ -173,7 +192,7 @@
|
|||||||
if(interpreter.GetVar("$source") in S.stored_names)
|
if(interpreter.GetVar("$source") in S.stored_names)
|
||||||
setname = interpreter.GetVar("$source")
|
setname = interpreter.GetVar("$source")
|
||||||
else
|
else
|
||||||
setname = "<i>[trim(copytext(sanitize(interpreter.GetVar("$source")), 1, MAX_MESSAGE_LEN))]</i>"
|
setname = "<i>[interpreter.GetVar("$source")]</i>"
|
||||||
|
|
||||||
if(signal.data["name"] != setname)
|
if(signal.data["name"] != setname)
|
||||||
signal.data["realname"] = setname
|
signal.data["realname"] = setname
|
||||||
|
|||||||
@@ -123,3 +123,114 @@
|
|||||||
if(container)
|
if(container)
|
||||||
if(istype(container, /list) || istext(container))
|
if(istype(container, /list) || istext(container))
|
||||||
return length(container)
|
return length(container)
|
||||||
|
|
||||||
|
// BY DONKIE~
|
||||||
|
// String stuff
|
||||||
|
/proc/n_lower(var/string)
|
||||||
|
if(istext(string))
|
||||||
|
return lowertext(string)
|
||||||
|
|
||||||
|
/proc/n_upper(var/string)
|
||||||
|
if(istext(string))
|
||||||
|
return uppertext(string)
|
||||||
|
|
||||||
|
|
||||||
|
//Makes a list where all indicies in a string is a seperate index in the list
|
||||||
|
// JUST A HELPER DON'T ADD TO NTSCRIPT
|
||||||
|
proc/string_tolist(var/string)
|
||||||
|
var/list/L = new/list()
|
||||||
|
|
||||||
|
var/i
|
||||||
|
for(i=1, i<=lentext(string), i++)
|
||||||
|
L.Add(copytext(string, i, i))
|
||||||
|
|
||||||
|
return L
|
||||||
|
|
||||||
|
proc/string_explode(var/string, var/separator)
|
||||||
|
if(istext(string))
|
||||||
|
if(istext(separator) && separator == "")
|
||||||
|
return string_tolist(string)
|
||||||
|
|
||||||
|
var/i
|
||||||
|
var/lasti = 1
|
||||||
|
var/list/L = new/list()
|
||||||
|
|
||||||
|
for(i=1, i<=lentext(string)+1, i++)
|
||||||
|
if(copytext(string, i, i+1) == separator) // We found a separator
|
||||||
|
L.Add(copytext(string, lasti, i))
|
||||||
|
lasti = i+1
|
||||||
|
|
||||||
|
L.Add(copytext(string, lasti, lentext(string)+1)) // Adds the last segment
|
||||||
|
|
||||||
|
return L
|
||||||
|
|
||||||
|
proc/n_repeat(var/string, var/amount)
|
||||||
|
if(istext(string) && isnum(amount))
|
||||||
|
var/i
|
||||||
|
var/newstring = ""
|
||||||
|
for(i=0, i<=amount, i++)
|
||||||
|
newstring = newstring + string
|
||||||
|
|
||||||
|
return newstring
|
||||||
|
|
||||||
|
proc/n_reverse(var/string)
|
||||||
|
if(istext(string))
|
||||||
|
var/newstring = ""
|
||||||
|
var/i
|
||||||
|
for(i=lentext(string), i>0, i--)
|
||||||
|
world << copytext(string, i, i+1)
|
||||||
|
newstring = newstring + copytext(string, i, i+1)
|
||||||
|
|
||||||
|
return newstring
|
||||||
|
|
||||||
|
// I don't know if it's neccesary to make my own proc, but I think I have to to be able to check for istext.
|
||||||
|
proc/n_str2num(var/string)
|
||||||
|
if(istext(string))
|
||||||
|
return text2num(string)
|
||||||
|
|
||||||
|
// Number shit
|
||||||
|
proc/n_num2str(var/num)
|
||||||
|
if(isnum(num))
|
||||||
|
return num2text(num)
|
||||||
|
|
||||||
|
// Squareroot
|
||||||
|
proc/n_sqrt(var/num)
|
||||||
|
if(isnum(num))
|
||||||
|
return sqrt(num)
|
||||||
|
|
||||||
|
// Magnitude of num
|
||||||
|
proc/n_abs(var/num)
|
||||||
|
if(isnum(num))
|
||||||
|
return abs(num)
|
||||||
|
|
||||||
|
// Round down
|
||||||
|
proc/n_floor(var/num)
|
||||||
|
if(isnum(num))
|
||||||
|
return round(num)
|
||||||
|
|
||||||
|
// Round up
|
||||||
|
proc/n_ceil(var/num)
|
||||||
|
if(isnum(num))
|
||||||
|
return round(num)+1
|
||||||
|
|
||||||
|
// Round to nearest integer
|
||||||
|
proc/n_round(var/num)
|
||||||
|
if(isnum(num))
|
||||||
|
if(num-round(num)<0.5)
|
||||||
|
return round(num)
|
||||||
|
return n_ceil(num)
|
||||||
|
|
||||||
|
// Clamps N between min and max
|
||||||
|
proc/n_clamp(var/num, var/min=-1, var/max=1)
|
||||||
|
if(isnum(num)&&isnum(min)&&isnum(max))
|
||||||
|
if(num<=min)
|
||||||
|
return min
|
||||||
|
if(num>=max)
|
||||||
|
return max
|
||||||
|
return num
|
||||||
|
|
||||||
|
// Returns 1 if N is inbetween Min and Max
|
||||||
|
proc/n_inrange(var/num, var/min=-1, var/max=1)
|
||||||
|
if(isnum(num)&&isnum(min)&&isnum(max))
|
||||||
|
return ((min <= num) && (num <= max))
|
||||||
|
// END OF BY DONKIE :(
|
||||||
|
|||||||
Reference in New Issue
Block a user