ID:147696
 
Lets make up an illustration here.

There are huts, which can contain objects. The world could have anywhere from 100 to 500 huts at a time.

There are also sticks. There's quite a variety of different kinds of sticks, somewhere in the area of a few dozen to several hundred different kinds.

Each hut can hold one of every kind of stick. So if there are 200 kinds of sticks, each of the 500 huts can hold 200 sticks.

That's 100,000 sticks. More than BYOND can handle.

So I tried an alternative approach.

Since a stick type is a static object, the variables of which do not change throughout the game, I decided that I could create a list storing each of the stick types, then just refer to that list whenever I needed information about a specific stick type.

var/list/stick_list = list("stick type" = new /stick/datum object)

Now all 200 stick types are stored in one list, so there are 500 huts and only 200 sticks. 700. A much more managable number.

Now here's the problem.

Each hut has two statpanels. One statpanel is supposed to allow the player to gather new sticks, and the other statpanel shows which sticks are currently in the Hut.

But, here's a catch. The sticks in the hut need to have a switch that determines whether or not they're in the hut's fireplace. So ideally I'd want to click on a stick type from the hut statpanel and, perhaps modifying the associated value in the list containing all the sticks in the hut, determine whether the stick is in the fireplace or not.

So, from the Gathering statpanel, clicking on a stick type should move it to the Hut statpanel. From the Hut statpanel, clicking on the stick type should determine whether the stick is in the fireplace or not.

Trouble is, there doesn't seem to be any way to make this work. So, help!
one solution (something i've been meaning to try out, but real life keeps getting in the way) might be to store all the "sticks" in a MySQL database, using a unique key (let's say "stickID") to identify each stick. assuming that you track each stick's location in the world map, you could have a near-infinite number of sticks in the world (ok, actually whatever the max numbers of records a MySQL database can have... well over several GB of records), you would only need to deal with sticks that were actually in a player's view (oview?), or personal inventory. so i guess the only problem i see that may arise is if you exceed the max number of objects that BYOND can handle in the player's field of view.

at any rate, your idea (var/list/stick_list...) might work just fine, but i think a database-object-tracking solution could untether you from most object limitations.

now your bit about statpanels- i have no clue! :)

(digi reminds himself to set up the digitalBYOND server with MySQL once DSL returns)

(digi also reminds himself to actually learn BYOND programming)
In response to digitalmouse
digitalmouse wrote:
now your bit about statpanels- i have no clue! :)

The statpanel bit was more the issue, since while it may no be the best approach ever invented, the stick list part works just fine.

But unless I can come up with a decent workaround to get the statpanels working, I'll have to consider it another BYOND restriction causing a dent in my project.
In response to Foomer
The Click() proc has a "location" argument which specifies where it was clicked. When the object is clicked in a statpanel, the location argument is set to the name of that statpanel.

So:

<code>obj/stick/Click(Location) if (Location=="Gathering") //Gather sticks else if (Location=="Hut") //Burn sticks</code>
In response to Crispy
I could have the clicking supported by displaying the stick list contents in each statpanel, with only or without the sticks that the hut currently contains. But I'd still need a way to display graphically whether each stick type is in the fireplace or not. (Something like suffix would be nice, but I can't use that without changing the suffix for every version of that stick type in the universe.)
In response to Foomer
Use two stick lists. One for normal sticks, one for burning sticks. The Gather panel obviously only accesses the normal sticks. Clicking a normal stick in the Hut panel removes that stick from the hut and replaces it with the corresponding stick from the burning list. There are now 900 objs (500 huts + 200 sticks x 2), but that's still a managable number.
In response to Shadowdarke
Say, that's a good idea. Much better than the one I was tangling with of creating new instances of each stick type for the players to manage whenever there is a player there to manage them, and removing them when the player leaves.
In response to Foomer
If all the sticks are the same...
In the hut why not just be only allowed to have one stick of each 'type'. Then when sticks are added or removed it increments/decrements an amount counter on the sticks. You could have a virtually infinite number of sticks. Also if you then et a new type of sticks you just create a new object (then move it into the hut). It makes it versatile too (It would check to make sure that if no sticks of its type are in the hut it will then move itself into the hut.)