Display Collection Management script?

Hello all, I have a display case in the museum that holds all of my stuffed whatnots on one shelf, and a bunch of random crap on another. I was wondering if there was a way to script the addition of all of my stuffed animals to my display case without having to know a list of all stuffed animals. Any ideas?
 

jasonharper

Developer
A couple of possibilities that would avoid having an explicit list of all stuffies:

1. Loop over all items in your inventory, and move anything with a name containing "stuffed" unless it's on a list of exceptions (stuffed spooky mushrooms come to mind).

2. Loop over all items in your inventory, and move anything with a non-zero amount in your display case already. This will also move stuff that's on your shelf of "random crap", there's no script access to shelving data.
 

zarqon

Well-known member
3. Assuming the stuffies have contiguous item numbers (or at least several contiguous ranges), do (a) for loop(s) on the item numbers of the stuffies, moving any in your inventory to your display.
 

noxious

New member
2. Loop over all items in your inventory, and move anything with a non-zero amount in your display case already.

That would be like cross checking inventory against dc, without knowing or specifying items or item numbers, right? Can I make it to move anything with a zero amount? It would be an if loop i assume, but how do you specify an ambiguous inventory? All the examples I've seen call for a specific item to be named.
 

zarqon

Well-known member
You would foreach get_inventory(), checking (display_amount() > 0) to decide whether to cli_execute(display put * item).
 

noxious

New member
sigh... of course it would be something complicated. What is the command to check the display amount? I found int display_amount( item it ) on the wiki somewhere. Don't think that's it though, but I have no better ideas. And how does the flow go? Simplified --foreach get_inventory(), if int display_amount( item it ) > 0), display 1, else, display 0? Am I somewhat in the ballpark at least?
 

Alhifar

Member
Pretty close, something like:
Code:
int[item]inv;
foreach it in inv
{
if( display_amount( it ) > 0 ) cli_execute( "display put * " + it.to_string() );
}

Mind you, that's completely untested, but it's at the very least the correct idea.
 

Rinn

Developer
Code:
void main()
{
    int [item] inventory = get_inventory();

    foreach i in inventory
    {
        if (display_amount(i) > 0)
        {
            put_display( item_amount(i), i );            
        }
    }
}
 

noxious

New member
Thanks for all the help guys! One last question, how can I cange this to display only one of each item? I tried to change both i's after put_display, but they both say invalid parameter for function. I don't think I'm quite understanding keys right (that's what the i is, right?)


Code:
void main()
{
int [item] inventory = get_inventory();

foreach i in inventory
{
if (display_amount(i) < 1)
{
put_display( item_amount(i), i );
}
}
}

BTW: how do you post code in its own box?
 

Rinn

Developer
Code:
void main()
{
    int [item] inventory = get_inventory();

    foreach i in inventory
    {
        if (display_amount(i) > 0)
        {
            put_display( item_amount(i), i );            
        }
    }
}

In this case i is an item. So in the line 'put_display( item_amount(i), i );' the first parameter is the number of items to move, and the second parameter is which item you're moving. If you wanted to put only one item the line would instead be 'put_display( 1, i );'
 

Bale

Minion
BTW: how do you post code in its own box?

You use code tags. They look like this: [code] [/code]. They can only be seen when you are editing a post. If you still don't understand, then quote this post and take a look at what I typed below this:

Code:
void main() {
	for i from 1 upto 10
		if(i == 1) print("Kiss me once.");
		else print("Kiss me "+ i +" times.");
}

In this quote, you should be able to clearly see the code tags I'm using.
 
Last edited:

noxious

New member
In this case i is an item. So in the line 'put_display( item_amount(i), i );' the first parameter is the number of items to move, and the second parameter is which item you're moving. If you wanted to put only one item the line would instead be 'put_display( 1, i );'

Ah I was close. And makes alot more sense now, thanks.




You use code tags. They look like this: [code] [/code].

In this quote, you should be able to clearly see the code tags I'm using.

Cool that you gave an example instead of just an explanation, I got to see noparse work too. :)
 
Top