Worlds of Carnage
It is currently Fri Nov 08, 2024 11:07:29pm

All times are UTC-04:00




Post new topic  Reply to topic  [ 7 posts ] 


 Post subject: custom command 2
PostPosted: Fri Jul 22, 2005 6:00:44pm 
User avatar
Immortal
Joined: Sun Apr 15, 2001 10:17:32pm
Posts: 27
Website: http://defed.wocmud.org
Location: USA
Offline
here's another custom command to make a secret door work. again, there are probably things i could have done better/different.

@arguments is the stuff you type after the 'command' - which is 'slide'.

the #@input stuff converts the '@arguments' into useable words, that are put into a numbered order for later use ( via 'stringToWords' ) and then strips off extraneous, useless words like is, an, a...( via 'filterActionWords' )....

so...typing 'slide the panel' would mean @input->1 is panel, due to the stripping of the 'the'.

this may be clearer in the 'bet' command, as i use the same structure to extract 'the amount bet', and 'game bet on' from a command such as 'bet 5000 on big'. @input->1 is the 'amount' and @input->2 is the 'game type'....on is stripped in the filterActionWords function.


this all makes sense to ME, but if i have terribley buggered the explanation, please correct me blob!


Code:
custom_command_act slide
Code:
if %isNpc( @actor ) return endif @input = @arguments @input = %stringToWords( @input ) @input = %filterActionWords( @input ) @exit = %getRoomExits( @roomNumber )->north @otherSide = %getExitStat( @exit, otherSide ) if %( @input->1 ) == panel %setExitStat( @exit, isClosed, 0 ) %setExitStat( @otherSide, isClosed, 0 ) echoto room all The panel slides open. at 10000 echoto room all The panel slides open. wait 5 secs %setExitStat( @exit, isClosed, 1 ) %setExitStat( @otherSide, isClosed, 1 ) echoto room all The panel slides shut. at 10000 echoto room all The panel slides shut. endif


Top
   

 Post subject:
PostPosted: Fri Jul 22, 2005 6:06:56pm 
User avatar
Joined: Sat Dec 25, 2004 1:14:21pm
Posts: 157
Website: http://photobucket.com/albums/y216/Kinara/
Offline
why are there so many symbols!!!............


Top
   

 Post subject:
PostPosted: Fri Jul 22, 2005 6:07:05pm 
Joined: Sun Apr 16, 2006 9:12:10pm
Posts: 2
Offline
Paz is smart.

Wonder how long it takes for me to delete this post!


Top
   

 Post subject:
PostPosted: Fri Jul 22, 2005 6:11:03pm 
User avatar
Joined: Sat Dec 25, 2004 1:14:21pm
Posts: 157
Website: http://photobucket.com/albums/y216/Kinara/
Offline
well, we know paz is smart =) he tells us he us he is.

But seriously, why so many symbols? isnt there some way to simplify it?


Top
   

 Post subject:
PostPosted: Fri Jul 22, 2005 6:30:56pm 
User avatar
Immortal
Joined: Sun Apr 15, 2001 10:17:32pm
Posts: 27
Website: http://defed.wocmud.org
Location: USA
Offline
it's not all about smarts...when learning new stuff, i often browse over an existing example, grasp the concept, then manipulate it to fit my usage.

what symbols are you referring to? this script is fairly small and pretty simple! you should see some of blobs.

functions always start with %, # is used in front of lines that arent processed by the game ( for lack of a better explanation) and @ is used in front of variables, pointers, etc.


Top
   

 Post subject:
PostPosted: Fri Jul 22, 2005 6:36:26pm 
User avatar
Joined: Sat Dec 25, 2004 1:14:21pm
Posts: 157
Website: http://photobucket.com/albums/y216/Kinara/
Offline
yeah, i was talking about the % and such.
Urs is complicated enough.....dunno if i wanna see one of blobs.......


thanks paz =)


Top
   

 Post subject:
PostPosted: Sat Jul 23, 2005 11:46:21pm 
User avatar
Implementor
Joined: Fri Oct 06, 2000 5:32:29pm
Posts: 288
Website: http://www.wocmud.org
Location: Ottawa, Canada
Offline
Quote:
yeah, i was talking about the % and such.
Urs is complicated enough.....dunno if i wanna see one of blobs.......
Well you are reading the "advanced techniques" page ;) But anyway, I can perhaps shed a little light on the mystery. Symbols like % or @ are indicators to the scropt engine on how to treat the following information. For instance when the engine encounteres % is generaly knows that a function will follow, and when it encounters @ it generally knows that a variable will follow. This kind of technique is common in most scripting languages, and isn't always necessary. part of the reason that BlobbieScript uses these symbols is historical. For instance % is not completely necessary for functions since the engine can be made smart enough to know that a series of characters followed by () is a function; however, in the original easyacts engine $. was used to define functions... so you would have $.isEvil( @n ). So I reduced this to a clearer symbol of %isEvil() whilst removing the $ symbol from general usage since in 90% of scripting languages $ signifies a variable and not a function. So there you have it... FYI $.isEvil() is still supported since BlobbieScript was made backward compatible with existing easyact scripts.

Now to address the other comment my Pazam. The # character when leading a line is used to prevent the script engine from passing the value of evaluating the line to the MUD's interpreter as a command. For instance the following would make the mob "laugh".
Code:
@foo = laugh
This is because the result of evaluating some line of code is usually sent tot he game's interpreter. The # symbol prevents that functionality. This is why scripts can be as simple to write as:
Code:
talk @n You must die. hit @n


Top
   

Display posts from previous:  Sort by  

Post new topic  Reply to topic  [ 7 posts ] 

All times are UTC-04:00


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group