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
Kariyana
Beginner


Joined: 02 Feb 2004
Posts: 10
Location: Canada

PostPosted: Sun Jul 25, 2004 3:14 pm   

Using #ADD and #MATH in item/container script
 
Hi,

I'm looking to do the following with my scripts: I have a container that's empty and I mine for stuff, let's say, copper ore. When I mine and I get ore, I get the following message:

You dig up Copper ore (13) and drop it on a stack!

Now the number in the parenthesis varies, sometimes there's no number at all (as in no ore at all) or there's just one ore, so it comes out as "You dig up Copper ore and drop it on a stack!". Right now, I have the trigger set to where if I get 'You dig up Copper ore ', it will fill the portal with ore, then keep mining in the direction I have it set in, like 'fill por ore;mine d'.

My question is, how would I set it up to where I fill the portal with the ore and it goes into my title? Like, say I have 1100 ore in the container and I want that in my title, then when I add 12 more ore, I want it to say 'SoandSo has mined up 1112 copper ore'. Thanks :)
_________________
Live outside the box, you can see alot better from there.

- Myself
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Sun Jul 25, 2004 5:47 pm   
 
The only thing that is probably confusing is the trigger pattern. Since () are usually used to set matching text to %1-%99, you need to use the escape character(~) so they're parsed literally.

#trigger {You dig up Copper ore ~((%d)~) and drop it on a stack!} {fill por ore;mine d;#add CopperMined %1;title has mined up @CopperMined copper ore.}
Reply with quote
SCORNME
Novice


Joined: 25 Jul 2004
Posts: 48
Location: aka Falan

PostPosted: Mon Jul 26, 2004 7:05 am   
 
@Danlo

Would your script fire on "You dig up Copper ore and drop it on a stack!" and add 1 since it doesn't have ()? Or would there need to be a second trigger?

#TR {You dig up Copper ore and drop it on a stack!} {fill por ore;mine d;#add CopperMined 1;title has mined up @CopperMined copper ore.}

-curious-
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Mon Jul 26, 2004 9:24 am   
 
Sorry, I read your first post wrong. Yeah, you'll need that second trigger.
Reply with quote
geniusclown
Magician


Joined: 23 Apr 2003
Posts: 358
Location: USA

PostPosted: Mon Jul 26, 2004 1:44 pm   
 
This is sort of convoluted, but I think it solves your problem.
Quote:
#TR {^You dig up Copper ore{| ~(}({|%d}){|~)} and drop it on a stack!$} {#IF (%1) {#ADD CopperMined %1} {#ADD CopperMined 1}}

You didn't post what it looks like when you get none at all, so I'm not sure how to make that work, though I'm sure it's not a difficult modification.

Alternatively, you could do this using a Perl Regular Expression (details on matching using Perl can be found at http://www.regular-expressions.info/reference.html):
Quote:
#REGEX {You dig up Copper ore[ (]*([\d]*)[)]* and drop it on a stack!} {#IF (%1) {#ADD CopperMined %1} {#ADD CopperMined 1}}
_________________
.geniusclown
Reply with quote
Kariyana
Beginner


Joined: 02 Feb 2004
Posts: 10
Location: Canada

PostPosted: Mon Aug 09, 2004 8:50 pm   
 
I'm back, and this time, I hope to get this thing finalized.

Ok, last time we were trying to figure out the best way to put what I had mined into my title. I got that far but want to advance it a bit further. As of right now, I have two triggers set up as follows:

You dig up (%w) ore ~((%d)~) and drop it on a stack!
OreType = %1
#show @OreType, %2
fill por ore
#IF (@OreType = "Copper") {
#show COPPER FOUND: %2
#add CopperMined %2
title has mined up @CopperMined copper ore.
mine @MineDir
}

That direction has already been stripped clean.
#IF (@DirToMine >= 5) {DirToMine = 1} {#MATH DirToMine {@DirToMine + 1}}
#SHOW @MineDir
mine @MineDir

I have CopperMined, MineDir, OreType and DirToMine set up already as my variables. Now, the way the first trigger is set up is to include all other types of ore so instead of just working for Copper, it works for Iron and Silver and Gold and Mitrill and Adamantite. However, for this mining character, I only want the amount of Copper ore that I mined to go into my title (because she's a Copper ore miner).

Now, the second trigger was set up by my husband so that when I was mining and the direction I went in was stripped, it would switch to another direction and mine there. However, it's looping atm. I'd like to be able to change direction when I get that message and keep mining in the direction that I just designated (for example, if I mine out the eastern wall and there's still a north, south and west direction, I'd like to start mining south and keep mining south until I get the stripped message again, then change north and do the same thing). The mines are set up in a basic 13x13 grid, so if I start and go 6 east, then I'll hit a wall where I can't mine anything. And if I start and go 6 west, same thing. If I attempt to mine in that direction, it will say "Nothing to mine in that direction." I'd like to be able to switch my mining direction like I would when I get the stripped message.

I guess what I'm really asking is a couple things...1) How can I switch the direction that I was mining in before once I break through a wall, and continue to mine in that direction...2) How can I get the singular ore that I mine out to tally into my title?...3) How can I get it to mine in a certain direction when I get two different resources? (ie sandstone and copper, I just want it to mine east if I get copper...if I get sandstone, I don't want it to do anything unless sandstone is the only thing I mine up).

I hope that wasn't too confusing. I'll keep monitoring this for any responses. Thanks again :)
_________________
Live outside the box, you can see alot better from there.

- Myself
Reply with quote
SCORNME
Novice


Joined: 25 Jul 2004
Posts: 48
Location: aka Falan

PostPosted: Tue Aug 10, 2004 7:28 am   
 
...from your script
Code:
  mine @MineDir
  }

That direction has already been stripped clean.
#IF (@DirToMine >= 5) {DirToMine = 1} {#MATH DirToMine {@DirToMine + 1}}
#SHOW @MineDir
mine @MineDir


1. I don't see where you changed @MineDir. So, you're sending the same direction that was already stripped. From what I see, @DirToMine is a duplicate of @MineDir. I think you can get rid of @DirToMine and change it to:

Code:
#IF (@MineDir >= 5) {MineDir = 1} {#ADD MineDir +1}
#SHOW @MineDir
mine @MineDir



2. Create a variable and trigger for the different ores and do the same as Danlo showed.

3. If you want to change direction when you get excessive ores that aren't Copper, here's an idea:

#var BAdamantite 0
#var BCopper 0
#var BGold 0
#var BIron 0
#var BMitrill 0
#var BSilver 0
#alias gomine {mine @MineDir; BIron = IronMined; BGold = GoldMined; BSilver = SilverMined; BMitrill = MitrillMined; BAdamantite = AdamantiteMined}

add this to your "dig up" trigger commands
#IF ((@IronMined - @BIron) > #) {#SH That direction has already been stripped clean.}
...and replace all commands of mine @MineDir with the alias gomine.

I'm not sure about the #IF's expression syntax. Idea is that when you start mining in a direction you set your Beginning ore counts (BGold, BIron, etc). Then when you get a new ore, you check the amount you've gained (@IronMined - @BIron). If you've mined too many of the ore (replace the # with your desired limit value, e.g. 2, 3, 4, etc) then simply #SHOW the pattern to trigger mining in a new direction.

Not elegant, but I think it'll work. not checked
Reply with quote
Kariyana
Beginner


Joined: 02 Feb 2004
Posts: 10
Location: Canada

PostPosted: Tue Aug 10, 2004 1:48 pm   
 
Ok, I gave it a go this morning and this is what happened:

I changed the code for <b>"That direction has already been stripped clean."</b> but zMUD failed to recognize <b>{#ADD MineDir +1}</b>...it ended up just being <b>{#ADD MineDir 1}</b>. So, when I got the message, it showed the number <b>1</b> and tried to </b>mine 1</b>, not mine in the next direction. I then tried to list each direction because list assigns the direction to a number...so <b>list="e|w|s|n|u|d"</b> gave me <b>e = 1</b>, <b>w = 2</b>, and so on.

I added the variables and assigned them the value of 0, and set up the alias for gomine. I also went into the dig trigger command and changed the instances of <b>mine @MineDir</b> to <b>gomine</b>. I tried this and with no success, I changed the value of the number in the <b>#IF ((@IronMined - @BIron) > #) {#SH That direction has already been stripped clean.}<b>

So, after much frustration, I gave up on it. I'll just have to manually change the direction by setting the <b>#var MineDir</b> in the trigger line MUDside, unless there is some other way to go at it.
Code:
_________________
Live outside the box, you can see alot better from there.

- Myself
Reply with quote
Kariyana
Beginner


Joined: 02 Feb 2004
Posts: 10
Location: Canada

PostPosted: Tue Aug 10, 2004 1:49 pm   
 
Oh and btw, gomine loops and sets all of the ore variables over and over, I had to delete 338 instances of them :P
_________________
Live outside the box, you can see alot better from there.

- Myself
Reply with quote
SCORNME
Novice


Joined: 25 Jul 2004
Posts: 48
Location: aka Falan

PostPosted: Wed Aug 11, 2004 5:57 am   That's why it says [i]newbie[/i] under my name
 
I didn't see a reference to a direction name, so I thought you were sending the numbers 1-5. Oops! And, why ">=5"? What happens when you try to mine in the 5th direction? Is there a 5th direction?

gomine shouldn't have looped, unless you were sending "gomine @MineDir"! And, it should only have updated those 6 variables - not created 338+ ! At least that was the idea. But, since gomine was causing problems with tracking how much you'd mined, just delete it and the #IF statement. The loop was most likely caused by the #IF statement's expression. I wasn't sure of the syntax for it. Sorry!

Code:

#VAR direction {n|e|s|w}
#trigger {That direction has already been stripped clean.} {
#IF (@DirToMine >= 5) {DirToMine=1} {
#ADD DirToMine 1
}
MineDir=%item(@direction,@DirToMine)
mine @MineDir
}

I think that should return the direction in @direction which corresponds to the number in @DirToMine. However, that adds up to 5 before resetting to 1, and there's no corresponding 5th direction.
Reply with quote
Kariyana
Beginner


Joined: 02 Feb 2004
Posts: 10
Location: Canada

PostPosted: Wed Aug 11, 2004 4:07 pm   
 
Ok, I went ahead and deleted all instances of #IF and such, and went in to modify the stripped clean trigger. This is what I have:

Code:

#IF (@DirToMine >= 5) {@DirToMine=1}
#ADD @DirToMine 1
MineDir=%item( @direction, @DirToMine)
mine @MineDir

and this is what it does mudside:

<920hp 1060m 835mv> mine w
That direction has already been stripped clean.

#IF (2 >= 5) {2=1}
mine east

<920hp 1060m 835mv>
<920hp 1060m 835mv> Huh?

<920hp 1060m 835mv> mine WHAT direction?

I tried spelling out the direction in the variable, have them as a list, and I tried making it just the short form direction. But neither were successful. I usually only get the 'mine WHAT direction?' when I either type out a direction other than n or north.

DirToMine is setting itself up as 2, an alias of 1 is being created with the value of 4 and the alias of 2 is being created with a value of 3.
_________________
Live outside the box, you can see alot better from there.

- Myself
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Wed Aug 11, 2004 5:50 pm   
 
The problem, it seems, at the moment, is that your #IF statement is not right. You put that you have:

#IF (@DirToMine >= 5) {@DirToMine=1}
#ADD @DirToMine 1

While SCORNME put down:

#IF (@DirToMine >= 5) {DirToMine=1} {
#ADD DirToMine 1
}

Now, firstly, SCORNME's trigger is all one line:

#trigger {That direction has already been stripped clean.} {{#IF (@DirToMine >= 5) {DirToMine=1} {#ADD DirToMine 1}};MineDir=%item(@direction,@DirToMine);mine @MineDir}


Two, when you fixed yours, you used {@DirToMine=1}. @DirToMine will give the value of DirToMine, which in that instance of yours was 2. When you set a variable, you don't want to use the @ symbol before it. Plus, you separated the #ADD statement from the #IF statement.

The intent of the #IF statement is to set DirToMine to 1 if it is at 5 or more, and if it is less than 5, to add one to DirToMine. The question was asked, probably because the thinking is n,s,e,w equals 4 directions, why you used 5. Do you have DirToMine set up for more than four directions? If so, then the comparison is understandable. If not, then you should change it to check if @DirToMine >= 4.
Reply with quote
Kariyana
Beginner


Joined: 02 Feb 2004
Posts: 10
Location: Canada

PostPosted: Thu Aug 12, 2004 4:04 pm   
 
Yay that worked! Now I know if I want to add in up or down, I can change the value with @DirToMine to 6 and add in up and down in the direction variable. Now my only problem is when I mine out a room and get no copper, it doesn't allow for me to keep mining.

ie: I mine out a wall, I get copper and sandstone. I fill my portal and continue to mine in the direction I was mining in. I start to dig up again, I only get sandstone and nothing happens. I want to continue to dig in that direction, but when it comes up again that I get two different minerals, I don't want to "double dig". Here is how it's set up now:

You dig up Sandstone and drop it on a stack!
#WAIT 5
#IF {@OreFound = 0}
#ABORT
#IF {@OreFound >= 1}
save
mine @MineDir

You dig up Copper ore and drop it on a stack!
#WAIT 100
#IF {@OreFound = 0}
fill por ore
mine @MineDir

I have three variables set up, one for StoneFound, one for OreFound, and one for GemFound (GemFound for when I get further down into the mines). Sandstone is listed in my variable for StoneFound and Copper ore is in my OreFound one. Should I change the variable in the Sandstone message to StoneFound and not OreFound?
_________________
Live outside the box, you can see alot better from there.

- Myself
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Thu Aug 12, 2004 11:39 pm   
 
I would mix all possible things you can mine into one variable like the direction variable we used before. Then trigger {You dig up * and drop it on a stack!} and its value with an if statement that when the * matches what you want it to(Copper Ore, ie) that it performs the actions you want.

Someone else may want to correct my trigger line and help you with the format for the #IF statement, but this approach should do it.
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