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
TesterOfLimitz
Novice


Joined: 02 Jun 2007
Posts: 37

PostPosted: Sun Jul 01, 2007 11:05 pm   

Multistate Reset Script
 
Ok, so ive been writing a healing script for Achaea, and basically i use triggers to add/subtract the different amount of herbs of each type i should eat. Basic enough, but, illusions can loop a system into adding tons and tons of herbs into one thing, and basically waste alot of my money, so I was wondering, if I were to have a mutlitstate trigger, is there was anyway to Reset the variable to 0 should it not recieve the second line.......I dunno if im making sense, so ill give a basic example. It works off the concept that if the system thinks there are multiple afflictions for the same herb, that if it tries to cure 1 of them, but doesnt actually recieve a cure, then i have no need to eat any more of said herb.

Code:
#va herb 4
#trigger {You eat this herb}
#condition {You heal this affliction} {#math herb -1}



Mud Sends this:
Quote:
You eat this herb
You heal this affliction
prompt

and the script executes, subtracting one from @herbmaking it 3


Mud Sends this:
Quote:
You eat this herb
prompt

and the script executes, and changes the @herbvariable back to 0



Hopefully I explained well enough to give you guys the general idea of what I want, I think it could be extremely helpful, But ive been trying to think of a way to actually WRITE it, and have kinda stumped meself. Any and all help, as always, is greatly appreciated.

-- Tester
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Jul 02, 2007 12:19 am   
 
You can do this in a number of ways. One way is this:

#trig {You eat this herb} {}
#cond {(*)} {#if (%1 != "You heal this affliction") {do something}}

but this can swiftly get very complicated with many affliction cure messages. Probably the most robust way to do this would be to use entirely separate triggers for the eating line and the affliction cure line, since either can be illusioned (or both). The affliction cure line will check what affliction curing commands you have sent (eating herbs, focusing, etc) and what affliction curing lines you've recieved. The affliction only gets removed if the cure-line you've recieved matches one of the commands that was sent. If your script starts ignoring many afflictions because of this, it could prompt you.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Fuego Ledrey
Wanderer


Joined: 09 May 2007
Posts: 64
Location: Dustin Acres, California

PostPosted: Mon Jul 02, 2007 12:55 am   
 
What I do, just as another example, Fangs way is fine, is I have all the "You cure this affliction" messages in a folder called "Cures", easy enough. Then I have all of the "You eat this herb" lines in my system. Every time my system eats an herb, it puts a flag in a variable with the name of the herb, i.e.:
Code:
#ALIAS sys_eat {#if (%ismember(%1,"herb1|herb2|etc.")) {outr %1;eat %1;#addkey flages {herb_eaten} {1}} {eat %1}}
#TRIGGER {You eat this herb.} {#if (%iskey(@flags,herb_eaten)) {#T+ Cures}}

Along with the cures lines being in the Cures folder, there is an onPrompt event that does:
Code:
#event onPrompt {#delkey flags herb_eaten;#T- Cures}


Something like this might be what you're looking for.

This may not be exact as my mouse has broken and I can't check to see the exact code, this is off the top of my head. Hope it helps, and hope it's accurate. If it's not then I'm sure you can iron out the wrinkles.
_________________
EDIT: Image moved to Avatar FINALLY.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Jul 02, 2007 1:08 am   
 
That's definitely a good way to do it. I personally like lots of control over my system and like to know exactly what it's doing - I have it tell me every time it's refused to acknoledge a cure because it thinks it'd detected an illusion. If I reckon it's coming up with some false positives for whatever reason, I'm then able to turn off the illusion protection if I choose. I guess it just depends how trusting you are of your system :P
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
TesterOfLimitz
Novice


Joined: 02 Jun 2007
Posts: 37

PostPosted: Mon Jul 02, 2007 1:33 am   
 
actually, i found a way of condesing all the healing triggers and whatnot into a data record........I cant believe i didnt think of this, since its actually the way I use to pick up venom attacks Shocked
ex:
Code:
afflictions.affline1 = affname1
afflictions.affline2 = affname
then
#trigger {You get shanked}
#condition {({@afflictions})} {#loopdb @afflictions {#if (%1 = %key) {#additem afflicted %val}}


Anyways, thanks for the help, As always, quick, nice and very effective help Very Happy

--------------------------
A quick edit: I use a Command trigger at the beginning of the healing list, so it only executes the 'You eat an herb' after i tell it to eat said herb

A quick edit part duece: I have manual backups just in case I think my illusion system's malfunctioning....Im trusting, but its nice to have a manual override just in case
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Jul 02, 2007 1:51 am   
 
I'm very surprised if that works as you've pasted it there, Tester. I was under the impression that dbvars didn't match in patterns, much less matching exactly the same way as string lists but with their keys instead of values.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
TesterOfLimitz
Novice


Joined: 02 Jun 2007
Posts: 37

PostPosted: Mon Jul 02, 2007 1:59 am   
 
Actually, Looking at the code I just posted...using

Code:
#trigger {You get shanked}
#condition {({@afflictions})} {#if (%db(@afflictions,%1)) {afflicted.%db(@afflictions,%1) = 1}


might work a little better..
-----------------------
Quick edit: Actually Fang they do, the variable expands within the brackets using the key's as a string (I think i read about it in the pattern matching help file, so i dont think its a bug) Ill post a quick example here in a moment you can use to test it.


Last edited by TesterOfLimitz on Mon Jul 02, 2007 2:30 am; edited 1 time in total
Reply with quote
TesterOfLimitz
Novice


Joined: 02 Jun 2007
Posts: 37

PostPosted: Mon Jul 02, 2007 2:25 am   
 
Code:
#class "Testing Data Record Expansion in Triggers"
#trigger {({@test})} {#if (%db(@test,%1)) {tested.%db(@test,%1) = 1}}
test.hello = hi
test.Tester = name
test.Cmud = client
Tested.hi = 0
Tested.name = 0
Tested.client= 0
#alias {test1} {#say Hi}
#alias {test2} {#say My name is Tester}
#alias {test3} {#say This is a test showing the Data Record Expansion in triggers for the program Cmud}
#class 0


Alrighty, do the normal copy and paste into the command line, Run through the test alias's (Test1, Test2, Test3) and it -should- go through and change the Tested variables.
(still kinda new writing the code out in this format, I use the package editor for most of the things I do)
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Jul 02, 2007 9:35 am   
 
Weird, I did a test last night and it didn't work. Yours definitely does work though - I guess that's my something new to learn today. Thanks! :)
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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