[Tutor] Game programming - inventory management (was Help)

Bob Gailer bgailer at alum.rpi.edu
Tue Nov 28 21:40:52 CET 2006


Please use a meaningful subject line. Many of us try to follow 
"threads", and "help" does not help.
I have provided one for this case.

Mohammed H. Hafeji wrote:
> Need some help in python.
>  
> How do i make the user choose wheter or not to pick it up? (i can do 
> picking up an item from a list):
> //
> /*objectsCarried = []*/
> /**/ 
> /*inventory = ['bat']
> lengthOfInventory =len(inventory)*/
> /**/ 
> /*print 'The room holds:'*/
> /**/ 
> /*for item in range(lengthOfInventory):
>     print item, inventory[item]*/
> /**/ 
>
> /*numberChosen = int(raw_input('use the number to pick up an item '))*/
> /**/ 
> /*objectChosen = inventory[numberChosen]*/
> /**/ 
> /*objectsCarried.append(objectChosen)
> inventory.remove(objectChosen)*/
> /**/ 
> /*print 'you are carrying '
> for item in objectsCarried:
>     print item*/
> /**/ 
> /*print*/
> /**/ 
> /*print 'The room now holds:'*/
> /**/ 
> /*for item in inventory:
>     print item*/
>  
> But i cant do when u have a choice to pick up or not.
>  
> Also if not too much trouble then how can i do:
>  
> IF the user picks the bat up then when he comes across the vampire 
> then he kills it, but if he hasnt pickd up the bat then he dies?
>  
> Thanks in advance
>  
> P.S. Could u plz email sum code
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>   


-- 
Bob Gailer
510-978-4454



More information about the Tutor mailing list