mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 19:22:56 +00:00
-Additions to NTSL from /vg/:
Logging for scripts. A non-recursive replacetext function. -Fixed an issue with the broadcast() function for NTSL, it will now properly broadcast again. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@5462 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
@@ -8,7 +8,11 @@ client/verb/tcssave()
|
|||||||
|
|
||||||
if(Machine.SelectedServer)
|
if(Machine.SelectedServer)
|
||||||
var/obj/machinery/telecomms/server/Server = Machine.SelectedServer
|
var/obj/machinery/telecomms/server/Server = Machine.SelectedServer
|
||||||
Server.setcode( winget(src, "tcscode", "text") ) // this actually saves the code from input to the server
|
var/tcscode=winget(src, "tcscode", "text")
|
||||||
|
var/msg="[mob.name] is adding script to server [Server]: [tcscode]"
|
||||||
|
diary << msg
|
||||||
|
message_admins("[mob.name] has uploaded a NTLS script to [Machine.SelectedServer] ([mob.x],[mob.y],[mob.z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[mob.x];Y=[mob.y];Z=[mob.z]'>JMP</a>)",0,1)
|
||||||
|
Server.setcode( tcscode ) // this actually saves the code from input to the server
|
||||||
src << output(null, "tcserror") // clear the errors
|
src << output(null, "tcserror") // clear the errors
|
||||||
else
|
else
|
||||||
src << output(null, "tcserror")
|
src << output(null, "tcserror")
|
||||||
|
|||||||
@@ -68,7 +68,6 @@
|
|||||||
interpreter.SetVar("$medical", 1355)
|
interpreter.SetVar("$medical", 1355)
|
||||||
interpreter.SetVar("$engineering",1357)
|
interpreter.SetVar("$engineering",1357)
|
||||||
interpreter.SetVar("$security", 1359)
|
interpreter.SetVar("$security", 1359)
|
||||||
interpreter.SetVar("$mining", 1349)
|
|
||||||
interpreter.SetVar("$supply", 1347)
|
interpreter.SetVar("$supply", 1347)
|
||||||
|
|
||||||
// Signal data
|
// Signal data
|
||||||
@@ -119,7 +118,7 @@
|
|||||||
@param replacestring: the string to replace the substring with
|
@param replacestring: the string to replace the substring with
|
||||||
|
|
||||||
*/
|
*/
|
||||||
interpreter.SetProc("replace", /proc/replacetext)
|
interpreter.SetProc("replace", /proc/string_replacetext)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
-> Locates an element/substring inside of a list or string
|
-> Locates an element/substring inside of a list or string
|
||||||
@@ -268,6 +267,9 @@ datum/signal
|
|||||||
newsign.data["vmessage"] = H.voice_message
|
newsign.data["vmessage"] = H.voice_message
|
||||||
newsign.data["vname"] = H.voice_name
|
newsign.data["vname"] = H.voice_name
|
||||||
newsign.data["vmask"] = 0
|
newsign.data["vmask"] = 0
|
||||||
|
newsign.data["level"] = list()
|
||||||
|
|
||||||
|
var/pass = S.relay_information(newsign, "/obj/machinery/telecomms/hub")
|
||||||
|
if(!pass)
|
||||||
S.relay_information(newsign, "/obj/machinery/telecomms/broadcaster") // send this simple message to broadcasters
|
S.relay_information(newsign, "/obj/machinery/telecomms/broadcaster") // send this simple message to broadcasters
|
||||||
S.relay_information(newsign, "/obj/machinery/telecomms/hub")
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Script -> BYOND code procs
|
// Script -> BYOND code procs
|
||||||
|
#define SCRIPT_MAX_REPLACEMENTS_ALLOWED 200
|
||||||
// --- List operations (lists known as vectors in n_script) ---
|
// --- List operations (lists known as vectors in n_script) ---
|
||||||
|
|
||||||
// Clone of list()
|
// Clone of list()
|
||||||
@@ -173,6 +173,8 @@ proc/n_repeat(var/string, var/amount)
|
|||||||
if(istext(string) && isnum(amount))
|
if(istext(string) && isnum(amount))
|
||||||
var/i
|
var/i
|
||||||
var/newstring = ""
|
var/newstring = ""
|
||||||
|
if(length(newstring)*amount >=1000)
|
||||||
|
return
|
||||||
for(i=0, i<=amount, i++)
|
for(i=0, i<=amount, i++)
|
||||||
if(i>=1000)
|
if(i>=1000)
|
||||||
break
|
break
|
||||||
@@ -242,3 +244,48 @@ proc/n_inrange(var/num, var/min=-1, var/max=1)
|
|||||||
if(isnum(num)&&isnum(min)&&isnum(max))
|
if(isnum(num)&&isnum(min)&&isnum(max))
|
||||||
return ((min <= num) && (num <= max))
|
return ((min <= num) && (num <= max))
|
||||||
// END OF BY DONKIE :(
|
// END OF BY DONKIE :(
|
||||||
|
|
||||||
|
// Non-recursive
|
||||||
|
// Imported from Mono string.ReplaceUnchecked
|
||||||
|
/proc/string_replacetext(var/haystack,var/a,var/b)
|
||||||
|
if(istext(haystack)&&istext(a)&&istext(b))
|
||||||
|
var/i = 1
|
||||||
|
var/lenh=lentext(haystack)
|
||||||
|
var/lena=lentext(a)
|
||||||
|
//var/lenb=lentext(b)
|
||||||
|
var/count = 0
|
||||||
|
var/list/dat = list()
|
||||||
|
while (i < lenh)
|
||||||
|
var/found = findtext(haystack, a, i, 0)
|
||||||
|
//diary << "findtext([haystack], [a], [i], 0)=[found]"
|
||||||
|
if (found == 0) // Not found
|
||||||
|
break
|
||||||
|
else
|
||||||
|
if (count < SCRIPT_MAX_REPLACEMENTS_ALLOWED)
|
||||||
|
dat+=found
|
||||||
|
count+=1
|
||||||
|
else
|
||||||
|
//diary << "Script found [a] [count] times, aborted"
|
||||||
|
break
|
||||||
|
//diary << "Found [a] at [found]! Moving up..."
|
||||||
|
i = found + lena
|
||||||
|
if (count == 0)
|
||||||
|
return haystack
|
||||||
|
//var/nlen = lenh + ((lenb - lena) * count)
|
||||||
|
var/buf = copytext(haystack,1,dat[1]) // Prefill
|
||||||
|
var/lastReadPos = 0
|
||||||
|
for (i = 1, i <= count, i++)
|
||||||
|
var/precopy = dat[i] - lastReadPos-1
|
||||||
|
//internal static unsafe void CharCopy (String target, int targetIndex, String source, int sourceIndex, int count)
|
||||||
|
//fixed (char* dest = target, src = source)
|
||||||
|
//CharCopy (dest + targetIndex, src + sourceIndex, count);
|
||||||
|
//CharCopy (dest + curPos, source + lastReadPos, precopy);
|
||||||
|
buf+=copytext(haystack,lastReadPos,precopy)
|
||||||
|
diary << "buf+=copytext([haystack],[lastReadPos],[precopy])"
|
||||||
|
diary<<"[buf]"
|
||||||
|
lastReadPos = dat[i] + lena
|
||||||
|
//CharCopy (dest + curPos, replace, newValue.length);
|
||||||
|
buf+=b
|
||||||
|
diary<<"[buf]"
|
||||||
|
buf+=copytext(haystack,lastReadPos, 0)
|
||||||
|
return buf
|
||||||
Reference in New Issue
Block a user