ID:149952
![]() Jan 19 2002, 12:56 pm
|
|
In my houselib (although it's a lib, it's just for my game :p), I'm trying to create an array of icons. Theres an icon for a vacant house/apt/etc, and one for occupied. When you say HOUSELIB_AddRealEstate(x,y,l,"name",cost,0), I want to incrament HOUSELIB_RealEstate_Count (+= duh :p), and then have HOUSELIB_RealEstate_Icons[HOUSELIB_RealEstateCount] set to one or the other icon. And of course place it. I've spent hours, and looked through everything, but so far no poptato. Basically I need to be pointed in the right direction to learn how to create an array of icons. I've tried var/list/icon/something, and var/icon/something[] but so far nothing...
|
![]() Jan 19 2002, 3:40 pm
|
|
Does anyone have a clue how to create an array of icons, like instead if TestIcon, you have TestIcon[3] or TestIcon[4]?
|
Dreq wrote:
Does anyone have a clue how to create an array of icons, like instead if TestIcon, you have TestIcon[3] or TestIcon[4]? Create a list and put icons in it. Did that not work when you tried it? |
Nope I spent 4+ hours on it (really, I did!), I've tried every practical way... BYOND seems to be screwy with arrays... I don't do Enemy["HP"]=53, I do Enemy.HP[EnemyNum]. And I will do that for the icons too... I have tried:
var/list/icon/Bla but when I say Bla.icon='something' it chokes on the '.'.... And it gives simular results when I say: var/icon/Bla[30] and try to do Bla.icon[30], and bitches like hell if i try to say Bla[30].icon.... I wish they did python-style arrays ;) |
Forgive my ignorance if I'm wrong, but I'm pretty sure that BYOND doesn't have 'arrays' so to speak. My personal definition of an array is that it's sort of.. well-defined. A certain size, all elements in it a certain data type. I find BYOND's lists far more fun and flexible. You can define a size, but that doesn't mean much when you can change it at will.
As for your problem, what you're saying isn't quite clicking. Firstly, what use would a one dimensional array be? You can't store location, only icon state. Unless you're using the index as the location, which doesn't allow for much flexibility.. methinks it'd waste space as well. Not much, but every byte counts.. After that, why are you storing actual icons? Why bother? Why not just have one large icon file, and a number of icon states. You can just store the icon state in the list and save yourself some trouble even bothering with icons. Of course, why are you even bothering with RealEstate_Count? You could just use RealEstate_Icons.len. If you still choose to do it that way, that is. Of course, I haven't slept in over two days, and may be rambling incoherently. Just my thoughts. --Tarmas. |
I am using icon states, but they are still seperate images, so I call them as seperate icons. But as far as one dementional arrays, consider these sippits (mind you they don't work, but it's what I got so far):
#define MAXREALESTATE 50 This will allow me to index the realestates, and therefore be congruant with my database, which I can modify via PHP so the site will be up to date with the actuial game. Anyway, when someone moves in, it will change the icon from the Vacant icon, to the Occupied icon. And vice versa. That's the use for it. |
Lots of commenting. The sure sign of a diseased mind.
Anyway. I considered it. I still don't know what you're asking. I also don't see anything from the code you gave me. All it seems to be doing is putting in some things to a list'o lists, creating a blank object with your vacant house icon state, and slamming it down on the map. I wasn't even sure you could use new() like that.. While I'm at it, I don't know if you can do this: RealEstate[5][RealEstateCount]="Vacant" Or not. What, precisely, is it setting to "House Vacant"? RealEstate[RealEstateCount] is a list.. As for your usage of new(), I looked it up and the example that seemed closest to it to me is: new(usr.icon,icon_state = "",dir = EAST) Which I think should turn yours into new('DreqSets.dmi', icon_state = "Vacant House", DIR = SOUTH). The DIR may or may not be optional.. haven't tried it. So, uh.. can you clarify your question now that we've seen the code? --Tarmas. P.S. RealEstateCount+=1? Why not ++? P.P.S. I seem to compulsively putting a blank line after every sentence.. Weird. |
Dreq wrote:
[snip] var/icon/RealEstateSigns[MAXREALESTATE][snip] DM has no concept of arrays as such. There are only lists. Lists can hold any kind of item. Use: var/list/RealEstateSigns[MAXREALESTATE] Then just add icons. |
Whoops. I completely skipped how he was defining them..
But.. er.. yeah. Oh no. I'm wasting forum space again, aren't I? We should show post count on these boards just for people like me.. --Tarmas. |
Dreq wrote:
but when I say Bla.icon='something' it chokes on the '.'.... And it gives simular results when I say: Instead of trying to access Bla[30].icon, store Bla[30] in a variable of the appropriate type and access the icon through it. var/mob/critter/C = Bla[30] C.icon = 'squiggly.dmi' |