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

Custom commands
https://www.wocmud.org/forum/viewtopic.php?f=26&t=138
Page 1 of 1

Author:  Pazam [ Thu Jul 21, 2005 6:05:11pm ]
Post subject:  Custom commands

here is a custom command i made for the dice game, so that when you type 'bet' it is issued as a real command. i can't guarantee that my 'code' is perfect, or even efficient, but between the example here and the help file, it should help someone. i do see a cpl things i could have done better. for ex: #@dicemaster = %getMobPointer( vnum ) would most likely have been a better method, rather than a keyword.
Code:
custom_command_act bet
Code:
if %isNpc( @actor ) return endif @gold = %getCharStat( @actor, gold ) @dicemaster = %getMobPointer( dicemaster ) if @gold < 1000 talk @actor You must have at least 1000 coins to play the dice games. return endif protect { if %getVar( wager ) talk @actor Only one player at a time please. return endif } endprotect @input = @arguments @input = %stringToWords( @input ) @input = %filterActionWords( @input ) %setEntityVar( @i, wager, @input->1 ) %setEntityVar( @i, player, %getShortName( @actor ) ) *%setEntityVar( @i, player, @actor ) if %getVar( wager ) > %getCharStat( @actor, gold ) talk @actor You don't even have that many coins! %deleteEntityVar( @i, wager ) %deleteEntityVar( @i, player ) return else talk @actor You placed a %( @input->1 ) coin wager on %( @input->2 ). endif if %( @input->2 ) == triple %callScript( @dicemaster, triple_bigsmall, @actor ) else if %( @input->2 ) == big %callScript( @dicemaster, big_bigsmall, @actor ) else if %( @input->2 ) == small %callScript( @dicemaster, small_bigsmall, @actor ) else wait 2 secs talk @actor I think you made a mistake with your bet. %deleteEntityVar( @i, wager ) %deleteEntityVar( @i, player ) endif endif endif

Author:  Blobbie [ Thu Jul 21, 2005 6:13:35pm ]
Post subject:  Re: custom commands

Quote:
for ex: #@dicemaster = %getMobPointer( vnum ) would most likely have been a better method
Isn't the script defined on the dicemaster himself? You could have just used @self. FYI you can't use %getMobPointer() with a vnum since multiple mobs with the same vnum might exist (oddly the same is true for keywords and yet functionality is there :)

Author:  Pazam [ Thu Jul 21, 2005 6:36:38pm ]
Post subject: 

good point. i have used %getMobPointer( vnum ) for places where there is, and can only be, one of the mob. i suppose in that case it didn't matter as long as i used a unique keyword, like 'dice_master', instead of something generic like 'master'.

thanks for reformatting my post =p

Author:  Blobbie [ Thu Jul 21, 2005 7:06:15pm ]
Post subject: 

Quote:
good point. i have used %getMobPointer( vnum ) for places where there is, and can only be, one of the mob. i suppose in that case it didn't matter as long as i used a unique keyword, like 'dice_master', instead of something generic like 'master'.
Yeah, I think the reason I allowed for it was for the event builders had named they're mobs or objects very specifically so there couldn't be confusion. Rooms can take vnums though, but that's because there canonly be one room in existence with a given vnum.
Quote:
thanks for reformatting my post =p
You're welcome, next time just use the "Code" button above the editor and then you won't lose indentation and stuff.

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