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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Casius
Novice


Joined: 03 Sep 2004
Posts: 34

PostPosted: Wed Nov 15, 2006 12:16 pm   

scripting help needed
 
it has to do with setting of flags. This scripting is for achaea

i am trying to set up flags for balance in CMud. eg: you perform an action like putting bait on a hook for fishing, by doing this he loses balance so i set #var balance 0, when the mud returns "you have recovered balance" i set #var balance 1, only after i have regained balance can i cast line. I want to set an alias bhook = bait hook with shrimp then i want the mud to wait until balance is recovered then automatically cast line. but i dont want to cast line everytime i recover balance

i hope you understand what i am trying to do. any help would be great
Reply with quote
Chris_3413
Novice


Joined: 22 Mar 2004
Posts: 46
Location: Australia

PostPosted: Wed Nov 15, 2006 12:38 pm   
 
I made a simple script for this long time ago for zMud and so far it still works fine in cMud too

basically, when ever you do somthing that uses balance insert these two lines between it and the command that needs to wait for balance before being executed:

balance=0
#WHILE (@balance=0) {#WAIT 50}

so long as the balance variable has a value of 0 It keeps on waiting for 50 milliseconds before checking again and then when it finally gets set back to 1 with the You have recovered balance on all limbs. message it exits the #WHILE loop and moves onto the next command.
(you could use a value higher than 50 if you like depending on how quickly you want it to repond to your balance recovery)

NOTE: I started using these 2 lines of code so frequently that in order to cut back on coding clutter I created an alias called balwait with those lines and simply call it whenever the code needs to wait for balance.
_________________
What do you mean, Fatal Error!
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Nov 15, 2006 1:14 pm   
 
A better way to do this (especially if you have a lot of scripts waiting for balance) would be to have a trigger "You have recovered balance" that then has a series of #ifs (or even a #switch if you're feeling adventurous and want the script to only try doing one command at a time), one of which could be

#if (@Baiting) {bhook}

And then have the alias instead be:

#if (@Balance) {bait hook with shrimp;#var Baiting 0} {#var Baiting 1}

which will hopefully reduce the overhead of all those scripts checking balance every 50ms. You can go wild with these things creating systems to queue commands in string variables and so on using #addkey to queue as many things as you like for balance.

Just as an afterthought, CMUD 1.16 has a much better way of doing this. Using the new event system, you create an event BalanceGain triggered by your prompt or the balance messages, and then have all your balance-related scripts just pick up on this event. This means that you can manage what's checking balance and things much more easily by disabling classes rather than checking variables. You could even have a separate "fishing" package that you only load when you want to fish, that automagically plugs into those events.
Reply with quote
Casius
Novice


Joined: 03 Sep 2004
Posts: 34

PostPosted: Fri Nov 17, 2006 9:12 pm   scripting help needed
 
Thanks chris i have used your method with the fishing thing and it works.

Fang i am busy trying your way with defences but im not getting it right. this is what i have done

#trigger (you have recovered balance) {#if (@constitution) {} {eqdefs}}
{#if (@vitality) {} {eqdefs}}
#alias (eqdefs) {#if (@balance) {#var eqdeffing 0} {constitution;#var eqdeffing 1}
{#if (@balance) {#var eqdeffing 0} {vitality;#var eqdeffing 1}

What i want it to do is i want to run the alias eqdefs then constitution must be sent to the mud, the mud must wait for balance then run vitality. I dont have Cmud 1.16 yet so i vant use the event system yet.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Nov 17, 2006 9:34 pm   
 
The idea behind the system I showed you above is that the alias checks if you have balance or not. If you do, it does the command. If you don't, it sets the variable "Baiting" so that when the trigger next fires, it'll know that the alias was tried unsuccessfully. I suppose a better way to do this would be to use the #temp command to create a temporary trigger "You have recovered balance" that'll send the alias again, but I hate using temporary triggers. I like my settings where I can see them :P

I use a much simpler system for deffing up, though it's a little less robust in that it'll try deffing up regardless of whether you already have the defense. Since you don't def in combat, I don't really see it as a problem - you can just type #fire You have recovered balance to move to the next one.

#alias defup {[command of first defence];#t+ Defup}

#trigger {You have recovered balance} {[second command]} "Defup"
#cond {You have recovered balance} {[third command]}
...
#cond {You have recovered balance} {[last command];#t- Defup}

I actually use the GUI for creating multistate triggers, so I can't guarantee this will work if you enter it from the command line. What it's supposed to do is create a trigger "You have recovered balance" with states for all your defenses in a class called Defup. You'll need to set the class Defup to "Disabled" and "Disable on startup" to stop it going off when you don't want it to. The alias will manually turn it on when you tell it to.

I use a multistate trigger for this so that I can disable it easily. Also, if you create a system for queueing commands, you then have to create exceptions for commands that don't take balance/eq, and there's not much point when this way works just fine (all you have to do is put all those commands in the alias along with the first one that takes bal/eq)

On the topic of a system for controlling balance, I actually use an expression trigger that looks like this:

@balance AND @equilibrium AND !@stunned

That executes whatever I want it to. Parrying and whatnot.

Then I have "You have recovered balance" and "You have recovered eq" set the right variables to 1. Expression triggers are a bit more useful in CMUD since they only check the variables in their patterns now. You can also set up part of your prompt trigger to set them via the %pos function if you capture the string at the end.
Reply with quote
Casius
Novice


Joined: 03 Sep 2004
Posts: 34

PostPosted: Sat Nov 18, 2006 8:41 am   
 
I am looking a the ACP for a bit of guidence and ideas, and i have a question from it. What is the difference between #regex and #trigger





Thanks
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Nov 18, 2006 10:33 am   
 
#regex is exactly the same as #trigger, it just creates a trigger with the Regex option enabled. Regex is short for (Perl) Regular Expression, which is basically just a different syntax for wildcards. I'm used to using the CMUD syntax, so I don't bother with it. Larkin and the ACP types must be more familiar with Perl Regex syntax. More info on how to use it is in the #regex entry in the command reference and in various places round the web.
Reply with quote
Casius
Novice


Joined: 03 Sep 2004
Posts: 34

PostPosted: Sat Nov 18, 2006 2:54 pm   
 
Okay Fang i have tried this programing in cmud

I created a class defup
Then i created an alias called baldefs, in the name i block i put baldefs, in the scripting part i put the following
selfishness;#t+ defup
#trigger (You have recovered equlibrium) {fitness} "defup"
#cond (You have recovered balance) {constitution}
#cond (You have recovered equlibrium) {split mind;#t- defup}

This returns a bug in the system. Once i remove "defup" then it runs but all it does is send selfishness and fitness to the mud, without waiting for balance. It does not even send constitution or split mind to the mud.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Nov 18, 2006 4:08 pm   
 
Equilibrium is spelt wrong, might be a start :P
_________________
Rorso's syntax colouriser.

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


Joined: 03 Sep 2004
Posts: 34

PostPosted: Sun Nov 19, 2006 1:31 pm   
 
This Cmud is driving me up the wall. every 20 sec im getting a send bug report.

I changed the spelling of equilibrium, and still it does not work, same problem. The "defup" causing a bug in the system. when #trigger is put into the scripping area of the settings editor cmud automatically creates another trigger in the root system.
It still just send slefishness and fitness straight to the mund without waiting for equilibrium or balance. am i doing something qrong?

Your help is greatly appreciated
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sun Nov 19, 2006 2:28 pm   
 
Okay, tested this and one thing you need to do is enclose the argument to #t+ in curly braces, making it #T+ {DefUp}. Same for #T-.

I have no idea why it's sending both commands at once. I tried recreating these settings myself and they worked fine. I use the GUI to create multistate triggers, so I don't know the syntax exactly but I've managed to create settings that do what you want them to. It ends up looking a bit like this with the second state of the trigger sending #T- {DefUp}

As an aside, many of the error messages I get from CMUD come from me executing code with errors in it - if you look at the bug report before you send it you can see errors like "unmatched parenthesis" and "unmatched braces" which are usually good pointers that you've got something wrong somewhere rather than it being CMUD's fault :)
Reply with quote
Casius
Novice


Joined: 03 Sep 2004
Posts: 34

PostPosted: Sun Nov 19, 2006 4:40 pm   
 
I dont know but i just cant seem to get it to work.

I do agree with you though that most of the bugs that the Cmud is giving is probably my fault.

i have resorted to doing the following with my defences, to put them up that is

selfishness
equib=0
#until (@equib) {#wa 50}
fitness
balance=0
#until (@balance) {#wa 50}
constitution
equib=0
#until (@equib) {#wa 50}
split mind
equib=0
#until (@equib) {#wa 50}
touch mindseye
equib=0
#until (@equib) {#wa 50}
vitality

It works great but i do realise that it is slightly inefficent. Espcially when im going to have many triggers that are going to rely on balance and equilibrium.
Reply with quote
Casius
Novice


Joined: 03 Sep 2004
Posts: 34

PostPosted: Sun Nov 19, 2006 7:13 pm   
 
Okay here is a question? How do you delete a package. I have imported a zMud package through the editor, but now i want to get rid of it. How do i do that. Is there something im missing as i can only find a way to delete the tab.

Another question comes with a trigger im trying to do: It has to do with the health, mana prompt in achaea. This is what it looks like

4024h, 2191m, 19020e, 12180w exdb-
Im trying to capture the values.
#trigger ((%1)h, (%2)m, (%3)e, (%4)w) {#var health %1;#var mana %2;#var endurance %3;#var willpower %4}

the triggers works with the above, but should i not be using %d instesd of the %1,%2 etc?? When i do it does not capture the values can you tell me why?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sun Nov 19, 2006 9:48 pm   
 
There're two ways to delete packages. The first is to right-click on the session icon and edit it. On the files tab there, there's a main session package and a list of extra packages. I'm not sure where CMUD puts zMUD packages, but it's probably the extra package list. Just highlight it and click the minus. The other way is just to go into the CMUD directory, find the .pkg file, probably in \CMUD\packages\ and delete it.

The trigger I've always used for my prompt is {^(%d)h, (%d)m, (%d)e, (%d)w (%w)-}. Make sure you also uncheck the "Trigger on newline" option and check the "Trigger on prompt" option and that you enclose the pattern in curly braces rather than brackets - that's probably why it's not firing at the moment. With this trigger, you can also use the %pos function with %5 to set things like eq, balance, blindness, etc etc which is quite useful :)

In addition, you can save the value of wildcards straight into local variables with the syntax ($localvar:%wildcard), which makes your scripts a bit easier to read. It's bugged at the moment if you have more than one local variable, but it'll hopefully be fixed in 1.16. Your trigger would look like this:

#trigger {($health:%1)h, ($mana:%2)m, ($endurance:%3)e, ($willpower:%4)w} {#var health $health;#var mana $mana;#var endurance $endurance;#var willpower $willpower}

which is a bit easier to understand than the %nn syntax. I'm sure you can see how it'd apply to my example.

I wouldn't worry too much about the multistate trigger for now. Deffing up isn't something I'd be overly concerned with, since you're not actually in combat when you do it. You're allowed a bit of inefficiency there :P Maybe come back to it when you've used them for other things.
Reply with quote
Casius
Novice


Joined: 03 Sep 2004
Posts: 34

PostPosted: Fri Nov 24, 2006 10:40 am   
 
I have a quick question. When i have been programing i tend to do something wrong and the whole cMud keeps error reporting. I assume its my triggers. I have no idea what i have done wrong so i reinstall cMud and lose all my work. That is going to happen i understand. Here is the question....

Should i have a new package for everything that i do eg: a package for fishing, a package to track health, mana, etc. a package to track balance.

If this is a good idea how should i do it, because if i have an alias in on package and i start a new package the aliases in that package dont work. I have enabled the packages.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Nov 24, 2006 11:36 am   
 
If you view the bug report, it'll probably say something like "unmatched braces" or "unmatched parenthesis" - those errors you usually don't even have to close the program, let alone reinstall. Just resume the program, edit the settings, and off you go.

Most of the time when you get an error you usually just have to restart rather than reinstall anyway. And regardless, uninstalling doesn't delete your MUDs and PKGs, so you can just leave them in the folder and install again (or copy them out first).

You can separate your scripts into separate packages if you like - just share the modules so that your other settings in other packages can see them, and then make sure that packages that need to interact are enabled on the package properties page.
_________________
Rorso's syntax colouriser.

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


Joined: 03 Sep 2004
Posts: 34

PostPosted: Sat Nov 25, 2006 10:59 am   
 
Well i reprogrammed some things and it seems to be working on 1.16 so no problems yet. (hold thumbs)

I have been working on a class to pick up information about my stats. Health mana etc. You have helped me a bit here and i would like to show you what i have done and get some pointers.

#trigger {^(%d)h, (%d)m, (%d)e, (%d)w (%w)-} {#var health %1;#var mana %2;#var endurance %3;#var willpower %4;#if (%pos;x,%5)) {#var balance 1} {#var balance 0};#if (%pos(e,%5)) {#var equib 1} {#var equib 0}}

I have a question about the ^ at the beginning of the trigger, why is it there?
Have i used the %pos correctly. This is how i understand it should work for balance - If x is found in %5 then it will set @balance to 1 if not it will set @balance to 0.
Do you use this trigger solely to establish if you have balance or just as a backup against illusions? Or do you use - #trigger {You have recovered balance} {#var balance 1} as well
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Nov 25, 2006 12:17 pm   
 
^ matches the start of a line, so it'll only trigger if the pattern is at the beginning of a line.
As for the stats, you're using pos right. The first one has a semicolon instead of an open bracket though.

I use a trigger on "You have recovered balance" as well. I suppose I don't really need to, but I like to for completeness. It could have a positive effect on speed, now I think about it, since if you're entering a command when you gain balance, it'll be entered a line earlier.
_________________
Rorso's syntax colouriser.

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


Joined: 03 Sep 2004
Posts: 34

PostPosted: Wed Nov 29, 2006 4:56 pm   auto sipping and events
 
Okay i am now trying to set up an auto sip script, if health falls below a certain amount drink health, same with mana. Any suggestions?

but before i do this, where can i find more information on how to use events, as there is no information about this in the help file on Cmud
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Nov 29, 2006 6:33 pm   
 
Events are quite simple, really. See Zugg's thread announcing them for info, but broadly speaking:

Events contain scripts, and they have parameters just like an alias. But instead of typing the name, you use #RAISEEVENT or #RAISE eventname. This then sets off ALL events with the name "eventname" - it can be very useful if you have, say, lots of scripts that work off your prompt. You can create an event "Prompt" for each script in that script's own module, and have your prompt trigger #RAISE the event. You can simply disable a script's module if you want to stop using that script. It allows much more simple modularity.

Now, as for sipping, you first need to be capturing your health and mana from your prompt. Then you have a couple of options. The widely used zMUD method was to have a script in your prompt (or in an alias triggered by your prompt - or, indeed, if you want to be fancy, in the previously-mentioned Prompt event in an AutoSipping class or module) that looked something like this:

#if (@CanSip) {#if (@health > 150) {sip health;#var CanSip 0} {#if (@mana > 150) {sip mana;#var CanSip 0}}}

You also need a trigger like this:
#trig {You can sip health again} {#var CanSip 1}

When you're able to sip again, the variable gets set to 1, the next prompt triggers the sipping, and you sip, and the script waits until it sees "You can sip health again" before repeating the process. If you don't need to sip, it'll wait until you do.

That'll serve you fine if all you're doing is bashing. If you want to complicate it further, though, you can time how long it takes for you to recover after sipping, and add alarm that resets CanSip after that amount of time. Each "sip" section above would then look like this:

sip whatever;#va CanSip 0;#alarm AutoSipAlarm +3 {#va CanSip 1}

You also need to change the text of the "sip again" trigger to:

#var CanSip 1;#untrigger AutoSipAlarm

This is a failsafe in case you try to sip but fail for some reason (asleep, anorexic, stunned, whatever). It'll automatically try again after the timelimit is up. You could also link in with your affliction-tracking system, once you have one, by checking for afflictions that'll stop you from sipping and not sipping if they're present.
_________________
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 Beta Forum 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