ID:157337
 
            verb
BuyStock()
set hidden=1
var/amount=winget(src,"Franchises.stockinput","text")
var/type=winget(src,"Franchises.franchiselabel","text")
var/stock="src.store.[type]stock"
src << "[stock]"
stock+=text2num(amount)


I know that the above code is wrong, but how do i go about making it so that i don't have to code in the stocking of each franchise separately and make it so that i only need a few lines of code vs. a lot.

The variables im trying to edit are store.nike, store.applestock, etc. store being mob/var/store/store, going to a datum.

Arcticblast wrote:
>           verb
> BuyStock()
> set hidden=1
> var/amount=winget(src,"Franchises.stockinput","text")
> var/type=winget(src,"Franchises.franchiselabel","text")
> var/stock="src.store.[type]stock"
> src << "[stock]"
> stock+=text2num(amount)
>

I know that the above code is wrong, but how do i go about making it so that i don't have to code in the stocking of each franchise separately and make it so that i only need a few lines of code vs. a lot.

The variables im trying to edit are store.nike, store.applestock, etc. store being mob/var/store/store, going to a datum.


an associative array so that you can call stock["Nike"] seems to be what your looking for. If I am wrong or you don't understand please explain what you are trying to do a little more as I'm trying to figure out what you are really asking for.