Better feedback for variant renaming

Initialize variant to null, so the prev check doesn't mess up the first time
Add removal message to modder "remove" for consistency
No message if variant was not changed
This commit is contained in:
theo-3
2021-08-13 11:44:13 +03:00
parent abeb522e58
commit 3da97c06c9
2 changed files with 5 additions and 2 deletions
+1
View File
@@ -407,6 +407,7 @@
return
seed.variant = null
seed.apply_variant_name()
to_chat(usr, "<span class='notice'>You remove the [seed.plantname]'s variant designation.</span>")
interact(usr)
+4 -2
View File
@@ -10,7 +10,7 @@
var/plantname = "Plants" // Name of plant when planted.
var/product // A type path. The thing that is created when the plant is harvested.
var/species = "" // Used to update icons. Should match the name in the sprites unless all icon_* are overriden.
var/variant = "" // Optional custom name to track modified plants. Can be set with pen or from gene modder.
var/variant = null // Optional custom name to track modified plants. Can be set with pen or from gene modder.
var/growing_icon = 'icons/obj/hydroponics/growing.dmi' //the file that stores the sprites of the growing plant from this seed.
var/icon_grow // Used to override grow icon (default is "[species]-grow"). You can use one grow icon for multiple closely related plants with it.
@@ -335,6 +335,7 @@
// adj parameter changes what Adjacent is called from, such as the gene modder or a tray
/obj/item/seeds/proc/variant_prompt(mob/user, obj/item/container = null)
var/prev = variant
var/V = input(user, "Choose variant name:", "Plant Variant Naming", variant) as text|null
if(isnull(V)) // Did the user cancel?
return
@@ -349,7 +350,8 @@
variant = copytext(sanitize(html_encode(trim(V))), 1, 64) // Sanitization must happen after null check because it converts nulls to empty strings
if(variant == "")
variant = null
to_chat(user, "<span class='notice'>You [variant ? "change" : "remove"] the [plantname]'s variant designation.</span>")
if(prev != variant)
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()