ID:169762
 
Seen in Shadowdarke's tutorial all about statpanels, and in the section about hiding statpanels, how would you specify the statpanel you wish to hide?

mob
var
inventory_panel = 1
verb/inventory()
inventory_panel = !inventory_panel // toggle the value on or off
if(inventory_panel)
src << "Inventory opened."
else
src << "Inventory closed."
Stat()
if(inventory_panel && statpanel("Inventory"))
stat(contents)


Could you change 'inventory_panel' to what ever panel you choose?

ya i don't see why not as long as you change all the vars. so if you haev stats you could use stats_panel = 1. not 100% sure tho.
Rahowa wrote:
Seen in Shadowdarke's tutorial all about statpanels, and in the section about hiding statpanels, how would you specify the statpanel you wish to hide?

> mob
> var
> inventory_panel = 1
> verb/inventory()
> inventory_panel = !inventory_panel // toggle the value on or off
> if(inventory_panel)
> src << "Inventory opened."
> else
> src << "Inventory closed."
> Stat()
> if(inventory_panel && statpanel("Inventory"))
> stat(contents)

Could you change 'inventory_panel' to what ever panel you choose?

There are two ways you could go about it. In BTG, I use a list that tracks which statpanels a player has open. Players can have any number of panels (I never tested the upper limit) and the display of those panels can reflect what appear in them (a different Stat() proc for each atom type, if you like). The Group Member Stat Panels section of that article demonstrates this method.

A more resource friendly but slightly harder to understand method would be to use bitflags. It limits you to 16 hardcoded panels, but for most games, that's plenty.
#define INVENTORY_PANEL 1
#define SPELL_PANEL 2
#define CHEESE_PANEL 4

mob
var
panel_flags = 0 // currently open panels
verb/TogglePanel(panel_name = "" as text)
var/flag
if(!panel_name)
panel_name = input("Which panel would you like to toggle?","Toggle Panel") as \
null|anything in list("Inventory", "Spells", "Cheese")
switch(lowertext(panel_name))
if("inventory") flag = INVENTORY_PANEL
if("spells") flag = SPELL_PANEL
if("cheese") flag = CHEESE_PANEL
if(!flag) return // aborted or invalid panel name
if(panel_flags & flag)
panel_flags &= ~flag // clear the flag
src << "[panel_name] closed."
else
panel_flags |= flag // set the flag
src << "[panel_name] opened."

Stat()
if(statpanel("Stats"))
stat(panel_flags)
if((panel_flags & INVENTORY_PANEL) && statpanel("Inventory"))
stat(contents)
else if((panel_flags & SPELL_PANEL) && statpanel("Spells"))
stat("Spell Display goes here.")
else if((panel_flags & CHEESE_PANEL) && statpanel("Cheese"))
stat("Why would you have a panel devoted only to cheeses?")


Yes, you could made a separate flag varioable for each panel, but that is a terribly wasteful method. You don't need an entire variable just for a single flag.
In response to Shadowdarke
Great, thanks. Only one more question, is there to do that for verb panels?
In response to Rahowa
Rahowa wrote:
Great, thanks. Only one more question, is there to do that for verb panels?

Verb panels are a little more limited. http://www.byondscape.com/ascape.dmb/ Shadowdarke.2003-0322/#vrboff show the various ways you can turn them on and off.