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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Dec 02, 2007 2:04 am   

Problem with variable...
 
Ok, this one is boggling the mind here.

Code:

#TRIGGER {You have (%d) gold coins.} {
  #IF (%1 = @goldgiven) {
    #IF (%ismember( @goldfrom, @players) < 1) {
      say You're not even part of this game!
      give @goldgiven coin @goldfrom
      #t- goldcheck
      #ABORT 1
      }
    #loop @numplayers {
      #IF (%i = %ismember( @goldfrom, @players)) {
        #IF (@{%concat( "player", %i, ".bet")} > 0) {
          say @goldfrom you've already bet.
          give @goldgiven coin @goldfrom
          #t- goldcheck
          #ABORT 1
          }
        [#var (%concat( "player", %i, ".bet")) %1
        say Bet accepted.
        deposit %1
        #t- goldcheck
        }
      }
    } {
    say Very funny @goldfrom, don't emote gold gives.
    deposit %1
    #T- goldcheck
    }
  }


When it loops through the first time it sets the .bet field of the player who gives their coins first correctly.
However upon other players betting, it DELETES all the .bet fields of ALL the players. Why?
Before reaching this point the .bet field of all players is set to 0. But that shouldn't matter since I am explicitly setting it here.


Last edited by ralgith on Sun Dec 02, 2007 2:17 pm; edited 1 time in total
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Dec 02, 2007 2:18 am   
 
Sigh, even with the following cleaned version (man, what the heck was I on when I wrote the above?!?!)
Still having the same problem. I'm confounded.

Code:

#TRIGGER {You have (%d) gold coins.} {
  #IF (%1 = @goldgiven) {
    #IF (%ismember( @goldfrom, @players) < 1) {
      say You're not even part of this game!
      give @goldgiven coin @goldfrom
      #t- goldcheck
      #ABORT 1
      }
    #IF (@{%concat( "player", %ismember( @goldfrom, @players), ".bet")} > 0) {
      say @goldfrom you've already bet.
      give @goldgiven coin @goldfrom
      #t- goldcheck
      #ABORT 1
      }
    #var (%concat( "player", %ismember( @goldfrom, @players), ".bet")) %1
    say Bet accepted.
    deposit %1
    #t- goldcheck
    } {
    say Very funny @goldfrom, don't emote gold gives.
    deposit %1
    #T- goldcheck
    }
  }
#CLASS 0
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sun Dec 02, 2007 6:55 am   
 
I'm not sure what you were doing but the code you posted didn't even compile for me.

This does.
Code:
#IF (%1 = @goldgiven) {
  #IF (%ismember( @goldfrom, @players) < 1) {
    say You're not even part of this game!
    give @goldgiven coin @goldfrom
    #t- goldcheck
    #ABORT 1
  }
  #IF (@{%concat("player", %ismember(@goldfrom, @players), ".bet") } > 0) {
    say @goldfrom you've already bet.
    give @goldgiven coin @goldfrom
    #t- goldcheck
    #ABORT 1
  }
  #var {%concat( "player", %ismember( @goldfrom, @players), ".bet")} %1
  say Bet accepted.
  deposit %1
  #t- goldcheck
} {
  say Very funny @goldfrom, don't emote gold gives.
  deposit %1
  #T- goldcheck
}


Notices that #var ( %concat( "player", %ismember( @goldfrom, @players), ".bet" ) %1 is now #var { %concat( "player", %ismember( @goldfrom, @players), ".bet"} %1

The outer most braces are now parentheses. I hope that helps. There are too many undefined variables to get a better sense of what's happening.
_________________
Asati di tempari!
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Dec 02, 2007 2:13 pm   
 
I'm accepting a bet while dealing Blackjack ;)
And zMUD doesn't like the #var concat surrounded with curly brackets.
It also works fine for every other variable I concatenated using normal parens.
As I said, it works fine for the first player that calls it, but then clears all players
when its called again. And nothing in this code should do that.
I'm also trying not to give out too much of this code, it is a HUGE bot, and this is the final glitch with it.
I don't want anyone else having it as yet, so I don't want to post the entire thing.

I should note that zMUD also likes it just fine when I don't surround the %concat with anything, but I've been using the parens for safety sake.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sun Dec 02, 2007 8:09 pm   
 
Sorry about that. Another instance where I forgot to confirm which client was being refered to. Ignore my previous comments for now, as they were related to CMUD.
_________________
Asati di tempari!
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sun Dec 02, 2007 8:22 pm   
 
Ok I just tested this in ZMUD and it worked fine for me, so you must have some other codes that's resetting it. I mocked up the variables and I got player1 and player2 created successfully with the 'bet' value set.
_________________
Asati di tempari!
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Dec 02, 2007 9:30 pm   
 
Hmm, ok, I'll go through the whole script again.
Maybe I'll have to find someone trustworthy to let test the code.
Hmm. Man I hate these complex multi trigger and multi alias scripts sometimes. :)
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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