ID:155634
 
I was reading the DM guide and when certain examples of code were given that included var/something in a verb or proc, i was confused as to why it was included. ex.

obj/portal
New()
view() << "A shimmering portal appears!"
view() << 'portal.wav'
mob/DM
verb
make_portal(NewName as text)
-> var/obj/portal/P = new/obj/portal(usr.loc)
if(NewName) P.name = NewName

If you can please clarify this.
obj/portal
New()
view() << "A shimmering portal appears!"
view() << 'portal.wav'
mob/DM
verb
make_portal(NewName as text)
-> var/obj/portal/P = new/obj/portal(usr.loc)
if(NewName) P.name = NewName


There are multiple reasons as to why create a var in a verb/proc. For that, it is to signify the creation of the Portal Object on the user of the verb.
(I think! Please correct me if I'm wrong :) )

You can also do something like this.

            var/A = winget(usr,"New_File.Name","text")//For Interface Purposes, I have it so that A will be whatever the "text" is.
if(length(A)>=20)//You can't do that in this type of text string, or at least I don't think.
alert(usr,"Error: Your name may not be more than Twenty(20) Characters.")
return


It's basically like using a "Let statement" in Math, I guess...
Defining a variable as a type is known as typecasting a variable. This lets you access specific variables that are relevant only to a specific object type.