1. as of now, when someone buys something, it removes it from the shop and adds it to the player. this is fine, but how do i make it so that it "respawns" if you like, in the shopkeeper inventory after a certain time, and if thats not possible just gives the player a new one without removing the one in the shop.
2. is there a more efficient way to do this?.:
heres the code:
mob/NPC
Store_Keeper
icon= 'NPC.dmi'
icon_state = "Shop"
npc = 1
density = 1
New()
var/list/adding = list()
var/obj/raft/o1 = new/obj/raft
o1.suffix = "[o1.buyprice]"
o1.inshop = 1
adding+= o1
var/obj/raft/o2 = new/obj/raft
o2.suffix = "[o2.buyprice]"
o2.inshop = 1
adding+= o2
var/obj/raft/o3 = new/obj/raft
o3.suffix = "[o3.buyprice]"
o3.inshop = 1
adding+= o3
var/obj/Meat/o4 = new/obj/Meat
o4.suffix = "[o4.buyprice]"
o4.inshop = 1
adding+= o4
var/obj/Meat/o5 = new/obj/Meat
o5.suffix = "[o5.buyprice]"
o5.inshop = 1
adding+= o5
var/obj/Meat/o6 = new/obj/Meat
o6.suffix = "[o6.buyprice]"
o6.inshop = 1
adding+= o6
spawn(2)
contents+=adding
What you could do is make differing types of these objects, since I noticed you have two objects with three different prices:
Then you could populate the shopkeep's inventory loads easier:
Causing respawning objects can be done by using the bought object's type:
And you could also make some objects infinitely spawning while others can only exist once or spawn a limited amount of times doing something like this:
Though you have to be careful if you allow varying quantities of items to be bought, since what I provided for example above only covers buying items one at a time.