ID:1868066
 
(See the best response by Pirion.)
How do I create a mob/verb that communicates with an obj/proc? Inter-relating a variable to (for example):
1. Create an object.
2. Name the object according to number of like-type objects Eg. Robot 1.

Here's the junk I'm working with:
world
mob=/mob/player


mob
player
icon = 'robot.dmi'



/* verb
Construct(robopads)
world << "A robotic landing pad has been born!"
new /obj/robo_pad(src.loc)
robopads ++
src.name = robopads */


turf
icon = 'turf.dmi'


obj
robo_pad
icon = 'robo_pad.dmi'
var/package
proc
born(var/am)
world << "initiating robo-pad setup.."
sleep(30)
world << "constructing robo-pad.."
src.icon_state = "a"
sleep(30)
world << "construction complete.."
am ++
src.name = "robo-pad" + "[am]"


-Delta0Zero2
Best response
To follow a consistent creation method, I'd say this would be a perfect time for a factory. You'd be able to name and setup the robo_pad, then pass back to the calling function to finish what it needs to do with it.

RobotFactory/RobotFactory = new()
RobotFactory
var
RoboPadNumber = 0;

proc
CreateRoboPad(location)
var/obj/robo_pad/robo_pad = new(location)
robo_pad.name = text("[] #[]",robo_pad.name, ++RoboPadNumber)
return robo_pad

mob/verb/CreateRoboPad()
var/obj/robo_pad/robo_pad = RobotFactory.CreateRoboPad(src.loc)
world << text("[] has been born!",robo_pad.name)


While you could also do this with a global variable, I tend to shy away from this due to the encapsulation that the factory provides over the variable and the create method.
I didn't realize people still used the text() proc, embedded expressions murdered that proc ages ago.
Thank you Pirion, I picked up a few tips:
1. ("[] [] []",1,2,3) //Which I'd seen in a Java/C++ textbook before.

I have a question regarding the defining of a variable whose child is the exact same for instance:
var/obj/robo_pad/robo_pad

Is that syntaxically legal even??
In response to Delta0Zero2
Yeah, no one uses
text("[], [], []", varA, varB, varC)
anymore, since you can just do
"[varA], [varB], [varC]".
In your first snippet, you use
src.name = "robo-pad" + "[am]"
where you could've used
name = "robo-pad[am]".

About variable declaration: the text after the last slash is always the name of the variable, and it has no effect on the type of the variable or the value it contains.
I'm just feeling a little overwhelmed.
In response to Nadrew
I think it feels cleaner to use the text proc, as you can easily see the values being passed in. Just a stickler I guess.
Yes, but to actually figure out what those values do you have to count the arguments. Just putting the variable into the string seems a whole lot easier to read in my eyes.
Embedded expressions are basically identical anyway. They both compile to the same thing. Without text() supporting non-constant strings, it's pretty pointless compared to embedded expressions, which are far easier to read.
Embedded expressions are basically identical anyway. They both compile to the same thing. Without text() supporting non-constant strings, it's pretty pointless compared to embedded expressions, which are far easier to read.

The only merit I ever saw to them was that they were more similar to what traditional C programmers expected prior to the standardization of string concatenation (C++ stdlib) via + operator overloading (or . operator overloading depending on language).
I'm starting to grasp these concepts wherein (atom/var)'s existence lives on.

world
mob=/mob/player


mob
player
icon = 'robot.dmi'
examine = "I am a child of the atom."


turf
icon = 'turf.dmi'
examine = "I am a child of the atom."


obj
robo_pad
icon = 'robo_pad.dmi'
examine = "I am a child of the atom."


atom
var
examine