ID:1905130
 
(See the best response by Ter13.)

Problem description:
So, I've been working on a basic shop keeping system, where products are kept out on the shelf, you double click them, it checks to see if they are in a /area/shop area and then continues with a pretty basic, run of the mill BYOND shop.

It all works fine. But I noticed world Repop() only replaces stuff that is destroyed, not simply moved. What is the best way someone would suggest restocking these vendor tables?

Best response
IMO, the shop items shouldn't be moved at all. You can handle all of the restocking logic yourself quite easily if the object is consistent:

mob
var
swiggityswag
proc
PayMonies(cost)
if(swiggityswag>=cost)
swiggityswag -= cost
return 1
return 0
obj
shopware
var
stock = 1
max_stock = 20
restock_time = 100 //ten seconds
item_type
cost
proc
Restock()
if(!stock)
invisibility = 0
stock = min(max_stock,stock+1)

Purchase(mob/m)
if(stock&&m.PayMonies(cost))
new item_type(m)
if(stock--==max_stock)
RestockLoop()
if(!stock)
invisibility = 101

RestockLoop()
set waitfor = 0
while(stock<max_stock)
sleep(restock_time)
Restock()

DblClick(location,control,params)
Purchase(usr)

New()
if(istext(cost)&&str_ends_with(cost,"%"))
var/obj/item/i = new item_type()
cost = max(ceil(i.value * (text2num(cost)/100)),1)
overlays += i
else if(cost==null||!isnum(cost))
var/obj/item/i = new item_type()
cost = i.value
overlays += i
else
overlays += item_type
if(!stock)
invisibility = 101
if(stock<max_stock)
RestockLoop()
..()


Just set item_type to the type of item you want to sell, adjust stock and max_stock to your liking, and set cost to X amount of money. This way, you can have shops that have varying prices for stuff.

EDIT: I also added the ability to set the price to a percentage of the item's default value by setting the cost to a text string like so: "50%" or "200%". If the cost is null, it'll set itself to the default value of the item.
Games that make use of Repop() often like to copy an item and destroy it when it's first picked up. Personally I've never been a big fan of Repop(), as it's an all-or-nothing proposition.
I don't like Repop() at all. It's great for round-based games with static layouts, but it's really just better to handle trivial stuff like this yourself.