ID:178335
 
Lets say i want a store that updates as it sells things, the store will buy and sell items to and from players, and as it does, the numbers and types of items will change, but the default items in store willl eventually respawn, i need this on a constantly updating style, is there any way to do it with the List()?
There's a tutorial or something on associative lists, search for it. It can explain them better than I could because there's an accompanying example. It's actually a buy thing too.

I reccomend doing it that way to track stock of items too. :-)

Search for:
Buy Script
RPG Buying
etc...
In response to ShadowWolf
ShadowWolf wrote:
There's a tutorial or something on associative lists, search for it. It can explain them better than I could because there's an accompanying example. It's actually a buy thing too.

Yup, that's one of Lummox JR's Dream Tutor articles on BYONDscape.
Ter13 wrote:
Lets say i want a store that updates as it sells things, the store will buy and sell items to and from players, and as it does, the numbers and types of items will change, but the default items in store willl eventually respawn, i need this on a constantly updating style, is there any way to do it with the List()?

Wow. This sounds a lot more complicated than a standard shopkeeper system. It's perfectly doable, though.

For this, you're probably going to need four lists: One for objects and their prices, another with the number of each such object you have, another for specific objects bought from players and their prices (unless you want to count those objects as just like every other one of the same kind--that is, don't factor in wear and tear, etc.), and another for the number you want to keep in inventory.

The last list is the big one. Essentially you'll want to set up a proc to handle the respawning for you, like this:
mob/shopkeeper
...

/*
This uses a list called stocklist, which is an associative
list, where stocklist[item]=number_to_keep_stocked.
instock[item] is the number in stock
*/

proc/ItemSold(itemtype) // just sold an item
var/obj/O=locate(itemtype) in stocklist
if(!O) return // don't bother to restock this
// notice O is in both stocklist and instock; it's the same object
var/restocktime=3000*(instock[O]--)/(stocklist[O]+1)
// items respond faster when demand is high
spawn(restocktime)
if(instock[O]<stocklist[O]) ++instock[O]

proc/ItemBought(itemtype) // bought from player
var/obj/O=locate(itemtype) in stocklist
if(!O) return
++instock[O]

More sophisticated systems could be devised, but hopefully that's a good start.

Lummox JR
"is there a way to do this with list()?"

Sorry, i just had to do that.

-Rcet
would you leave my posts alone chord? I know you are trying to bootleg my copy of Dark days, but you don't have to try to sell it!