Jump to content

zMUD variable help.


Filth

Recommended Posts

I am able to create a variable as follows:

#VAR (some dark black leaves) 0 0

However I am unable to reference the variable using @ in any way. I have tried @(small dark black leaves) (@small dark black leaves) and just about any other combination of {}, [], and "". Am I missing something or is there no way to have a variable name with more than one word?

Link to comment
Share on other sites

Yes you are.

First, you need an alias so you can change the variable fast while you are playing. This depends on what you are going to use the variable for, but lets say you are going to use them for a fast smoke.

So you create an alias:

Name: herb

Value: #var herb

Then you create a way in which you want to use the variable, lets say you want it to be a macro, F4 for example, so when you press it, you will use the variable for smoke.

You go to macros:

Key: F4

Value:

get @herb bac

smoke @herb

Lets say you want to use the variable @herb for dark black leaves. You type "herb dark" -> This puts "dark" in the variable for @herb, so now when you press F4 you will get the dark black leaves from your backpack and smoke them. If you want to smoke grey herbs instead of dark black leaves, you type "herb grey" and now when you press F4 you will get your grey leaves from your backpack and smoke them.

I hope that helped.

PS. If you want to use more than one word for your variable, type "herb "dark black leaves" ".

Link to comment
Share on other sites

A fast smoke for me is using an alias for each specific herb. stn, armr, prt, sanc, frn for example.

My goal with this variable is to keep track of how many herbs I have left by adding one every time i pick up a new herb, or subtracting one every time I smoke an herb or they evaporate. And I want to do this without a huge #if statement or an independent trigger for each herb. (herbs is just an example, truly any consumable would work)

So far I have the trigger:

Pattern: You light (%w*) and begin to smoke it.

This gives %1 the exact name of your herb as you see it in game. It doesn't separate any of the keywords needed to manipulate the item in game, but it does give me a very reliable variable common to each herb.

Now the idea is to add -1 to the variable of whatever herb I just smoked.

It can be easily done as follows:

Variable

Name: some dark black leaves

Value: 1

Trigger

Pattern: You light (%w*) and begin to smoke it.

Value: #ADD %1 -1

This trigger will subtract one from the variable %1.

The only problem is manipulating a variable with a multi-word name.

In this example when mud sees, "You light some dark black leaves and begin to smoke it." it creates a variable named some with a value of dark.

I've tested this trigger with a variable named leaves with a value of 5 and after the mud saw, "You light leaves and begin to smoke it." the variable leaves became 4.

So my variable name has multiple words. How can I reference it?

Link to comment
Share on other sites

So my variable name has multiple words. How can I reference it?

As far as I know, you need to make a separate trigger that adds or subtracts for each individual herb time, using only one word as the variable name. This should only take a few minutes to set up.

Also, are you sure it is possible to refer to variables as matched strings? I've never seen {#ADD %1 -1} before. Anyway. Don't cut corners when scripting, it'll just lead to frustration and heartaches.

EDIT:

If this -is- possible, I would very much like to know. Would be so much easier to set up a script that automatically rolls for the highest possible of your race/class combination when creating a character.

Link to comment
Share on other sites

So my variable name has multiple words. How can I reference it?

Per my understanding, support for variable-names with whitespaces is very uncommon, just because it makes things too complicated (and/or error-prone?).

You might want to use "Record Variable", where herb name is the key, and amount is the value, IF zMud allows record variable's name to contain whitespaces.

Other option is to translate the whitespaces into underscores (_) before the #ADD.

Link to comment
Share on other sites

*facepalm* You people and your triggers...

Trigger:

$enemy walks in.

Action:

blackjack $enemy

;)

(Of course, you need A LOT more than just that for the trigger to be successful. And of course, ogres (and drunkies) can ruin just about everything...)

Link to comment
Share on other sites

Also, are you sure it is possible to refer to variables as matched strings? I've never seen {#ADD %1 -1} before.

Yes. Another way to do this would be to store %1 in a variable temp and reference it indirectly.

#TRIG {You light (&temp*) and begin to smoke it.} {#ADD @temp -1}

Anyway. Don't cut corners when scripting' date=' it'll just lead to frustration and heartaches.[/quote']

In fact cutting corners is mostly the idea to programming. Cutting corners is a bad term--a better word would be efficiency. If you can take 30 lines of code and turn in into 2 you do it. It will save on memory and processes. These two are practically limitless for a mud on a modern computer, but I like to keep tight coding a habbit.

Out of all the scripts I've ever done this is the only one zMUD could not do.

Ive created scripts to record all damage done to a target and display the info in buttons (Last battle, current battle, last 5 attacks act), made an exp rate calculator, buff timers for me and my opponent to view via macro, creating db records when identifying.

I found scripts for combat are way to prone to error or accidents, but I have done plenty of those! Anyone want a chase script? :P

If this -is- possible, I would very much like to know. Would be so much easier to set up a script that automatically rolls for the highest possible of your race/class combination when creating a character.

Very interesting. I'll get back to you!

Link to comment
Share on other sites

Trigger:

$enemy walks in.

Action:

blackjack $enemy

;)

(Of course, you need A LOT more than just that for the trigger to be successful. And of course, ogres (and drunkies) can ruin just about everything...)

lol

At one point in time (I think when I was scourging around on Islildien) I even created a ramdisk and had windows copy zMUD to it at startup and copy it back at shutdown. ^.^ Any kind of lag at your end can mean certain death against an evenly matched opponent.

Link to comment
Share on other sites

  • 2 months later...

this is a good one..

#action {%1 can't seem to get back into the air} {#showme {<----|=TARGET IS GROUNDED THIS ROUND=|---->}}

or...to show hp gained and loss every round..

#variable {changehp} {0}

#variable {curhp} {0}

#variable {oldhp} {0}

#variable {oldhp $curhp} {curhp %1}

#action {<%1/%2hp } {#var oldhp $curhp; #var curhp %1; #math {changehp}{$oldhp - $curhp};#if {$changehp > 0} {hploss};#if {$changehp < 0} {hpgain}} {5}

#alias {hpgain} {#showme <<<-YOU GAINED $changehp HITPOINTS->>>}

#alias {hploss} {#showme <<<-YOU LOST $changehp HITPOINTS->>>}

This snags your hp from your prompt everytime it echoes and uses $oldhp as a temp location for the hp from the last echo. It then compares the two for a difference, and displays said diff, calling the right display alias depending on the results. In game it looks like so...

Sepahoona: [===|===|=--|---]
<456/794hp 1043/1099m 452/3676>[Exits: --- ]> crit

Sepahoona: [===|===|=--|---]
<456/794hp 1043/1099m 452/3676>[Exits: --- ]> <<<-YOU LOST 86 HITPOINTS->>>
Your faith holding fast, you stop the blow with The Boneseer's power.
Someone's bladed onslaught devastates you!
Someone's cleave devastates you!
Someone's bladed onslaught decimates you!
Your steel shards graze someone.
Someone's slash misses you.
Someone's bash collides with your protective shield.
Someone's bash misses you.
Someone dodges your attack.
Someone dual parries a light sword's slice.

Sepahoona: [===|===|---|---]
<370/794hp 1042/1099m 452/3676>[Exits: --- ]> <<<-YOU GAINED -66 HITPOINTS->>>
You feel a lot better!

Sepahoona: [===|===|=--|---]
<436/794hp 1028/1099m 452/3676>[Exits: --- ]> crit
<<<-YOU LOST 56 HITPOINTS->>>

Something's fury misses you.
Someone's cleave devastates you!
Someone's bladed onslaught decimates you!
Your faith holding fast, you stop the blow with The Boneseer's power.
Your faith holding fast, you stop the blow with The Boneseer's power.
You are burned by the corrosive acid on something.
Someone's acidic bite scratches you.
Your steel shards hit someone.
Someone's slash misses you.
Someone parries your attack.
Your light sword's slice mauls someone.

Sepahoona: [===|===|---|---]
<380/794hp 1026/1099m 452/3676>[Exits: --- ]> #TICK+10
<<<-YOU GAINED -62 HITPOINTS->>>
You feel a lot better!

Sepahoona: [===|===|=--|---]
<442/794hp 1012/1099m 452/3676>[Exits: --- ]>

Hp changes appear to be displayed before the round happens, but you have to understand what order your client performs functions. The hp displays 1st since the mud does all the programatic calculations before it displays the incoming data as txt for you to see.

Also the hp gained displayes with a - in front of it, this is a result of the math used to calc the diff. I could convert it back to a positive number..but I am lazy. That fix would just be to display the alias as something like this...

#alias {hpgain} {#showme <<<-YOU GAINED {$changehp*-1} HITPOINTS->>>}

A chasing script would be defined as a targeted script that will hunt people down automatically. I wouldnt want to encourage discovery of how to do such a thing on the mud though. I am sure any novice could write one, but there are pitfalls that must be overcome that a newer player might not know about (and I wont tell em haah)

Link to comment
Share on other sites

#alias {hpgain} {#showme <<<-YOU GAINED {$changehp*-1} HITPOINTS->>>}

Yep, that method (#*-1) works. Much simpler than my "(root of #)^2". :P

#var numero -50
#OK. VARIABLE {numero} HAS BEEN SET TO {-50}.
#math numero2 {$numero*-1}
#MATH: VARIABLE {numero2} HAS BEEN SET TO {50}.

But the math inside #showme doesn't work.

<<<-YOU GAINED {-50*-1} HITPOINTS->>>

Here's a (partial) rewrite:

#action {<%1/%2hp } {#var oldhp $curhp; #var curhp %1; #math {changehp}{$oldhp - $curhp};#if {$changehp != 0} {hpchange}}

#alias {hpchange}
{
#var tmp LOST;
#if {$changehp < 0}
{
#var tmp GAINED;
#math changehp {$changehp*-1}
};
#showme <<<-YOU $tmp $changehp HITPOINTS->>>
}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...