Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
NeverNor
Novice


Joined: 18 Nov 2006
Posts: 32

PostPosted: Sat Nov 18, 2006 3:32 am   

Who wants to help out some newbie code!! *Smile*
 
Hello, I have been using this program for about a day same with DragonRealms. I have basically been standing in one room using testing out codes. I wanted to come up with something that would train up hiding and then stop when I got to a certain mindstate.

I don't know if it is me, but zMUD seems a little tempermental and cMUD just crashes on me when I flip through different windows on my toolbar. Anway this is what I have:
_______________________________________________________________

#CLASS {Roundtime}
#VAR rt {0}
#VAR maxrt {6}
#VAR roundTime {1163820435}
#VAR worldtime {1163820429}
#TRIGGER "rtTrig" {Q} {#var roundTime {%gsl( Q)}} "" {gsl}
#COND {q} {
#var worldtime {%gsl( q)}
#var rt {%eval( @roundtime-@worldtime)}
#var maxrt {@rt}
} {gsl}
#COND {} {
#add rt (-1)
#if (@rt>0) {#state rtTrig (2)} {#state rtTrig (0)}
} {wait|param=1000}
#BUTTON 21 {@rt} {} {} {} {@rt} {} {} {Size} {66} {34} {Pos} {18} {24} {32816} {} {Gauge||12|@maxrt||15} {} "" {Explore|Inset} {} {}
#BUTTON 34 {RT:} {} {} {} {} {} {} {Size} {25} {36} {Pos} {20} {0} {} {} {Separ} {} "" {} {} {}
#CLASS 0

#CLASS {ExpCheck}
#TRIGGER {SkillCheck &skill} {#T+ expLevelAlarm}
#ALARM "expLevelAlarm" {3} {
#T+ ExpStat
exp @skill
#T- expLevelAlarm
} "" {disable}
#CLASS 0

#CLASS {ExpStat} {disable}
#TRIGGER {% clear} {
#T+ SkillUp @skill
#ECHO {Skill up @skill}
#T- ExpStat
}
#TRIGGER {% learning} {
#T+ SkillUp @skill
#ECHO {Skill up @skill}
#T- ExpStat
}
#TRIGGER {% thoughtful} {
#T+ SkillUp @skill
#ECHO {Skill up @skill}
#T- ExpStat
}
#TRIGGER {% pondering} {
#T+ SkillUp @skill
#ECHO {Skill up @skill}
#T- ExpStat
}
#TRIGGER {% muddled} {
#T+ SkillUp @skill
#ECHO {Skill up @skill}
#T- ExpStat
}
#TRIGGER {% very muddled} {
#T+ SkillUp @skill
#ECHO {Skill up @skill}
#T- ExpStat
}
#TRIGGER {% perplexing} {
#T+ SkillUp @skill
#ECHO {Skill up @skill}
#T- ExpStat
}
#TRIGGER {% perplexed} {
#T+ SkillUp @skill
#ECHO {Skill up @skill}
#T- ExpStat
}
#TRIGGER {% bewildering} {
#T+ SkillUp @skill
#ECHO {Skill up @skill}
#T- ExpStat
}
#TRIGGER {% bewildered} {
#T+ SkillUp @skill
#ECHO {Skill up @skill}
#T- ExpStat
}
#TRIGGER {% dazed} {
#T- SkillUp @skill
#T- ExpStat
}
#TRIGGER {% mind lock} {
#T- SkillUp @skill
#T- ExpStat
}
#CLASS 0

#CLASS {SkillUp hid} {disable}
#TRIGGER {Skill up hid} {#T+ hideAlarm}
#ALARM "hideAlarm" {3} {
#T+ Unhide
hide
#T- hideAlarm
#T- SkillUp hid
} "" {disable}
#CLASS 0

#CLASS {Unhide} {disable}
#TRIGGER {already hidden} {
unhide
hide
}
#TRIGGER {Roundtime:} {#T+ unhideAlarm}
#ALARM "unhideAlarm" {@maxrt} {
unhide
#T- unhideAlarm
#ECHO {SkillCheck @skill}
#T- Unhide
}
#CLASS 0

_____________________________________________________________

The rt stuff I got from this website (thanks) the rest is me. I can't seem to get the thing to shut down, it is only suppose to work when I type #ECHO skillcheck hid, with hid being the wildcard that gets passed around to activate other types of skills, assuming I get them, I kinda built it to be modular. However, I can generate a "skill up hid" just by typing exp in the console and it keeps running well into Mind Lock. It is essentially an non-crashing infinite loop. Any help would be grand, or anyway other way to hand the thing.

This interface seems pretty powerful, wish it came with a better manual or some tutorials, well any help would be appreciated thanks.

Oh I just figured out that ExpStat was just running off the "learning" in "SKILL: Rank/Percent towards next rank/Amount learning
" and was not using the rotating stat that I was requesting, is there a way to omit it from using the first learning?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Nov 18, 2006 6:53 am   
 
Might be that the percent-sign in the % learning pattern is being mistaken as the wildcard indicator (and summarily ignored as "% " is not a valid wildcard). If so, things should start working if you change % to ~% in all of those triggers.

If that doesn't do the trick, you may have to redesign your triggerset to more accurately match the full line. You will need two triggers for this:

#TRIGGER {%s({@SkillNames})~:(%s)(%d) (%d)~% ({@SkillMindStates})%s({@SkillNames})~:(%s)(%d) (%d)~% ({@SkillMindStates})*} {}

#TRIGGER {^%s({@SkillNames})~:(%s)(%d) (%d)~% ({@SkillMindStates}){%s|}$} {}

These are the triggers I use to match the experience output in DR, though I removed the code they execute to make them easier to read.
_________________
EDIT: I didn't like my old signature
Reply with quote
NeverNor
Novice


Joined: 18 Nov 2006
Posts: 32

PostPosted: Sat Nov 18, 2006 5:55 pm   
 
Thanks that worked! I redid my code to make it more compact and all fit into one class:

_______________________________________________________________________

#CLASS {HideTrainer}
#TRIGGER {SkillCheck hid} {#T+ hideStateAlarm}
#ALARM "hideStateAlarm" {3} {
exp hid
#TR {~% clear} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TR {~% learning} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TR {~% thoughtful} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TR {~% pondering} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TR {~% concentrating} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TR {~% muddled} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TR {~% very muddled} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TR {~% perplexing} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TR {~% perplexed} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TR {~% bewildering} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TR {~% bewildered} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TR {~% dazed} {
#ECHO {HIDE TRAINING DONE}
#T- hideStateAlarm
}
#TR {~% mind lock} {
#ECHO {HIDE TRAINING DONE}
#T- hideStateAlarm
}
#TR {already hidden} {
unhide
hide
#T- hideStateAlarm
}
} "" {disable}
#ALARM "hideActionAlarm" {@maxrt} {
unhide
#ECHO {SkillCheck hid}
#T- hideActionAlarm
}
#CLASS 0
____________________________________________________________________

Now the thing creates a bunch of triggers like:

#TR {~% mind lock} {
#ECHO {HIDE TRAINING DONE}
#T- hideStateAlarm
}

in the gobal interface, which totally screwes up how it is not suppose to activate if I type "exp". Any idea on how to stop it from creating them and running good other times like it does the first time?
Reply with quote
NeverNor
Novice


Joined: 18 Nov 2006
Posts: 32

PostPosted: Sat Nov 18, 2006 8:32 pm   
 
I think I fixe d it with "Set as Default" and "Disable" from the UI. I wrote this:

#TR {SkillCheck hid} {#T+ HideTrainer;#T+ hideStateAlarm}

#TR {HIDE TRAINING DONE} {#T- HideTrainer}

#CLASS {HideTrainer} {disable|setdef}
#ALARM "hideStateAlarm" {3} {
exp hid
#TRIGGER {~% clear} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% learning} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% thoughtful} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% pondering} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% concentrating} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% muddled} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% very muddled} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% perplexing} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% perplexed} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% bewildering} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% bewildered} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% dazed} {
#ECHO {HIDE TRAINING DONE}
#T- hideStateAlarm
}
#TRIGGER {~% mind lock} {
#ECHO {HIDE TRAINING DONE}
#T- hideStateAlarm
}
#TRIGGER {already hidden} {
unhide
hide
#T- hideStateAlarm
}
} "" {disable}
#ALARM "hideActionAlarm" {@maxrt} {
unhide
#ECHO {SkillCheck hid}
#T- hideActionAlarm
} "" {disable}


It ran once fine and when I typed exp the trainer didn't process only SkillCheck hid, which is what I was going for. However, when I looked at the code for HideTrainer it was edited to this:

#CLASS {HideTrainer} {disable|setdef}
#ALARM "hideStateAlarm" {3} {
exp hid
#TRIGGER {~% clear} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% learning} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% thoughtful} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% pondering} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% concentrating} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% muddled} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% very muddled} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% perplexing} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% perplexed} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% bewildering} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% bewildered} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% dazed} {
#ECHO {HIDE TRAINING DONE}
#T- hideStateAlarm
}
#TRIGGER {~% mind lock} {
#ECHO {HIDE TRAINING DONE}
#T- hideStateAlarm
}
#TRIGGER {already hidden} {
unhide
hide
#T- hideStateAlarm
}
} "" {disable}
#ALARM "hideActionAlarm" {@maxrt} {
unhide
#ECHO {SkillCheck hid}
#T- hideActionAlarm
} "" {disable}
#TRIGGER {~% clear} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% learning} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% thoughtful} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% pondering} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% concentrating} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% muddled} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% very muddled} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% perplexing} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% perplexed} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% bewildering} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% bewildered} {
#T+ hideActionAlarm
hide
#T- hideStateAlarm
}
#TRIGGER {~% dazed} {
#ECHO {HIDE TRAINING DONE}
#T- hideStateAlarm
}
#TRIGGER {~% mind lock} {
#ECHO {HIDE TRAINING DONE}
#T- hideStateAlarm
}
#TRIGGER {already hidden} {
unhide
hide
#T- hideStateAlarm
}
#CLASS 0

I have no idea why it added those triggers again after the 2nd alarm statement (hideActionAlarm). Unless the triggers under the first alarm (hideStateAlarm) act like constructors and the ones underneath are the actual functions. Either way it works and it I don't end up with this TRs being created outside of class. Not bad for a 2nd day :D. Any comments, tips, improvements, or redirection of thought (usage of other functions I am not aware of) would be nice. I don't think there are any memory leaks or what-not, though these don't seem anything at all like Visual C++ classes; although I don't like variable/object auto-generation. One complaint I have is that it sometimes post and then returns a 1 sec wait, wish there was a way to curb that, oh welll, thanks for reading.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Nov 19, 2006 5:55 am   
 
Forget everything you know about C++ regarding classes. Classes in ZMud = Windows folders. There are also no constructors, destructors, or any of that stuff, either. So the fact that things are duplicating would be a rather bad thing you should get fixed. To do so, it looks like you have a #ALARM without an ending to it:

#ALARM "hideStateAlarm" {3} {
exp hid
#TRIGGER {~% clear} {

You will need a closing bracket between "exp hid" and #Trigger.

For further reference, it's best to review your code via the Settings Editor GUI from time to time. In most if not all cases, no setting of any type should ever have a syntax error (they show in red).

As for improvements and suggestions, here goes. First, I don't see any reason to have two alarms. One alarm would suffice, since you're only doing two commands and some messaging.

#alarm *@maxRT {unhide;exp hiding}

Second, if you are matching on a specific skill's experience listing, just make one trigger for that whole thing and do your calcs in that:

#variable skillmindstates {clear|learning|thoughtful|pondering|concentrating|muddled|very muddled|perplexing|perplexed|bewildering|bewildered|dazed|mind lock}
#trigger {Hiding:%s%d %d~.%d~% ({@SkillMindstates})} {#if (%ismember("%1",@skillmindstates) >= 12) {#NOOP this is for dazed and above;#ECHO {HIDING TRAINING DONE};#T- HideTrainer} {#NOOP this is for bewildered and below;hide}}

Third, regarding the two triggers outside of HideTrainer, keep this one and get rid of the other (it's not necessary given the #echo and #T- in the above trigger):

#TR {SkillCheck hid} {#T+ HideTrainer;#T+ hideStateAlarm}
_________________
EDIT: I didn't like my old signature
Reply with quote
NeverNor
Novice


Joined: 18 Nov 2006
Posts: 32

PostPosted: Mon Nov 20, 2006 8:09 am   
 
Thank you for that, I did some reevaluating and no longer duplicate #TRIGGERS or #ALARMS when making things, I do have one last request. I can't seen to make a heads on how ot use loops, they just immediate post to the screen or run on forever. In this code:

#CLASS {PowerTrainer} {disable|setdef}
#ALARM "powerTrainerAlarm" {3} {
#var skillName power
#T+ powerTrainerTR1
#T+ MindStatus
#T+ mindStatusAlarm
#T- powertrainerAlarm
} "" {disable}
#TRIGGER "powerTrainerTR1" {SKILL} {
per xib
#T- powerTrainerTR1
#T+ powerTrainerAlarm2
} "" {disable}
#ALARM "powerTrainerAlarm2" {@maxrt} {
#IF (@skillStatus <= 12) {
#T+ PowerTrainer
#T+ powerTrainerAlarm
#T- powerTrainerAlarm2
} {
#T- powerTrainerAlarm2
#T- PowerTrainer
}
}
#CLASS 0

I grab my skillStatus from another folder, I can change 'perc xib' into an array already:

#VAR powerObject {yav|kat|xib|pro|mani|ste}

but I can't get it into a loop where I can perc each one without writing a perc for each one, anyone help?
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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