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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
crycry
Apprentice


Joined: 24 Jun 2006
Posts: 169
Location: UK - South Coast

PostPosted: Sun Dec 03, 2006 4:07 pm   

quicky non-bug question
 
is there any way to test to see if a paramater has been passed to an alias? and if not, set a default?

for example

Code:
#if (%len( %1) < 1) {#var param "default"} {#var param %1}


This worked in zMud, but cMud doesnt like it.
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Sun Dec 03, 2006 4:19 pm   
 
That code works fine for me
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
crycry
Apprentice


Joined: 24 Jun 2006
Posts: 169
Location: UK - South Coast

PostPosted: Sun Dec 03, 2006 4:26 pm   
 
hmms.. I think its not that line after all, thanks Guinn. Ill have a search through and see if its further up the script.
_________________
'Life is what happens, when your too busy doing something else'

_________________

XP Pro SP2
cMud 1.24
_________________
Reply with quote
crycry
Apprentice


Joined: 24 Jun 2006
Posts: 169
Location: UK - South Coast

PostPosted: Sun Dec 03, 2006 4:31 pm   
 
i cant find it.. heres the whole alias script, some of the things arent the best way to do things probably but heyho.

Code:

// reset vars
#var online_list ""
#var social ""

// triggers on to capture the lists
#T+ name_capture
#T+ name_capture_afk
#T+ name_capture

// namelist capture
who
#wait 1000

// triggers off
#T- name_capture_afk
#T- name_capture

// if theyre afk, remove them from the online list
#if (!%ismember( ~(AFK~) @online_list)) {#delitem online_list ~(AFK~)}

// if no param passed, default is hug
#if (%len( %1) < 1) {#var social "hug "} {#var social %1}

// social the remaining online list
#forall (@online_list) {
   #if (!%ismember( %i, @friend_list)) {} {@social %i}
}


all this produces, on using the command 'huglist tickle' all this produces is 'who tickle'
_________________
'Life is what happens, when your too busy doing something else'

_________________

XP Pro SP2
cMud 1.24
_________________
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Sun Dec 03, 2006 5:20 pm   
 
Odd, I was having the same problems as you, then it just started working. I ignored the first bit of the alias, since I don't have the triggers for sensing who's online etc, and instead just populated the lists manually.

Code:
online_list = Bob|Guinn|Joe|crycry|Zugg|Fred
friend_list = Guinn|crycry|Ted

#ALIAS huglist {// if no param passed, default is hug
#if (%len( %1) < 1) {#var social "hug "} {#var social %1}

// social the remaining online list
#forall (@online_list) {
   #if (%ismember( %i, @friend_list)) {@social %i} {}}}


Which works fine. I agree that something was odd before, and it definitely didn't work when I first pasted it in, but seems to work now. Odd ;)
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
crycry
Apprentice


Joined: 24 Jun 2006
Posts: 169
Location: UK - South Coast

PostPosted: Sun Dec 03, 2006 5:44 pm   
 
lol its all very strange Smile thanks for taking time out Guinn.. your right too, the triggers only do exactly what you did anyway.

I might sit on this one for a bit and see what happens Smile
_________________
'Life is what happens, when your too busy doing something else'

_________________

XP Pro SP2
cMud 1.24
_________________
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Dec 03, 2006 6:23 pm   
 
If I'm doing a test like that one, I use the %numparam function. It works like so:

#if (%numparam()=0) {#var social "hug "} {#var social %1}

As for your code, I've noticed a couple of things. The first is that there's no comma indicating a second parameter in %ismember in the #if to determine who is afk and who isn't. It also has an exclamation mark before it - so if (AFK) is NOT part of the string, it'll delete (AFK) from the string. I wondered if this might be the cause of the problem, since it's looking for (AFK) as a member of the list rather than part of a member of the list, so I commented out all the rest of the script, added in the comma, and tried it to see if someone would be properly removed from the online list if they were AFK. I tried changing Bob from Guinn's list to Bob(AFK) and "Bob (AFK)" because I wasn't sure which was the proper output for your MUD, but neither was removed from the list after processing. When I removed the exclamation mark and added the comma, there was still nothing doing, so obviously something's going wrong there. In the end I ended up with this:

#forall @online_list {#if (%rightback(%i,5)="(AFK)") {#delitem online_list %i}}

Which SHOULD work. The only problem is, it doesn't. I added an #echo to the true and false commands of that #if to see if it really was deciding which ones need deleting, and it was. The only problem was that when it tried to do #delitem online_list Bob(AFK) it didn't work - probably because of the parenthesis. I tried this on the command line with "" round the string and it still didn't work even then. I'm stumped on fixing that particular conundrum. I'll move onto the rest for now.

The second part, the one that determines which social to use, also didn't work - it wasn't setting the variable. I changed it to use %numparam() as shown above and it works fine.

The final part, that determines whether or not someone is on the friends list, also didn't work. This was because "@social %i" ate the command - you need to enclose it in an #exec command to preserve the space and still parse the @social. Also, your syntax seems a bit weird, here - you test if the value is NOT a member, and then do nothing if it isn't a member. Wouldn't it be easier just to remove the exclamation mark and the true-value and only have a check if someone IS in the friendlist?

The final code I got was this:
Code:
// if theyre afk, remove them from the online list
#forall @online_list {#if (%rightback(%i,5)="(AFK)") {#delitem online_list %i}}

// if no param passed, default is hug
#if (%numparam()=0) {#var social "hug "} {#var social %1}

// social the remaining online list
#forall @online_list {
  #if (%ismember( %i, @friend_list)) {#exec {@social %i}}
}


which cleans up to this:
Code:
// if no param passed, default is hug
#if (%numparam()=0) {#var social "hug "} {#var social %1}
#forall @online_list {
  // if theyre afk, remove them from the online list
  #if (%rightback(%i,5)="(AFK)") {#delitem online_list %i}}
  // social the remaining online list
  #if (%ismember( %i, @friend_list)) {#exec {@social %i}}
}


which is working apart from the #delitem thing mentioned above. Not sure how to get around that, or if it's a bug.

EDIT: I just had a brain wave how to get around that #delitem problem. Since %rightback is working, you could add the %rightback check to the #if that determines whether or not to social them. So you get:

#if ((IS a friend) AND (ISN'T afk)) {social them up}


Last edited by Fang Xianfu on Sun Dec 03, 2006 6:30 pm; edited 1 time in total
Reply with quote
crycry
Apprentice


Joined: 24 Jun 2006
Posts: 169
Location: UK - South Coast

PostPosted: Sun Dec 03, 2006 6:29 pm   
 
haha, im so ass backwards it scares me sometimes.. thanks for all your work on that Fang, i had no clue of the existance of %numparam, thats a really handy one to know of. I also need to learn about the #EXEC command too.. will get right on it.

Thanks again folks, your all amazing Smile


edit: jeebus im dense.. how did i not know about #exec.. god that would have saved me ages and ages. *blushes furiously*
_________________
'Life is what happens, when your too busy doing something else'

_________________

XP Pro SP2
cMud 1.24
_________________

Last edited by crycry on Sun Dec 03, 2006 6:32 pm; edited 1 time in total
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Dec 03, 2006 6:31 pm   
 
See edit above crycry :)

EDIT AGAIN >_>:

For some reason, what I suggested above isn't working.
Code:
// if no param passed, default is hug
#if (%numparam()=0) {#var social "hug "} {#var social %1}
#forall @online_list {
  #if (%ismember( %i, @friend_list)) {#if (%rightback(%i,5)="(AFK)") {} {#exec {@social %i}}}
}

is though :)
Reply with quote
crycry
Apprentice


Joined: 24 Jun 2006
Posts: 169
Location: UK - South Coast

PostPosted: Sun Dec 03, 2006 6:53 pm   
 
thanks fang Smile

okies.. huglist works fine with no param, but when i put in a param, it goes 'who beer' (where beer was the social)

so basically what its doing, is behaving like the flagged line below was

'who %1', and not just 'who'

Code:

// reset vars
#var online_list ""
#var social ""
// triggers on
#T+ name_capture
#T+ name_capture_afk
#T+ name_capture
// namelist capture
who      // <<<<<<<<<<<<<<<<<
#wait 1000
// triggers off
#T- name_capture_afk
#T- name_capture

// if no param passed, default is hug
#if (%numparam() < 1) {#var social "hug "} {#var social %1}
// social the remaining online list
#forall (@online_list) {
   #if (%ismember( %i, @friend_list) && %rightback(%i,5) != "(AFK)") {#exec {@social %i}}
}


%rightback is pretty cool too.. thanks for that one!
_________________
'Life is what happens, when your too busy doing something else'

_________________

XP Pro SP2
cMud 1.24
_________________
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Dec 03, 2006 7:49 pm   
 
Try getting rid of the wait command and changing it to #alarm +1 {stuff to do}. Wait is a little bugger and can cause all kind of trouble :(
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
crycry
Apprentice


Joined: 24 Jun 2006
Posts: 169
Location: UK - South Coast

PostPosted: Sun Dec 03, 2006 8:01 pm   
 
nope, still doing it.

good idea with the alarm though.
_________________
'Life is what happens, when your too busy doing something else'

_________________

XP Pro SP2
cMud 1.24
_________________
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Dec 03, 2006 8:09 pm   
 
Is the append parameters option selected? I'm guessing since this uses %nn syntax rather that named parameters that it was imported from zMUD. It's possible that the append option is doing it, and that's enabled by default for aliases imported from zMUD.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
crycry
Apprentice


Joined: 24 Jun 2006
Posts: 169
Location: UK - South Coast

PostPosted: Sun Dec 03, 2006 8:13 pm   
 
your a blinding genius!!!!!!! thats what you are..

it was that all along.. your a star! thanks fang!

edit: what does that actually do btw? i have no clue.
_________________
'Life is what happens, when your too busy doing something else'

_________________

XP Pro SP2
cMud 1.24
_________________
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Dec 03, 2006 8:20 pm   
 
in zMUD, parameters were automatically added the end of aliases. So you could create an alias like this:

#alias k {kill}

and then type "k monster" and have it work fine. In CMUD, this isn't supported by default - you need to use %params to append parameters. The Auto Append option is a compatability option to keep aliases made in zMUD working until they're updated to use the new syntax.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
crycry
Apprentice


Joined: 24 Jun 2006
Posts: 169
Location: UK - South Coast

PostPosted: Sun Dec 03, 2006 8:23 pm   
 
thats really really good to know.. i should work on converting the others, im guessing its something that will disappear after a period of time.

thanks again fang *hugs*
_________________
'Life is what happens, when your too busy doing something else'

_________________

XP Pro SP2
cMud 1.24
_________________
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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