ID:1414440
 
(See the best response by Kaiochao.)
Code:
obj
Paper_Machine
icon = 'PaperMac.dmi'
desc = "Oohh... buttons, I wonder what they do?"
density = 1

verb
Start(N as num)
set src in view(1)
desc = "Type how many papers you want to make."
usr << "\blue*BEEP*"
view() << " \i\red The machine hums and spits out paper!"
Paper(N)
Examine()
set src in view()
desc = "Choose what to examine!"
usr << "It is shiny and pretty"
proc/Paper(N)
var/Papercnt = 10 //How many papers the machine can hold.
loop:
if(N == 0)
return
if(Papercnt == 0)
view() << "\red The machine didn't spit out any paper!"
return
var/obj/O = /obj/Paper
O.loc = src.loc
N = N-1
goto loop


Problem description:
I can't figure out how to create a new paper object at the location of the printer. (What the Paper Machine). The code compiles at compile-time but at run-time it fails, saying it cannot modify the location of O.loc (AKA Paper). This is probably a simple fix, please help!

Best response
var/obj/O = /obj/Paper

// should be
var/obj/O = new /obj/Paper

// or better yet
var/obj/Paper/paper = new (loc)

// /obj/Paper is a type, not an object

That code is a mess, lol.
/obj/Paper_Machine
icon = 'PaperMac.dmi'
desc = "Oohh... buttons, I wonder what they do?"
density = 1

verb/Start(var/N as num)
set name = "Start Printing"
set category = "Printer"
usr << "\blue*BEEP*"
view() << " \i\red The machine hums and spits out paper!"
for(var/i=1, i<=N, i++)
new /obj/paper(src.loc)
//This implies you have an object "paper" (/obj/paper)
Sorry, I thought the new proc ran a statement when a new object was created, thanks a bunch!
Thanks also @Drache but I care more about what the code actually does at this moment than the efficiency (until I get better at DM) to avoid mistakes.
In response to Vivalas
Lowercase "new" (also highlighted, blue by default) is an instruction. It's different from the New() proc that everything has.
Yours commented
obj
Paper_Machine
icon = 'PaperMac.dmi'
desc = "Oohh... buttons, I wonder what they do?"
density = 1
verb
Start(N as num) // var/N needed
set src in view(1)
desc = "Type how many papers you want to make."
usr << "\blue*BEEP*"
view() << " \i\red The machine hums and spits out paper!"
Paper(N)
Examine()
set src in view() //In view what? This sets it to all in sight of the paper machine.
desc = "Choose what to examine!"
usr << "It is shiny and pretty"
proc/Paper(N)
var/Papercnt = 10 //How many papers the machine can hold.
loop: //Don't use goto
if(N == 0)
return
if(Papercnt == 0) //Why would papercnt be 0? Nothing sets it to 0 here.
view() << "\red The machine didn't spit out any paper!"
return
var/obj/O = /obj/Paper
O.loc = src.loc //This seems to be the problem if you don't have "O" defined properly
N = N-1 //You can also just use N-- to decrement it or subtract by 1.
goto loop //Don't use goto


Mines uncommented
obj
Paper_Machine
icon = 'PaperMac.dmi'
desc = "Oohh... buttons, I wonder what they do?"
density = 1
verb
Start(N as num)
set src in view(1)
desc = "Type how many papers you want to make."
usr << "\blue*BEEP*"
view() << " \i\red The machine hums and spits out paper!"
Paper(N)
Examine()
set src in view(1)
desc = "Choose what to examine!"
usr << "It is shiny and pretty"

proc/Paper(N)
var/Papercnt = 10 //How many papers the machine can hold.
if(N>10)
N = Papercnt
while(N)
var/obj/O = new /obj/Paper
O.loc = src.loc
N--
I don't think we should be offering improvements without knowing what exactly the OP is intending for this object to do.

If you look a little closer, you might notice that the Papercnt variable in Paper() doesn't actually do/affect anything.
Hmm.. true. But judging from his comment I took that action. Still, seems like you're right though. Sorry.
Oh yeah thanks for the notice, as you may of guessed papercnt was intended to be how much paper the machine can hold. The machine wasn't really a printer though, it was a Paper_Machine (The machine doesn't print words to paper, it takes random crap and makes it into paper, which then gets written on, cuz it is paper lol). I didn't modify var/Papercnt because I was going to do that part later. :) Thanks for all the help!

EDIT: I mean how much "paper" is in the machine, gets increased when stuff is paperized, and gets decreased when paper gets manufacturinated. Also the
in view()
was set like that on purpose. People can tell (usually) that something is shiny and pretty from a distance.
In response to Vivalas
You'll want to move "var/Papercnt" out of the procedure if you want it to stay attached to the object. Currently, Papercnt is attached to the procedure, it's created and initialized every time that procedure is called, and it only exists inside the procedure. That way, you'll be able to access it (to read or modify it) in other procedures, like a "turn junk into paper" verb that would add to it.
Oh yeah, didn't notice that. Thanks!