Worlds of Carnage
It is currently Tue Apr 16, 2024 11:05:25am

All times are UTC-04:00




Post new topic  Reply to topic  [ 4 posts ] 


 Post subject: Custom commands
PostPosted: Thu Jul 21, 2005 6:05:11pm 
User avatar
Immortal
Joined: Sun Apr 15, 2001 10:17:32pm
Posts: 27
Website: http://defed.wocmud.org
Location: USA
Offline
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


Top
   

 Post subject: Re: custom commands
PostPosted: Thu Jul 21, 2005 6:13:35pm 
User avatar
Implementor
Joined: Fri Oct 06, 2000 5:32:29pm
Posts: 288
Website: http://www.wocmud.org
Location: Ottawa, Canada
Offline
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 :)


Top
   

 Post subject:
PostPosted: Thu Jul 21, 2005 6:36:38pm 
User avatar
Immortal
Joined: Sun Apr 15, 2001 10:17:32pm
Posts: 27
Website: http://defed.wocmud.org
Location: USA
Offline
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


Top
   

 Post subject:
PostPosted: Thu Jul 21, 2005 7:06:15pm 
User avatar
Implementor
Joined: Fri Oct 06, 2000 5:32:29pm
Posts: 288
Website: http://www.wocmud.org
Location: Ottawa, Canada
Offline
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.


Top
   

Display posts from previous:  Sort by  

Post new topic  Reply to topic  [ 4 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group