Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Sun Aug 07, 2011 9:52 am   

Package toggle?
 
Is there a way to toggle weather or not a package is enabled in a given window?

I have been having this setting tend to remain unsaved if the system turns off suddenly, which becomes an issue with lots of packages with buttons in them when shared.
I can think of a workaround, but i need to figure out the toggle.

#EVENT onLoad {
$package="such and such"
$totWin=%numitems(%names)
$thisWin=2
#LOCAL $window
#WHILE ($thisWin!>$totWin) {
$window=%item(%names, %thisWin)
#CALL %pkgState($window, $package, %boolean) //contrived command
$thisWin=($thisWin+1)
}}
_________________
Discord: Shalimarwildcat
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Aug 07, 2011 4:13 pm   
 
Check out the %packages function. It doesn't do exactly what you want, but you could easily write a user-defined function for a toggle.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Sun Aug 07, 2011 8:02 pm   
 
So... to reset it...
#call %packages( $window, %null)

Alright, I can make that work.
_________________
Discord: Shalimarwildcat
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Aug 07, 2011 8:45 pm   
 
You probably wouldn't want %null, though, you just want to remove that one package, not all of them. Try something like #CALL %packages($window,%delitem($package,%packages(%window)).
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Aug 07, 2011 8:56 pm   
 
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <func name="pkgState" copy="yes">
    <value>#IF (!$window OR !$package) {
  #SAY "Syntax: #CALL @pkgState(window, package, optional 0 or 1)"
  #EXIT
  }
#IF %null( $boolean) {#IF %ismember( $package, %packages( $window)) {$boolean = 0} {$boolean = 1}}
$packages = %packages( $window)
#IF $boolean {#CALL %packages( $window, %additem( $package, $packages))} {#CALL %packages( $window, %delitem( $package, $packages))}</value>
    <arglist>$window,$package,$boolean</arglist>
  </func>
</cmud>
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Sat Dec 17, 2011 7:31 am   
 
Finally got around to implementing this, and so far this looks like it might work... lets hope it can counteract the windows force closing CMUD issue from another thread.
Code:
<event event="onLoad" priority="360" id="37">
  <value>$list=%names
#CALL %pop($list)
#FORALL $list {#CALL @pkgState(%i, %class, 0)}</value>
</event>
_________________
Discord: Shalimarwildcat
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net