ID:143265
 
Code:
        statpanel("Inventory")
for(var/obj/O in src.contents)
O.checkedyet=0
for(var/obj/O in src.contents)
if(O.checkedyet==0)
O.checkedyet=1
var/amount=1
if(O.suffix=="Equipped") goto alreadysuffixed
for(var/obj/E in src.contents)
if(O.type==E.type)
if(E.checkedyet) continue
amount++
E.checkedyet=1
O.suffix="[amount]"
alreadysuffixed
stat(O)

------------------------------------------------------
Repilcator
icon = 'Objects.dmi'
icon_state = "Replicator"
density = 1
verb
Replicate()
set src in oview(1)
switch(input("What would you like replicated?") in list("Hydrospanner","Other"))
if("Hydrospanner")
icon_state = "Replicator Activated"
sleep(3)
icon_state = "Replicator"
for(var/obj/Items/Hydrospanner/B)
src.contents += B
alert("Done")


Problem description:
I am trying to make a replicator, however the item i am trying to replicate is not going into the inventory, the top code is the inventory code i got to stack items, the bottom is the replicator, can you tell me what i am doing wrong?


You're trying to add something that doesn't exist. It needs to be created.

Repilcator
icon = 'Objects.dmi'
icon_state = "Replicator"
density = 1
verb
Replicate()
set src in oview(1)
var/newitem=input("What would you like replicated?")as anything in usr.contents)
if(isobj(newitem))
icon_state = "Replicator Activated"
sleep(3)
icon_state = "Replicator"
new newitem(usr)
alert(usr,"Done")
In response to Kaiochao2536
What i meant by replicator was, like a Star Trek replicator, do you know how i can make on of those
Naztexz wrote:
Code:
>       statpanel("Inventory")
> for(var/obj/O in src.contents)
> O.checkedyet=0
> for(var/obj/O in src.contents)
> if(O.checkedyet==0)
> O.checkedyet=1
> var/amount=1
> if(O.suffix=="Equipped") goto alreadysuffixed
> for(var/obj/E in src.contents)
> if(O.type==E.type)
> if(E.checkedyet) continue
> amount++
> E.checkedyet=1
> O.suffix="[amount]"
> alreadysuffixed
> stat(O)
>
> ------------------------------------------------------
> Repilcator
> icon = 'Objects.dmi'
> icon_state = "Replicator"
> density = 1
> verb
> Replicate()
> set src in oview(1)
> switch(input("What would you like replicated?") in list("Hydrospanner","Other"))
> if("Hydrospanner")
> New() icon_state = "Replicator Activated"
> sleep(3)
> icon_state = "Replicator"
> for(var/obj/Items/Hydrospanner/B)
> src.contents += B
> alert("Done")
>

Problem description:
I am trying to make a replicator, however the item i am trying to replicate is not going into the inventory, the top code is the inventory code i got to stack items, the bottom is the replicator, can you tell me what i am doing wrong?

hmmm
You're going to need to make a new instance of the item, so calling the New() proc at some point would be neccessary I think, to create the item chosen then toss it into inventory. I'm a newbie though, have a test in an hour if I had more time I could figure it out I'm sure, In the demo section there's a demo for creating a merchant, I'm sure that would give you the meat of code you would need to do what you wanted, or even the same code that allows you to create loot from a recently killed mob would work.

Mike