Use null instead of empty string, fix all string checks

This commit is contained in:
theo-3
2021-08-12 15:19:59 +03:00
parent 39d38e756b
commit 8a8b7b16a6
4 changed files with 8 additions and 6 deletions
+3 -3
View File
@@ -279,9 +279,9 @@
dat += "</div>"
dat += "<div class='line'><h3>Variant</h3></div><div class='statusDisplay'><table>"
dat += "<tr><td width='260px'>[(seed.variant == "") ? "None" : seed.variant]</td>"
dat += "<tr><td width='260px'>[seed.variant ? seed.variant : "None"]</td>"
dat += "<td><a href='?src=[UID()];set_v=1'>Edit</a></td>"
if(seed.variant != "")
if(seed.variant)
dat += "<td><a href='?src=[UID()];del_v=1'>Remove</a></td>"
dat += "</tr></table></div>"
else
@@ -405,7 +405,7 @@
else if(href_list["del_v"])
if(!seed)
return
seed.variant = ""
seed.variant = null
seed.apply_variant_name()
interact(usr)
+1 -1
View File
@@ -42,7 +42,7 @@
seed.prepare_result(src)
transform *= TRANSFORM_USING_VARIABLE(seed.potency, 100) + 0.5 //Makes the resulting produce's sprite larger or smaller based on potency!
add_juice()
if(seed.variant && seed.variant != "")
if(seed.variant)
name += " \[[seed.variant]]"
/obj/item/reagent_containers/food/snacks/grown/Destroy()
+1 -1
View File
@@ -344,7 +344,7 @@
/obj/machinery/hydroponics/examine(user)
. = ..()
if(myseed)
if(myseed.variant != "")
if(myseed.variant)
. += "<span class='info'>It has the <span class='name'>[myseed.variant]</span> variant of <span class='name'>[myseed.plantname]</span> planted.</span>"
else
. += "<span class='info'>It has <span class='name'>[myseed.plantname]</span> planted.</span>"
+3 -1
View File
@@ -339,11 +339,13 @@
if(!adj.Adjacent(user) || isnull(V))
return
variant = copytext(sanitize(html_encode(trim(V))), 1, 64)
if(variant == "")
variant == null
to_chat(user, "<span class='notice'>You [variant ? "change" : "remove"] the [plantname]'s variant designation.</span>")
apply_variant_name()
/obj/item/seeds/proc/apply_variant_name()
var/V = (variant == "") ? "" : " \[[variant]]" // If we have a non-empty variant add it to the name
var/V = variant ? " \[[variant]]" : "" // If we have a non-empty variant add it to the name
var/N = initial(name)
if(copytext(name, 1, 13) == "experimental") // Don't delete 'experimental'
N = "experimental " + N