From 08ed0b080bd10e618f084a61629cd9e0d0a9efcf Mon Sep 17 00:00:00 2001 From: "vageyenaman@gmail.com" Date: Tue, 28 Feb 2012 04:57:03 +0000 Subject: [PATCH] Improvements on TCS and the NTSL default namespace. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3208 316c924e-a436-60f5-8080-3fe189b3f50e --- .../scripting/Implementations/Telecomms.dm | 5 +++-- .../modules/scripting/Implementations/_Logic.dm | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/code/modules/scripting/Implementations/Telecomms.dm b/code/modules/scripting/Implementations/Telecomms.dm index d0306ffc61..b95ace19aa 100644 --- a/code/modules/scripting/Implementations/Telecomms.dm +++ b/code/modules/scripting/Implementations/Telecomms.dm @@ -41,8 +41,8 @@ program.SetVar("PI" , 3.141592653) // value of pi program.SetVar("E" , 2.718281828) // value of e program.SetVar("SQURT2" , 1.414213562) // value of the square root of 2 - program.SetVar("false" , 0) // boolean shortcut to 0 - program.SetVar("true" , 1) // boolean shortcut to 1 + program.SetVar("FALSE" , 0) // boolean shortcut to 0 + program.SetVar("TRUE" , 1) // boolean shortcut to 1 program.SetVar("NORTH" , NORTH) // NORTH (1) program.SetVar("SOUTH" , SOUTH) // SOUTH (2) @@ -146,6 +146,7 @@ interpreter.SetProc("pick", /proc/n_pick) interpreter.SetProc("prob", /proc/prob_chance) + interpreter.SetProc("substr", /proc/docopytext) diff --git a/code/modules/scripting/Implementations/_Logic.dm b/code/modules/scripting/Implementations/_Logic.dm index aca6ed2110..e6ae13fded 100644 --- a/code/modules/scripting/Implementations/_Logic.dm +++ b/code/modules/scripting/Implementations/_Logic.dm @@ -78,7 +78,8 @@ // Clone of list.Swap() /proc/n_listswap(var/list/L, var/firstindex, var/secondindex) if(!istype(L, /list)) return - return L.Swap(firstindex, secondindex) + 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) @@ -100,12 +101,20 @@ if(haystack && needle) if(isobject(haystack)) if(istype(haystack, /list)) - var/list/listhaystack = haystack - return listhaystack.Find(needle, start, end) + if(length(haystack) >= end && start > 0) + var/list/listhaystack = haystack + return listhaystack.Find(needle, start, end) else if(istext(haystack)) - return findtext(haystack, needle, start, end) + 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)