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
forlove
Newbie


Joined: 17 Nov 2009
Posts: 4

PostPosted: Tue Nov 17, 2009 4:16 am   

Function no response
 
Here are 3 defined functions, all of them have an argument, and do a lot of calculation, then return a variable.
FunctionA, FunctionB, FunctionC.

When I use the following script, but SOMETIMES it will return nothing, or no response. Anyone can help me?

#ec @FunctionA(@FunctionB(@FunctionC(@myVariable)))


Last edited by forlove on Tue Nov 17, 2009 6:06 am; edited 1 time in total
Reply with quote
orphean
Apprentice


Joined: 21 Oct 2008
Posts: 147
Location: Olympia, WA

PostPosted: Tue Nov 17, 2009 4:28 am   
 
How do you expect people to help when you give no details on what Functions A, B, and C are doing?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Nov 17, 2009 4:39 am   
 
use the #RETURN command.
_________________
EDIT: I didn't like my old signature
Reply with quote
forlove
Newbie


Joined: 17 Nov 2009
Posts: 4

PostPosted: Tue Nov 17, 2009 5:56 am   
 
For example:
FunctionA {
a lot of calculation.
//Here, the calculation will spend a lot time, I think maybe the problem come from this long time calculation, but don't know how to solve it.
#return xxx
}
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Nov 17, 2009 6:28 am   
 
Use the #HELP command.
_________________
EDIT: I didn't like my old signature
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Nov 17, 2009 1:54 pm   
 
Usually when a function returns nothing, its because the function actually returns nothing. Without details about your functions, we can't really tell you what the problem is.

As for the speed, you may be surprised at how fast Cmud can run calculations. Unless your calculation is a thousand lines long, or you are doing very inefficient things, you probably won't see any significant delay in your output. Long execution time is almost certainly not your problem.
Reply with quote
forlove
Newbie


Joined: 17 Nov 2009
Posts: 4

PostPosted: Thu Nov 19, 2009 4:47 am   
 
Yes, maybe the problem is I'm doing very inefficient things.:-(
Please give your comment, thanks for your patient!

Purpose: Create the shortest shortcut from AreaB-Roomb to AreaD-Roomd.
For example:
Divided the mud map to 4 AREA, A,B,C,D
A     B
   O
C     D

Each AREA has one shortcut, from MAP center O to the AREA center A,B,C,D.
listOA="s|w|s|nw|nw|nw"
listOB="s|w|s|ne|ne|ne"
listOC="s|w|s|sw|sw|sw"
listOD="s|w|s|se|se|se"
There are a lot rooms in the area, a,b,c,d.
Aa     Bb,b1,b2
   O
Cc     Dd

Each ROOM has one shortcut, from AREA center A,B,C,D to the ROOM a,b,b1,b2,c,d.
Store the full shortcut in below list:
For AreaB:
listRoomName="b|b1|b2" //unfortunately, b and b1 have the same room name, but they are different rooms, the final listRoomName will be:
listRoomName="b|b|b2"
listRoomShortcut="e|e|n" //Start point is AREA center
For AreaD:
listRoomName="d"
listRoomShortcut="e" //Start point is AREA center

Question 1: The shortest shortcut from AreaB-Roomb to AreaD-Roomd?

step0: listRoomxy(AreaB,Roomb,AreaD,Roomd) //new Function, the below is the detail.
step1: listBb="e" //From AREA center B to ROOM b.
step2: listOB="s|w|s|ne|ne|ne" //from MAP center O to the AREA center B.
step3: listOb=listOB + listBb="s|w|s|ne|ne|ne|e" //Here, use new Function: listMerge(), return listOb.
step4: listbO="w|sw|sw|sw|n|e|n" //Reverse listOb, use new Function: listReverse(), return listbO.
step5: listDd="e" //From AREA center D to ROOM d.
step6: listOD="s|w|s|se|se|se" //from MAP center O to the AREA center D.
step7: listOd="s|w|s|se|se|se|e" //Again, use listMerge().
step8: listbd=listbO + listOd="w|sw|sw|sw|n|e|n|s|w|s|se|se|se|e" //listMerge()
step9: listbd="w|sw|sw|sw|se|se|se|e" // "n|e|n|s|w|s" is unnecessary, use new Fuction: listSlim(),return listbd.
step10: #return @listbd
Finally, the result should be "w|sw|sw|sw|se|se|se|e".

Maybe the problem comes from the below new defined functions:
listMerge() //combine 2 or more lists.
listReverse() //change the list to opposite direction and reverse the list, for example: w-e,n-s,ne-sw,se-nw(west-east,north-south,northeast-southwest,southeast-northwest)
listSlim() //remove the waste direction pairs, just like: w-e,n-s,ne-sw,se-nw, etc..

Your comment is welcome.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Nov 19, 2009 2:59 pm   
 
Well, my first question would be, are you using the mapper? If you are, there is an easy function to find the shortest route between two rooms: %pathfrom().

Your procedure as outlined looks fine, but I don't know how you implemented it. This problem is fairly straightforward, and shouldn't take more than a second to run in Cmud. If it is taking a long time, or hanging, or returning a null value, you probably have a bug in your code. We'd have to see your code to figure out the problem.

I see two methods for making your coding easier. The first would be to use the mapper. If you're trying to keep track of all these paths just to get from place to place, why not use the mapper? That's what it is for, and it has a lot of powerful tools for paths. If you don't want to use the mapper, then I suggest you convert your path lists into Cmud path strings. So listOA would be "sws3h", etc. You can concatenate these paths easily with %concat(), especially if they don't have a dot in front. You can reverse a path with %pathreverse(). To produce the reverse of a path without the dot, do %replace(%pathreverse("sws3h"),"."), or something like that. This eliminates the need for your listMerge() and listReverse(). You would still need a listSlim(), and you'd probably need to do that with the stringlist of directions. To convert the path to a stringlist, use %pathexpand().
Reply with quote
forlove
Newbie


Joined: 17 Nov 2009
Posts: 4

PostPosted: Fri Nov 20, 2009 6:35 am   
 
No, I do not try mapper.
Yes, PATH is a very powerful tool. But, in this mud, there are a lot of unregular directions(100 or more), I need to define them by myself, finally, I found PATH can't treat all of them.
For example,
Between room A and room B, there is a maze, I must define them as two new directions.
from A to B, the way AtoB is "w;w;s;n;e;w;n", //set as new alias, def_AB, then set direction p, reverse, q
from B to A, the way BtoA is "n;n;s;e;w" //set as new alias, def_BA, then set direction q, reverse, p
Here, if there are 100 Mazes, how can I deal with them by path, there are not enough letter (a-z, only 26 letters) to define the new directions. :-(
Any other way? If it's possible, PATH will be better for me.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Nov 20, 2009 2:37 pm   
 
I'm not sure what you mean by "there is a maze, I must define them as two new directions." You seem to be saying that the reverse of some of the paths is not the inverse of the directions. That's fine, and you just have to define separate paths for them. I don't know what you mean by 'then set direction p, reverse q'.

If the problem is simply not being able to use %pathreverse() to generate a reverse path, then you can use a separate path for each direction.

In any case, you don't have to use paths. The method you outlined should work fine, and be plenty fast enough. If you just want to debug your current code, cut and paste it to the forum within [code]...[/code] blocks.
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