Re: The Inventory
Status: Alpha
Brought to you by:
cwalther
|
From: James C. W. <jfc...@ya...> - 2012-01-06 22:33:15
|
Okay, thanks for making that clearer:) ________________________________ From: Christian Walther <cwa...@gm...> To: pip...@li... Sent: Friday, January 6, 2012 4:52 AM Subject: Re: The Inventory James C. Wilson wrote: > However, for the future, I'm not aware of what the list index of the > object is, or how to find it. If it's the number that the inventory > table assigns the object Yes, "index" is a common term for the consecutive numbers that the "slots" of a list or array are addressed with. Lua by convention starts counting at 1, most other programming languages start at 0. If you don't know where in the list the object is, then you just search for it. The shortest way of doing that I can find right now is index = table.foreachi(state.inventory, function(i, v) if v == "TVCable" then return i end end) although you can also spell it out as for i = 1, table.getn(state.inventory) do if state.inventory[i] == "TVCable" then index = i break end end > wouldn't that be biased toward the order in which the player picks up > items? Yes, the inventory keeps objects in the order they were picked up. If you don't like that and would rather have them e.g. in a fixed order, you need to change the inventory code. -Christian ------------------------------------------------------------------------------ Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex infrastructure or vast IT resources to deliver seamless, secure access to virtual desktops. With this all-in-one solution, easily deploy virtual desktops for less than the cost of PCs and save 60% on VDI infrastructure costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox _______________________________________________ Pipmak-Users mailing list Pip...@li... news://news.gmane.org/gmane.games.devel.pipmak.user https://lists.sourceforge.net/lists/listinfo/pipmak-users |