Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ Numerical calculator/tracker.

Numerical calculator/tracker.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  3  

Posted by Xyborg   Canada  (47 posts)  Bio
Date Sat 30 Aug 2003 12:03 PM (UTC)

Amended on Sat 30 Aug 2003 12:14 PM (UTC) by Xyborg

Message
Ok. My eyes hurt from reading and failed attempts at doing this so I've just decided to make my own bloody post.

What I'm trying to do is track how much experience I am getting.

"You gain 179,304 Experience!"

is the line I get when I kill something. Now what I want to do and have been trying to do, is take that number, write it somewhere, then take the next gain and add it to that. Once they are combined, I want to write that total somewhere, discard the others, and repeat the process.

I tried using the wizard and that's more confusing to me than when I first dived into C programming at the age of 12.

Any help would be greatly appreciated.

[EDIT]
Oh yeah. Version 3.42 of course. Gotta keep up to date with this stuff ya know...

We offer power to those willing to take it. Sadly, few are unburdened enough by their prejudices to accept.
Top

Posted by Xyborg   Canada  (47 posts)  Bio
Date Reply #1 on Sat 30 Aug 2003 01:30 PM (UTC)

Amended on Sat 30 Aug 2003 01:31 PM (UTC) by Xyborg

Message
Ok. I just punched all this crap into notepad after looking at the Level_Timer plugin of Nicks. I decided I'd use a DBZ mud since I figured it would be a little easier to work with. But for some reason, I can get it to load no problem, but I still think I'm a bloody moron and can't figure this VB stuff out. So please, if you know what I'm doing wrong, lemme know and tell me how to fix it.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient[
<!ENTITY trigger_match
"Your power level increases by * points." >
]>
<!-- Saved on Saturday, August 30, 2003, 6:31 AM -->
<!-- MuClient version 3.42 -->

<!-- Plugin "PL_Tracker" generated by Notepad? -->

<!--
Change the entity above to reflect the message you get when you gain powerlevel.
-->

<muclient>
<plugin
name="PL_Tracker"
author="Gar"
id="224913675cf54a90c032df56"
language="VBscript"
purpose="Displays how much PL you have gained this session"
save_state="y"
date_written="2003-08-30 06:31:00"
requires="3.24"
version="1.0"
>
<description trim="y">
<![CDATA[
When installed, this plugin will display how much PL you have gained so far.
]]>
</description>

</plugin>


<!-- Triggers -->

<triggers>
<trigger
custom_colour="7"
enabled="y"
match="&trigger_match;"
script="OnLevel"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
</trigger>
</triggers>

<!-- Script -->


<script>
<![CDATA[
sub OnLevel (name, line, wildcards)
dim cgain
dim ototal
dim ntotal
dim msg

ototal = GetVariable ("total_gain")

if IsEmpty (ototal) then
SetVariable "total_gain", now
Note "Tracking Started."
exit sub
end if

ntotal = Fix (ototal + cgain)

msg = "Total PL Gained = " _
& ntotal & "."

ColourNote "white", "blue", msg
SetVariable "total_gain", now

end sub

]]>
</script>


</muclient>

We offer power to those willing to take it. Sadly, few are unburdened enough by their prejudices to accept.
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #2 on Sat 30 Aug 2003 01:36 PM (UTC)
Message
OK, from what I see, you are not using the wildcards anywhere. wildcards(1) will give you the number of exp points, e.g. 197,120. You then need to remove the comma and add it to whatever you want. The rest of the code seems correct, but the ototal, cgain and ntotal variables boggle me. They are not set anywhere, are they?

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Xyborg   Canada  (47 posts)  Bio
Date Reply #3 on Sat 30 Aug 2003 01:38 PM (UTC)

Amended on Sat 30 Aug 2003 01:42 PM (UTC) by Xyborg

Message
I'm a moron. I prolly screwed everything up. I didn't set any variables anywhere, don't know how to remove that comma, and well, just started this scripting junk today.

I'm totally lost...

[EDIT]
Oh yeah. Don't know how to set variables either. I was just going by what I'd seen in that one plugin.

[EDIT2]
Oh. I can load it fine but when it tries to total the numbers and stuff it goes SPLAT and crashes my client with errors lol.

We offer power to those willing to take it. Sadly, few are unburdened enough by their prejudices to accept.
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #4 on Sat 30 Aug 2003 04:29 PM (UTC)

Amended on Sat 30 Aug 2003 04:39 PM (UTC) by Poromenos

Message

Function fnRemCom(strNumber)
    Dim intCounter
    Dim strTemp
    For intCounter = 1 To Len(strNumber)
        If Mid(strNumber, intCounter, 1) <> "," Then
            strTemp = strTemp & Mid(strNumber, intCounter, 1)
        End If
    Next
    fnRemCom = strTemp
End Function


This function will remove your commas, call it like this:

Note fnRemCom("103,120")

This would print 103120.

To get your experience gain you should do:
cgain = Int(fnRemCom(wildcards(1)))
and then cgain will be your current gain.

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #5 on Sat 30 Aug 2003 04:38 PM (UTC)
Message
Modded it a bit, here it is, enjoy:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Saved on Saturday, August 30, 2003, 6:31 AM -->
<!-- MuClient version 3.42 -->

<!-- Plugin "PL_Tracker" generated by Notepad? -->

<!--
Change the entity above to reflect the message you get when you gain powerlevel.
-->

<muclient>
<plugin
name="PL_Tracker"
author="Gar"
id="224913675cf54a90c032df56"
language="VBscript"
purpose="Displays how much PL you have gained this session"
save_state="y"
date_written="2003-08-30 06:31:00"
requires="3.24"
version="1.0"
>
<description trim="y">
<![CDATA[
When installed, this plugin will display how much PL you have gained so far.
]]>
</description>

</plugin>


<!-- Triggers -->

<triggers>
<trigger
custom_colour="7"
enabled="y"
match="Your power level increases by ((\d+)\,|)((\d+)\,|)(\d+) points\.$"
regexp="y"
script="OnLevel"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
</trigger>
</triggers>

<!-- Script -->


<script>
<![CDATA[
sub OnLevel (name, line, wildcards)
dim cgain
dim ototal
dim ntotal

'calculate the gain
cgain = Int(wildcards(2) & wildcards(4) & wildcards(5))
'get the previous gain
ototal = GetVariable ("total_gain")
'if there is no previous gain, note that we started tracking
if IsEmpty (ototal) then Note "Tracking Started."
'set ntotal to total gain
ntotal = Int(ototal + cgain)
'display it
ColourNote "white", "blue", "Total PL Gained = " & ntotal & "."
'store it
SetVariable "total_gain", ntotal
'we're done
end sub

]]>
</script>


</muclient>

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #6 on Sat 30 Aug 2003 04:39 PM (UTC)
Message
It was actually almost finished, you just need to remember to use "wildcards" to get your wildcards, and remember that "now" returns the system time :P

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #7 on Sat 30 Aug 2003 07:17 PM (UTC)
Message
Also, it is a lot easier to use 'replace' to remove that comma that the mess that Poromenos came up with. Just use:

match="Your power level increases by .* points\.$"

and

cgain = Int(replace(wildcards(1), ",", "")

This also saves having a mess of wildcards to deal with, since you only need one.
Top

Posted by Xyborg   Canada  (47 posts)  Bio
Date Reply #8 on Sat 30 Aug 2003 09:28 PM (UTC)
Message
Ok. I tried the one you posted Poromenos and I got some errors.

Error Number:
-2146828275
Event:
Execution of line 13 column 1
Description:
Type mismatch: 'ototal'
Called by:
Function/Sub: OnLevel called by trigger
Reason: Processing trigger ""

So that's what I got when I tried to start tracking the powerlevel.

I'm assuming it's the
ototal = GetVariable ("total_gain")
line that's causing the problem and I can't see why.

I've fiddled with what Shadowfyr had posted and I get a different error. I don't know what the hell could be wrong with it, but I'm still sitting here trying to figure it out.

Again, any help would be great. And I love you guys for, well, helping. It's more than what most people do in the other forums I dabble in.

[EDIT]
Geez. I really gotta remember to check that little box that enables the forum code...

We offer power to those willing to take it. Sadly, few are unburdened enough by their prejudices to accept.
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #9 on Sat 30 Aug 2003 10:08 PM (UTC)
Message
You should perhaps delete your old ototal variable, the saved value is messing with the plugin. Just add
SetVariable "total_gain", ""
in the beginning of the plugin, run it once, and then delete the line. It should work normally.

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Xyborg   Canada  (47 posts)  Bio
Date Reply #10 on Sat 30 Aug 2003 10:14 PM (UTC)
Message
Hrm... I added SetVariable "total_gain", "" just below dim ntotal and got the same error message but just a different line since I did put a couple more lines in.

God I wish I knew VB. Make my life so much easier.

We offer power to those willing to take it. Sadly, few are unburdened enough by their prejudices to accept.
Top

Posted by Xyborg   Canada  (47 posts)  Bio
Date Reply #11 on Sat 30 Aug 2003 11:16 PM (UTC)
Message
Ok. I've gotten it to run without errors, but it's not adding all the numbers together and displaying the total. Below is what I've got so far. No errors but no math being done either. Maybe it's because total_gain and ntotal aren't defined as integers. Just a thought though.



<?xml version="1.0" encoding="UTF-8"?>
<!-- Saved on Saturday, August 30, 2003, 6:31 AM -->
<!-- MuClient version 3.42 -->

<!-- Plugin "PL_Tracker" generated by Notepad? -->

<!--
Change the entity above to reflect the message you get when you gain powerlevel.
-->

<muclient>
<plugin
name="PL_Tracker"
author="Gar"
id="224913675cf54a90c032df56"
language="VBscript"
purpose="Displays how much PL you have gained this session"
save_state="y"
date_written="2003-08-30 06:31:00"
requires="3.24"
version="1.0"
>
<description trim="y">
<![CDATA[
When installed, this plugin will display how much PL you have gained so far.
]]>
</description>

</plugin>


<!-- Triggers -->

<triggers>
<trigger
custom_colour="7"
enabled="y"
match="Your power level increases by ((\d+)\,|)((\d+)\,|)(\d+) points\.$"
regexp="y"
script="OnLevel"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
</trigger>
</triggers>

<!-- Script -->


<script>
<![CDATA[
sub OnLevel (name, line, wildcards)
dim cgain
dim ototal
dim ntotal

SetVariable ("total_gain"), ""

'calculate the gain
cgain = Int(wildcards(2) & wildcards(4) & wildcards(5))
'get the previous gain
ototal = GetVariable (total_gain)
'if there is no previous gain, note that we started tracking
if IsEmpty (ototal) then Note "Tracking Started."
'set ntotal to total gain
ntotal = Int(ototal + cgain)
'display it
ColourNote "white", "blue", "Total PL Gained = " & ntotal & "."
'store it
SetVariable ("total_gain"), "ntotal"
'we're done
end sub

]]>
</script>


</muclient>

We offer power to those willing to take it. Sadly, few are unburdened enough by their prejudices to accept.
Top

Posted by Xyborg   Canada  (47 posts)  Bio
Date Reply #12 on Sun 31 Aug 2003 12:08 AM (UTC)
Message
Ok. cgain works fine, but ntotal, total_gain, and ototal aren't returning anything. I have them all posting a note displaying anything that they should, but nothing comes back.

We offer power to those willing to take it. Sadly, few are unburdened enough by their prejudices to accept.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #13 on Sun 31 Aug 2003 12:09 AM (UTC)

Amended on Sun 31 Aug 2003 12:11 AM (UTC) by Nick Gammon

Message
This looks incredibly complicated. I wouldn't use all those wildcards, the potential for confusion is very great.

Just one simple trigger:

Your power level increases by * points.

Don't really need a regular expression.

The trigger could do a simple script. In fact, this should do the whole thing ...


<triggers>
  <trigger
   enabled="y"
   match="Your power level increases by * points."
   send_to="12"
   sequence="100"
  >
  <send>SetVariable "power", CInt (GetVariable ("power")) + _
   CInt (Replace ("%1", ",", ""))
Note "Your power level is now " &amp; GetVariable ("power")</send>
  </trigger>
</triggers>



Remember, keep it simple. :)



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Xyborg   Canada  (47 posts)  Bio
Date Reply #14 on Sun 31 Aug 2003 12:20 AM (UTC)

Amended on Sun 31 Aug 2003 12:23 AM (UTC) by Xyborg

Message
Pull out your rifles and get ready to shoot me in the head.

It appears that my intelligence is below that of a simple monkey.

I guess it's better when you ENABLE SCRIPTING!

Man I feel so stupid right now.

[EDIT]
Oh yeah. Sorry if I made any of ya feel bad by saying it wasn't working.

Plus now I was wondering if there was a way to put the commas back in to the ntotal thing.

We offer power to those willing to take it. Sadly, few are unburdened enough by their prejudices to accept.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


109,630 views.

This is page 1, subject is 3 pages long: 1 2  3  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.