Rather than have a global for each, it would be easier/better to have 
a single global list to store the inventory for all players.  Here 
are two ways to do this.  First, if you just want to do this by 
player number, then you could have a single list where each element 
in the list is your property list:

global gnumPlayers
global gInventoryList

gInventoryList = []  -- initialize to an empty list
repeat with i = 1 to gnumPlayers
    append(gInventoryList, [:])  -- append an empty prop list for each player
end repeat

Then you can reference the inventory for each player by number.  For 
example, if there is a player three, then player three's inventory 
list could be retrieved by doing this:

   thisPlayersInventoryList = gInventoryList[3]


However, if each player hhas a "name", and you want to reference 
their inventory by their name, then you can built a property list 
like this.  I'll assume that you have the players names in some 
global list:

global gPlayerNamesList
global gInventoryList
global gNumPlayers  -- must be equal to count(gPlayerNamesList)

gInventoryLit = [:]  -- initialize to empty property list
repeat with i = 1 to gnumPlayers
    thisPlayerName = gPlayersNamesList[i]
    addProp(gInventoryList, thisPlayerName, [:])
end repeat

Then when you want to retrieve the inventory list for a particular 
player, you use the player's name as an index into the gInventoryList:

   thisPlayersInventoryList = gInventoryList["JohhnyBoy"]

Irv



At 4:50 AM +0000 2/11/02, Nmuta Jones wrote:
>Hello
>
>This is something that seems fairly simple...but I'm not doing it right.
>
>I am building a simple game where the user enters number of players 
>which is stored as gnumPlayers.
>
>then a repeat loop is used to set up several things for each player, 
>depending on how many players there are. everything in the loop 
>worked until I later tried to add an empty prop list for each 
>player. Each list is to have a unique name concatenating the player 
>number with the list name. What I WANT is a bunch of empty prop 
>lists named ginventorylist1, ginventorylist2, ginventorylist3, etc.
>
>here is the part of the code that needs fixing:
>
>global gnumPlayers--(this derived from text user input earlier.)
>  repeat with i= 1 to (gnumPlayers)
>    global (ginventorylist & i) = [:]
>
>end repeat
>
>end
>

-- 

Lingo / Director / Shockwave development for all occasions. 
          
   (Home-made Lingo cooked up fresh every day just for you.)
[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to