I am trying to create a Batch Game, where it has an inventory similiar to Skyrim, Oblivion, and other well known Games similiar. The ides is that there is not a fixed number of Inventory slots, but rather, the game creates a new slot if the existing slots are occupied. I already know how to make the game check for them, ish.
if '%item1%'=='blank' (set item1=%item%) else (if '%item1%'=='%item%' set /A item1qua=%item1qua%+1)
if '%item2%'=='blank' (set item2=%item%) else (if '%item2%'=='%item%' set /A item2qua=%item2qua%+1)
I also dont know how to create a batch script that changes the number each time until the inventory slot is found as blank. Then the Game has to save all the Inventory slots when done. My current method is this:
( Echo @echo off
Echo set item1=%item1%
Echo set item1qua=%item1qua%
Echo set item2=%item2%
Echo set item2qua=%item2qua%
Echo set item3=%item3%
Echo set item3qua=%item3qua%
Echo set item4=%item4%
Echo set item4qua=%item4qua%)>>%playername%.bat
The term "qua" simply refers to the Quantity. I have tried this code:
set num=1
:inv
if '%item%num%%'=='blank' (set %item%num%%=%item% && goto next) else (set /a num=%num%+1)
goto inv
In short, this would expand the inventory as the player gets more items. The items would have a weight, just like in Elder scrolls and other games, I want to add that sacred annoyance to players (hehe), however, I would also want the code to remove the extra 'blank' itemslots, without leaving a gap in the numbering system, example: item1, item2 item4, item7, item8
My previous method was to copy an existing .bat file with thw item data on form the mother folder, and place it in a folder elsewhere which the player could veiw their items using the dir command. As you can imagine, not very productive.
My second method was more in the Alpha stage of the game, when it was basically a life simulator, which sort of got abondoned, but left in the game folder just incase i picked it up again:
>>Users\%fname%.bat Echo set weed=%weed%
>>Users\%fname%.bat Echo set money=%money%
>>Users\%fname%.bat Echo set water=%water%
>>Users\%fname%.bat Echo set lighters=%lighters%
>>Users\%fname%.bat Echo set cigarettes=%cigarettes%
>>Users\%fname%.bat Echo set lightbulbs=%lightbulbs%
EDITS
Thanks to the link provided by Chris Schaller, I found a Code that could work, and edited to what I needed.
@echo off
set len=11
set obj[0]=Gold
set obj[1]=Silver
set obj[2]=Sword
set obj[3]=Knife
set obj[4]=Greenfelt
set obj[5]=Amulet
set obj[6]=Chickenleg
set obj[7]=Necklace
set obj[8]=StolenItem
set obj[9]=GoldIngot
set obj[10]=Statuette
set obj[11]=Seeds
set i=0
:loop
if /i %i% equ %len% goto :eof
for /f "usebackq delims== tokens=2" %%j in (`set obj[%i%]`) do (
echo %%j
)
pause
set /a i=%i%+1
goto loop
The code works good for some aspects, however how would I allow obj[0] increase each time?