mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-19 02:54:41 +01:00
Telecomms Refactor & CodeMirror
This commit does the following:
- A lot of shit I am really too tired to fucking write about
- Absolute pathed telecomms scripting
- Browser Datum traffic control
- Absolutely lovely replacement for the fucking skin TCS window, using
codemirror
- CodeMirror integration for nanoUI
- Sorta, I didn't work on this as much as I wanted to, because IT TOOK
11 FUCKING HOURS TO GET THE BROWSER DATUM TO WORK
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
// Script -> BYOND code procs
|
||||
#define SCRIPT_MAX_REPLACEMENTS_ALLOWED 200
|
||||
|
||||
// --- List operations (lists known as vectors in n_script) ---
|
||||
|
||||
// Creates a list out of all the arguments
|
||||
// Clone of list()
|
||||
/proc/n_list()
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/n_list() called tick#: [world.time]")
|
||||
var/list/returnlist = list()
|
||||
for(var/e in args)
|
||||
returnlist.Add(e)
|
||||
return returnlist
|
||||
|
||||
// Picks one random item from the list
|
||||
// Clone of pick()
|
||||
/proc/n_pick()
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/n_pick() called tick#: [world.time]")
|
||||
var/list/finalpick = list()
|
||||
for(var/e in args)
|
||||
if(isobject(e))
|
||||
@@ -24,15 +25,16 @@
|
||||
|
||||
return pick(finalpick)
|
||||
|
||||
// Gets/Sets a value at a key in the list
|
||||
// Clone of list[]
|
||||
/proc/n_listpos(var/list/L, var/pos, var/value)
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/n_listpos() called tick#: [world.time]")
|
||||
if(!istype(L, /list)) return
|
||||
if(isnum(pos))
|
||||
if(!value)
|
||||
if(L.len >= pos)
|
||||
if(L.len >= pos && !(pos > L.len))
|
||||
return L[pos]
|
||||
else
|
||||
if(L.len >= pos)
|
||||
if(L.len >= pos && !(pos > L.len))
|
||||
L[pos] = value
|
||||
else if(istext(pos))
|
||||
if(!value)
|
||||
@@ -40,13 +42,15 @@
|
||||
else
|
||||
L[pos] = value
|
||||
|
||||
// Copies the list into a new one
|
||||
// Clone of list.Copy()
|
||||
/proc/n_listcopy(var/list/L, var/start, var/end)
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/n_listcopy() called tick#: [world.time]")
|
||||
if(!istype(L, /list)) return
|
||||
return L.Copy(start, end)
|
||||
|
||||
// Adds arg 2,3,4,5... to the end of list at arg 1
|
||||
// Clone of list.Add()
|
||||
/proc/n_listadd()
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/n_listadd() called tick#: [world.time]")
|
||||
var/list/chosenlist
|
||||
var/i = 1
|
||||
for(var/e in args)
|
||||
@@ -59,8 +63,9 @@
|
||||
if(chosenlist)
|
||||
chosenlist.Add(e)
|
||||
|
||||
// Removes arg 2,3,4,5... from list at arg 1
|
||||
// Clone of list.Remove()
|
||||
/proc/n_listremove()
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/n_listremove() called tick#: [world.time]")
|
||||
var/list/chosenlist
|
||||
var/i = 1
|
||||
for(var/e in args)
|
||||
@@ -73,26 +78,45 @@
|
||||
if(chosenlist)
|
||||
chosenlist.Remove(e)
|
||||
|
||||
// Cuts out a copy of a list
|
||||
// Clone of list.len = 0
|
||||
/proc/n_listcut(var/list/L, var/start, var/end)
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/n_listcut() called tick#: [world.time]")
|
||||
if(!istype(L, /list)) return
|
||||
return L.Cut(start, end)
|
||||
|
||||
// Swaps two values in the list
|
||||
// Clone of list.Swap()
|
||||
/proc/n_listswap(var/list/L, var/firstindex, var/secondindex)
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/n_listswap() called tick#: [world.time]")
|
||||
if(!istype(L, /list)) return
|
||||
if(L.len >= secondindex && L.len >= firstindex)
|
||||
return L.Swap(firstindex, secondindex)
|
||||
|
||||
// Inserts a value into the list
|
||||
// Clone of list.Insert()
|
||||
/proc/n_listinsert(var/list/L, var/index, var/element)
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/n_listinsert() called tick#: [world.time]")
|
||||
if(!istype(L, /list)) return
|
||||
return L.Insert(index, element)
|
||||
|
||||
// --- String methods ---
|
||||
// --- Miscellaneous functions ---
|
||||
|
||||
//If list, finds a value in it, if text, finds a substring in it
|
||||
/proc/n_smartfind(var/haystack, var/needle, var/start = 1, var/end = 0)
|
||||
// Clone of sleep()
|
||||
/proc/delay(var/time)
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/delay() called tick#: [world.time]")
|
||||
sleep(time)
|
||||
|
||||
// Clone of rand()
|
||||
/proc/rand_chance(var/low = 0, var/high)
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/rand_chance() called tick#: [world.time]")
|
||||
return rand(low, high)
|
||||
|
||||
// Clone of prob()
|
||||
/proc/prob_chance(var/chance)
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/prob_chance() called tick#: [world.time]")
|
||||
return prob(chance)
|
||||
|
||||
// Merge of list.Find() and findtext()
|
||||
/proc/smartfind(var/haystack, var/needle, var/start = 1, var/end = 0)
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/smartfind() called tick#: [world.time]")
|
||||
if(haystack && needle)
|
||||
if(isobject(haystack))
|
||||
if(istype(haystack, /list))
|
||||
@@ -104,41 +128,54 @@
|
||||
if(istext(haystack))
|
||||
if(length(haystack) >= end && start > 0)
|
||||
return findtext(haystack, needle, start, end)
|
||||
|
||||
//Returns a substring of the string
|
||||
/proc/n_substr(var/string, var/start = 1, var/end = 0)
|
||||
|
||||
// Clone of copytext()
|
||||
/proc/docopytext(var/string, var/start = 1, var/end = 0)
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/docopytext() called tick#: [world.time]")
|
||||
if(istext(string) && isnum(start) && isnum(end))
|
||||
if(start > 0)
|
||||
return copytext(string, start, end)
|
||||
|
||||
//Returns the length of the string or list
|
||||
/proc/n_smartlength(var/container)
|
||||
// Clone of length()
|
||||
/proc/smartlength(var/container)
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/smartlength() called tick#: [world.time]")
|
||||
if(container)
|
||||
if(istype(container, /list) || istext(container))
|
||||
return length(container)
|
||||
return 0
|
||||
|
||||
//Lowercase all characters
|
||||
// BY DONKIE~
|
||||
// String stuff
|
||||
/proc/n_lower(var/string)
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/n_lower() called tick#: [world.time]")
|
||||
if(istext(string))
|
||||
return lowertext(string)
|
||||
|
||||
//Uppercase all characters
|
||||
/proc/n_upper(var/string)
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/n_upper() called tick#: [world.time]")
|
||||
if(istext(string))
|
||||
return uppertext(string)
|
||||
|
||||
//Converts a string to a list
|
||||
/proc/n_explode(var/string, var/separator = "")
|
||||
/proc/time()
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/time() called tick#: [world.time]")
|
||||
return world.time + (12 HOURS)
|
||||
|
||||
/proc/timestamp(var/format = "hh:mm:ss") // Get the game time in text
|
||||
//writepanic("[__FILE__].[__LINE__] (no type)([usr ? usr.ckey : ""]) \\/proc/timestamp() called tick#: [world.time]")
|
||||
return time2text(world.time + (10 HOURS), format) // Yes, 10, not 12 hours, for some reason time2text() is being moronic (T-thanks BYOND), and it's adding 2 hours to this, I don't even know either.
|
||||
|
||||
proc/string_explode(var/string, var/separator = "")
|
||||
//writepanic("[__FILE__].[__LINE__] \\/proc/string_explode() called tick#: [world.time]")
|
||||
if(istext(string) && (istext(separator) || isnull(separator)))
|
||||
return text2list(string, separator)
|
||||
|
||||
//Converts a list to a string
|
||||
/proc/n_implode(var/list/li, var/separator)
|
||||
/proc/list_implode(var/list/li, var/separator)
|
||||
if(istype(li) && (istext(separator) || isnull(separator)))
|
||||
return list2text(li, separator)
|
||||
|
||||
//Repeats the string x times
|
||||
/proc/n_repeat(var/string, var/amount)
|
||||
proc/n_repeat(var/string, var/amount)
|
||||
//writepanic("[__FILE__].[__LINE__] \\/proc/n_repeat() called tick#: [world.time]")
|
||||
if(istext(string) && isnum(amount))
|
||||
var/i
|
||||
var/newstring = ""
|
||||
@@ -151,166 +188,76 @@
|
||||
|
||||
return newstring
|
||||
|
||||
//Reverses the order of the string. "Clown" becomes "nwolC"
|
||||
/proc/n_reverse(var/string)
|
||||
if(istext(string))
|
||||
var/newstring = ""
|
||||
var/i
|
||||
for(i=lentext(string), i>0, i--)
|
||||
if(i>=1000)
|
||||
break
|
||||
newstring = newstring + copytext(string, i, i+1)
|
||||
|
||||
return newstring
|
||||
|
||||
// String -> Number
|
||||
/proc/n_str2num(var/string)
|
||||
// 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)
|
||||
//writepanic("[__FILE__].[__LINE__] \\/proc/n_str2num() called tick#: [world.time]")
|
||||
if(istext(string))
|
||||
return text2num(string)
|
||||
|
||||
/proc/n_proper(var/string)
|
||||
if(!istext(string))
|
||||
return ""
|
||||
// Clamps N between min and max
|
||||
/proc/n_clamp(var/num, var/min = 0, var/max = 1)
|
||||
if(isnum(num) && isnum(min) && isnum(max))
|
||||
return Clamp(num, min, max)
|
||||
|
||||
return text("[][]", uppertext(copytext(string, 1, 2)), lowertext(copytext(string, 2)))
|
||||
|
||||
|
||||
// --- Number methods ---
|
||||
|
||||
//Returns the highest value of the arguments
|
||||
//Need custom functions here cause byond's min and max runtimes if you give them a string or list.
|
||||
/proc/n_max()
|
||||
if(args.len == 0)
|
||||
return 0
|
||||
|
||||
var/max = args[1]
|
||||
for(var/e in args)
|
||||
if(isnum(e) && e > max)
|
||||
max = e
|
||||
|
||||
return max
|
||||
|
||||
//Returns the lowest value of the arguments
|
||||
/proc/n_min()
|
||||
if(args.len == 0)
|
||||
return 0
|
||||
|
||||
var/min = args[1]
|
||||
for(var/e in args)
|
||||
if(isnum(e) && e < min)
|
||||
min = e
|
||||
|
||||
return min
|
||||
|
||||
/proc/n_prob(var/chance)
|
||||
return prob(chance)
|
||||
|
||||
/proc/n_randseed(var/seed)
|
||||
rand_seed(seed)
|
||||
return 0
|
||||
|
||||
/proc/n_rand(var/low, var/high)
|
||||
if(isnull(low) && isnull(high))
|
||||
return rand()
|
||||
|
||||
return rand(low, high)
|
||||
|
||||
// Number shit
|
||||
/proc/n_num2str(var/num)
|
||||
proc/n_num2str(var/num)
|
||||
//writepanic("[__FILE__].[__LINE__] \\/proc/n_num2str() called tick#: [world.time]")
|
||||
if(isnum(num))
|
||||
return num2text(num)
|
||||
|
||||
// Squareroot
|
||||
/proc/n_sqrt(var/num)
|
||||
proc/n_sqrt(var/num)
|
||||
//writepanic("[__FILE__].[__LINE__] \\/proc/n_sqrt() called tick#: [world.time]")
|
||||
if(isnum(num))
|
||||
return sqrt(num)
|
||||
|
||||
// Magnitude of num
|
||||
/proc/n_abs(var/num)
|
||||
proc/n_abs(var/num)
|
||||
//writepanic("[__FILE__].[__LINE__] \\/proc/n_abs() called tick#: [world.time]")
|
||||
if(isnum(num))
|
||||
return abs(num)
|
||||
|
||||
// Round down
|
||||
/proc/n_floor(var/num)
|
||||
proc/n_floor(var/num)
|
||||
//writepanic("[__FILE__].[__LINE__] \\/proc/n_floor() called tick#: [world.time]")
|
||||
if(isnum(num))
|
||||
return round(num)
|
||||
|
||||
// Round up
|
||||
/proc/n_ceil(var/num)
|
||||
proc/n_ceil(var/num)
|
||||
//writepanic("[__FILE__].[__LINE__] \\/proc/n_ceil() called tick#: [world.time]")
|
||||
if(isnum(num))
|
||||
return round(num)+1
|
||||
|
||||
// Round to nearest integer
|
||||
/proc/n_round(var/num)
|
||||
proc/n_round(var/num)
|
||||
//writepanic("[__FILE__].[__LINE__] \\/proc/n_round() called tick#: [world.time]")
|
||||
if(isnum(num))
|
||||
if(num-round(num)<0.5)
|
||||
return round(num)
|
||||
return n_ceil(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
|
||||
// END OF BY DONKIE :(
|
||||
|
||||
// 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))
|
||||
/proc/n_sin(var/const/x)
|
||||
return sin(x)
|
||||
|
||||
// Returns the sine of num
|
||||
/proc/n_sin(var/num)
|
||||
if(isnum(num))
|
||||
return sin(num)
|
||||
/proc/n_cos(var/const/x)
|
||||
return cos(x)
|
||||
|
||||
// Returns the cosine of num
|
||||
/proc/n_cos(var/num)
|
||||
if(isnum(num))
|
||||
return cos(num)
|
||||
/proc/n_asin(var/const/x)
|
||||
return arcsin(x)
|
||||
|
||||
// Returns the arcsine of num
|
||||
/proc/n_asin(var/num)
|
||||
if(isnum(num)&&-1<=num&&num<=1)
|
||||
return arcsin(num)
|
||||
/proc/n_acos(var/const/x)
|
||||
return arccos(x)
|
||||
|
||||
// Returns the arccosine of num
|
||||
/proc/n_acos(var/num)
|
||||
if(isnum(num)&&-1<=num&&num<=1)
|
||||
return arccos(num)
|
||||
|
||||
// Returns the natural log of num
|
||||
/proc/n_max(...)
|
||||
return max(arglist(args))
|
||||
|
||||
/proc/n_min(...)
|
||||
return min(arglist(args))
|
||||
|
||||
/proc/n_log(var/num)
|
||||
if(isnum(num)&&0<num)
|
||||
return log(num)
|
||||
|
||||
// Replace text
|
||||
/proc/n_replace(text, find, replacement)
|
||||
if(istext(text) && istext(find) && istext(replacement))
|
||||
var/find_len = length(find)
|
||||
if(find_len < 1) return text
|
||||
. = ""
|
||||
var/last_found = 1
|
||||
var/count = 0
|
||||
while(1)
|
||||
count += 1
|
||||
if(count > SCRIPT_MAX_REPLACEMENTS_ALLOWED)
|
||||
break
|
||||
var/found = findtext(text, find, last_found, 0)
|
||||
. += copytext(text, last_found, found)
|
||||
if(found)
|
||||
. += replacement
|
||||
last_found = found + find_len
|
||||
continue
|
||||
return
|
||||
|
||||
// --- Miscellaneous functions ---
|
||||
|
||||
/proc/n_time()
|
||||
return world.timeofday
|
||||
|
||||
// Clone of sleep()
|
||||
/proc/n_delay(var/time)
|
||||
sleep(time)
|
||||
if(isnum(num) && 0 < num)
|
||||
return log(num)
|
||||
Reference in New Issue
Block a user