ID:794837
 
Keywords: input
(See the best response by DarkCampainger.)
Code:
mob
proc
Name_Land()
set category = "Property"
if (src.owner == "property1")
for (var/area/property1/P in world)
P.property_name = input ("Please choose a name for your property", "Name Land")


Problem description:

Hello, im trying to make a farming game. what im trying to do here is make it so people can give a name to their farm land. my problem is i would like to give this input box a cancel button in case someone changes their mind and doesnt want to name their land. how would i go about doing something like that? i just now got the hang of input boxes and alert boxes but im sketchy on how to give them cancel buttons..
Best response
What you need to do is include the null argument type for your input() to mark it as optional. Because you also want it to have the text type (it has it now by default), you can combine the text and null options using the pipe character(|):
var/new_name = input ("Please choose a name for your property", "Name Land") as text|null
if(new_name)
P.property_name = new_name


The null argument type will cause the input box to have a cancel button. If the user presses it, input() will return null.
ooohh okay! using the null argument worked! thank you! :D