Worlds of Carnage
https://www.wocmud.org/forum/

custom command 2
https://www.wocmud.org/forum/viewtopic.php?f=26&t=143
Page 1 of 1

Author:  Pazam [ Fri Jul 22, 2005 6:00:44pm ]
Post subject:  custom command 2

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

Author:  Kayenta [ Fri Jul 22, 2005 6:06:56pm ]
Post subject: 

why are there so many symbols!!!............

Author:  Grael [ Fri Jul 22, 2005 6:07:05pm ]
Post subject: 

Paz is smart.

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

Author:  Kayenta [ Fri Jul 22, 2005 6:11:03pm ]
Post subject: 

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?

Author:  Pazam [ Fri Jul 22, 2005 6:30:56pm ]
Post subject: 

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.

Author:  Kayenta [ Fri Jul 22, 2005 6:36:26pm ]
Post subject: 

yeah, i was talking about the % and such.
Urs is complicated enough.....dunno if i wanna see one of blobs.......


thanks paz =)

Author:  Blobbie [ Sat Jul 23, 2005 11:46:21pm ]
Post subject: 

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

Page 1 of 1 All times are UTC-04:00
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/