Skip to content

Commit

Permalink
replaces X.len with length(X)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gboster-0 committed Nov 8, 2024
1 parent 579e21f commit 4eb42c6
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 69 deletions.
90 changes: 45 additions & 45 deletions yogstation/code/modules/scripting/Implementations/logic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
name = "find"

/datum/n_function/default/find/execute(this_obj, list/params)
var/haystack = params.len >= 1 ? params[1] : null
var/needle = params.len >= 2 ? params[2] : null
var/start = params.len >= 3 ? params[3] : 1
var/end = params.len >= 4 ? params[4] : 0
var/haystack = length(params) >= 1 ? params[1] : null
var/needle = length(params) >= 2 ? params[2] : null
var/start = length(params) >= 3 ? params[3] : 1
var/end = length(params) >= 4 ? params[4] : 0
if(!haystack || !needle)
return
if(IS_OBJECT(haystack))
Expand All @@ -50,9 +50,9 @@
name = "substr"

/datum/n_function/default/substr/execute(this_obj, list/params)
var/string = params.len >= 1 ? params[1] : null
var/start = params.len >= 2 ? params[2] : 1
var/end = params.len >= 3 ? params[3] : 0
var/string = length(params) >= 1 ? params[1] : null
var/start = length(params) >= 2 ? params[2] : 1
var/end = length(params) >= 3 ? params[3] : 0
if(istext(string) && isnum(start) && isnum(end))
if(start > 0)
return copytext(string, start, end)
Expand All @@ -62,7 +62,7 @@
name = "length"

/datum/n_function/default/length/execute(this_obj, list/params)
var/container = params.len >= 1 ? params[1] : null
var/container = length(params) >= 1 ? params[1] : null
if(container)
if(istype(container, /list) || istext(container))
return length(container)
Expand All @@ -73,7 +73,7 @@
name = "lower"

/datum/n_function/default/lower/execute(this_obj, list/params)
var/string = params.len >= 1 ? params[1] : null
var/string = length(params) >= 1 ? params[1] : null
if(istext(string))
return lowertext(string)

Expand All @@ -82,7 +82,7 @@
name = "upper"

/datum/n_function/default/upper/execute(this_obj, list/params)
var/string = params.len >= 1 ? params[1] : null
var/string = length(params) >= 1 ? params[1] : null
if(istext(string))
return uppertext(string)

Expand All @@ -91,8 +91,8 @@
name = "explode"

/datum/n_function/default/explode/execute(this_obj, list/params)
var/string = params.len >= 1 ? params[1] : null
var/separator = params.len >= 2 ? params[2] : ""
var/string = length(params) >= 1 ? params[1] : null
var/separator = length(params) >= 2 ? params[2] : ""
if(istext(string) && (istext(separator) || isnull(separator)))
return splittext(string, separator)

Expand All @@ -111,8 +111,8 @@
name = "repeat"

/datum/n_function/default/repeat/execute(this_obj, list/params)
var/string = params.len >= 1 ? params[1] : null
var/amount = params.len >= 2 ? params[2] : null
var/string = length(params) >= 1 ? params[1] : null
var/amount = length(params) >= 2 ? params[2] : null
if(istext(string) && isnum(amount))
var/i
var/newstring = ""
Expand All @@ -130,7 +130,7 @@
name = "reverse"

/datum/n_function/default/reverse/execute(this_obj, list/params)
var/string = params.len >= 1 ? params[1] : null
var/string = length(params) >= 1 ? params[1] : null
if(istext(string))
var/newstring = ""
var/i
Expand All @@ -146,15 +146,15 @@
name = "tonum"

/datum/n_function/default/tonum/execute(this_obj, list/params)
var/string = params.len >= 1 ? params[1] : null
var/string = length(params) >= 1 ? params[1] : null
if(istext(string))
return text2num(string)

/datum/n_function/default/proper
name = "proper"

/datum/n_function/default/proper/execute(this_obj, list/params)
var/string = params.len >= 1 ? params[1] : null
var/string = length(params) >= 1 ? params[1] : null
if(!istext(string))
return ""

Expand All @@ -170,7 +170,7 @@
name = "max"

/datum/n_function/default/max/execute(this_obj, list/params)
if(!params.len)
if(!length(params))
return FALSE

var/max = params[1]
Expand All @@ -185,7 +185,7 @@
name = "min"

/datum/n_function/default/min/execute(this_obj, list/params)
if(!params.len)
if(!length(params))
return FALSE

var/min = params[1]
Expand All @@ -199,22 +199,22 @@
name = "prob"

/datum/n_function/default/prob/execute(this_obj, list/params)
var/chance = params.len >= 1 ? params[1] : null
var/chance = length(params) >= 1 ? params[1] : null
return prob(chance)

/datum/n_function/default/randseed
name = "randseed"

/datum/n_function/default/randseed/execute(this_obj, list/params)
//var/seed = params.len >= 1 ? params[1] : null
//var/seed = length(params) >= 1 ? params[1] : null
//rand_seed(seed)

/datum/n_function/default/rand
name = "rand"

/datum/n_function/default/rand/execute(this_obj, list/params)
var/low = params.len >= 1 ? params[1] : null
var/high = params.len >= 2 ? params[2] : null
var/low = length(params) >= 1 ? params[1] : null
var/high = length(params) >= 2 ? params[2] : null
if(isnull(low) && isnull(high))
return rand()

Expand All @@ -225,7 +225,7 @@
name = "tostring"

/datum/n_function/default/tostring/execute(this_obj, list/params)
var/num = params.len >= 1 ? params[1] : null
var/num = length(params) >= 1 ? params[1] : null
if(isnum(num))
return num2text(num)

Expand All @@ -234,7 +234,7 @@
name = "sqrt"

/datum/n_function/default/sqrt/execute(this_obj, list/params)
var/num = params.len >= 1 ? params[1] : null
var/num = length(params) >= 1 ? params[1] : null
if(isnum(num))
return sqrt(num)

Expand All @@ -243,7 +243,7 @@
name = "abs"

/datum/n_function/default/abs/execute(this_obj, list/params)
var/num = params.len >= 1 ? params[1] : null
var/num = length(params) >= 1 ? params[1] : null
if(isnum(num))
return abs(num)

Expand All @@ -252,7 +252,7 @@
name = "floor"

/datum/n_function/default/floor/execute(this_obj, list/params)
var/num = params.len >= 1 ? params[1] : null
var/num = length(params) >= 1 ? params[1] : null
if(isnum(num))
return round(num)

Expand All @@ -261,7 +261,7 @@
name = "ceil"

/datum/n_function/default/ceil/execute(this_obj, list/params)
var/num = params.len >= 1 ? params[1] : null
var/num = length(params) >= 1 ? params[1] : null
if(isnum(num))
return round(num)+1

Expand All @@ -270,7 +270,7 @@
name = "round"

/datum/n_function/default/round/execute(this_obj, list/params)
var/num = params.len >= 1 ? params[1] : null
var/num = length(params) >= 1 ? params[1] : null
if(isnum(num))
if(num-round(num) < 0.5)
return round(num)
Expand All @@ -281,9 +281,9 @@
name = "clamp"

/datum/n_function/default/clamp/execute(this_obj, list/params)
var/num = params.len >= 1 ? params[1] : null
var/min = params.len >= 2 ? params[2] : -1
var/max = params.len >= 3 ? params[3] : 1
var/num = length(params) >= 1 ? params[1] : null
var/min = length(params) >= 2 ? params[2] : -1
var/max = length(params) >= 3 ? params[3] : 1
if(isnum(num) && isnum(min) && isnum(max))
if(num <= min)
return min
Expand All @@ -296,9 +296,9 @@
name = "inrange"

/datum/n_function/default/inrange/execute(this_obj, list/params)
var/num = params.len >= 1 ? params[1] : null
var/min = params.len >= 2 ? params[2] : -1
var/max = params.len >= 3 ? params[3] : 1
var/num = length(params) >= 1 ? params[1] : null
var/min = length(params) >= 2 ? params[2] : -1
var/max = length(params) >= 3 ? params[3] : 1
if(isnum(num)&&isnum(min)&&isnum(max))
return ((min <= num) && (num <= max))

Expand All @@ -307,7 +307,7 @@
name = "sin"

/datum/n_function/default/sin/execute(this_obj, list/params)
var/num = params.len >= 1 ? params[1] : null
var/num = length(params) >= 1 ? params[1] : null
if(isnum(num))
return sin(num)

Expand All @@ -316,7 +316,7 @@
name = "cos"

/datum/n_function/default/cos/execute(this_obj, list/params)
var/num = params.len >= 1 ? params[1] : null
var/num = length(params) >= 1 ? params[1] : null
if(isnum(num))
return cos(num)

Expand All @@ -325,7 +325,7 @@
name = "asin"

/datum/n_function/default/asin/execute(this_obj, list/params)
var/num = params.len >= 1 ? params[1] : null
var/num = length(params) >= 1 ? params[1] : null
if(isnum(num) && -1 <= num && num <= 1)
return arcsin(num)

Expand All @@ -334,7 +334,7 @@
name = "acos"

/datum/n_function/default/acos/execute(this_obj, list/params)
var/num = params.len >= 1 ? params[1] : null
var/num = length(params) >= 1 ? params[1] : null
if(isnum(num) && -1 <= num && num <= 1)
return arccos(num)

Expand All @@ -343,7 +343,7 @@
name = "log"

/datum/n_function/default/log/execute(this_obj, list/params)
var/num = params.len >= 1 ? params[1] : null
var/num = length(params) >= 1 ? params[1] : null
if(isnum(num) && 0 < num)
return log(num)

Expand All @@ -352,17 +352,17 @@
name = "replace"

/datum/n_function/default/replace/execute(this_obj, list/params)
var/text = params.len >= 1 ? params[1] : null
var/find = params.len >= 2 ? params[2] : null
var/replacement = params.len >= 3 ? params[3] : null
var/text = length(params) >= 1 ? params[1] : null
var/find = length(params) >= 2 ? params[2] : null
var/replacement = length(params) >= 3 ? params[3] : null
if(!istext(text) || !istext(find) || !istext(replacement))
return
var/find_len = length(find)
if(!find_len)
return text

var/max_count
if(params.len >= 4 && isnum(params[4]))
if(length(params) >= 4 && isnum(params[4]))
max_count = min(params[4], SCRIPT_MAX_REPLACEMENTS_ALLOWED)
else
max_count = SCRIPT_MAX_REPLACEMENTS_ALLOWED
Expand Down Expand Up @@ -393,7 +393,7 @@
name = "sleep"

/datum/n_function/default/sleeps/execute(this_obj, list/params)
var/time = params.len >= 1 ? params[1] : null
var/time = length(params) >= 1 ? params[1] : null
sleep(time)

/datum/n_function/default/timestamp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ GLOBAL_LIST_INIT(allowed_translations, list(
returnerrors += scanner.errors
returnerrors += parser.errors

if(returnerrors.len)
if(length(returnerrors))
return returnerrors

interpreter = new(program)
Expand Down Expand Up @@ -296,13 +296,13 @@ GLOBAL_LIST_INIT(allowed_translations, list(

/datum/n_function/default/signal/execute(this_obj, list/params)
var/datum/n_struct/signal/S = new
if(params.len >= 1)
if(length(params) >= 1)
S.properties["content"] = params[1]
if(params.len >= 2)
if(length(params) >= 2)
S.properties["freq"] = params[2]
if(params.len >= 3)
if(length(params) >= 3)
S.properties["source"] = params[3]
if(params.len >= 4)
if(length(params) >= 4)
S.properties["job"] = params[4]
return S

Expand Down Expand Up @@ -349,8 +349,8 @@ GLOBAL_LIST_INIT(allowed_translations, list(
interp_type = /datum/n_Interpreter/TCS_Interpreter

/datum/n_function/default/mem/execute(this_obj, list/params, datum/scope/scope, datum/n_Interpreter/TCS_Interpreter/interp)
var/address = params.len >= 1 ? params[1] : null
var/value = params.len >= 2 ? params[2] : null
var/address = length(params) >= 1 ? params[1] : null
var/value = length(params) >= 2 ? params[2] : null
if(istext(address))
var/obj/machinery/telecomms/server/S = interp.Compiler.Holder

Expand All @@ -360,7 +360,7 @@ GLOBAL_LIST_INIT(allowed_translations, list(
S.memory -= address
return TRUE
else // Setting the value
if(S.memory.len >= MAX_MEM_VARS)
if(length(S.memory) >= MAX_MEM_VARS)
if(!(address in S.memory))
return FALSE
S.memory[address] = value
Expand All @@ -380,8 +380,8 @@ GLOBAL_LIST_INIT(allowed_translations, list(
interp_type = /datum/n_Interpreter/TCS_Interpreter

/datum/n_function/default/remote_signal/execute(this_obj, list/params, datum/scope/scope, datum/n_Interpreter/TCS_Interpreter/interp)
var/freq = params.len >= 1 ? params[1] : 1459
var/code = params.len >= 2 ? params[2] : 30
var/freq = length(params) >= 1 ? params[1] : 1459
var/code = length(params) >= 2 ? params[2] : 30

if(isnum(freq) && isnum(code))

Expand Down Expand Up @@ -418,7 +418,7 @@ GLOBAL_LIST_INIT(allowed_translations, list(
interp_type = /datum/n_Interpreter/TCS_Interpreter

/datum/n_function/default/broadcast/execute(this_obj, list/params, datum/scope/scope, datum/n_Interpreter/TCS_Interpreter/interp)
if(params.len < 1)
if(length(params) < 1)
return
var/datum/n_struct/signal/script_signal = params[1]
if(!istype(script_signal))
Expand Down
Loading

0 comments on commit 4eb42c6

Please sign in to comment.