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...
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>
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?
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.
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.
<?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>
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
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...
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.
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.
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
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.
This line gets rid of what ever was in there before. In your case this was a time and day, so this will have gotten rid of that:
SetVariable ("total_gain"), ""
A better option would be to move it to a new sub:
sub OnPluginInstall
setvariable "total_gain",""
end sub
This will make it so each time the plugin is loaded it clears the value, 'but' only once, not every time you try to use it.
This is a problem:
ototal = GetVariable (total_gain)
getvariable requires a string. By leaving off the "" you are telling it to look in a VB variable called total_gain for a name that doesn't exist. It needs to be:
ototal = GetVariable ("total_gain")
This will work. The one you have for this will fail, because you don't tell it what they 'end' of the 'if' is actually at:
if IsEmpty (ototal) then
Note "Tracking Started."
end if
Here you have the opposite problem to when you tried to 'get' the value:
SetVariable ("total_gain"), "ntotal"
Your actually telling it here to store the value "ntotal" in totla_gain, not the contents of the variable ntotal. Change it to:
SetVariable "total_gain", ntotal
So the end result is:
<?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 OnPluginInstall
setvariable "total_gain",""
end sub
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."
end if
'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>
Thx Shadowfyr. I'll copy that too. But yeah. Now I'll juat have to get the ntotal to place proper commas, put in a command to reset the total PL gained to zero and maybe have it so you just type a command to see how much PL you've gained so far.
Ok. I woke up and now none of my scripts are working. This is really driving me nuts. I did everything I did the first time I got it to work and it isn't now. Giving me that same error I got the first time about the ototal and OnLever trigger stuff.
[EDIT]
Oh yeah. And Nick. The trigger you gave me isn't working. says Send-to-script cannot execute because scripting is not enabled. every time the trigger goes off.
I do have it enabled. Shift+Ctrl+6 and then click the little checkbox marked "Enable Script" Click 'OK' then it should be all good. But I used Shadowfyr's script there and this is the error I get.
Error number: -2146828275
Event: Execution of line 19 column 1
Description: Type mismatch: 'ototal'
Called by: Function/Sub: OnLevel called by trigger
Reason: processing trigger ""
I'm not sure what this means exactly, but it's confusing me.
And as for the trigger thing of yours Nick. I made the plugin as below since I have no idea how to use triggers the way you do.
<?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? -->
<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>
<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 " & GetVariable ("power")</send>
</trigger>
</triggers>
</muclient>
Then when I have "Enable Script" checked, I still get this kind of message.
You _traumatize_ A Newbie Fighter! [35]
Your power level increases by 6 points.
Send-to-script cannot execute because scripting is not enabled.
So I'm lost as to what's wrong. I know I'm a total newb, but hey, everyone is when they first start.
Error number: -2146828275
Event: Execution of line 19 column 1
Description: Type mismatch: 'ototal'
Called by: Function/Sub: OnLevel called by trigger
Reason: processing trigger ""
Take out that part that causes that. (or, if that is all there is, blank out the script file, so scripting is still enabled, but there is no file).
It's not a problem in compiling the script file. It's the bug that MUSHClient doesn't load the scripting engine if you don't use a script in a plugin, which is fixed in the next version. Just take the trigger Nick gave you, go to the Triggers window in MUSHClient, and press the "Paste" button... It'll work. Or, alternately, put this in the end of your plugin, above </muclient>:
This makes no sense to me. I open the trigger window (Shift+Ctrl+8) but I don't understand exactly where I'm pasting the trigger so it'll work. I mean, I'm totally lost here.
Perhaps a step by step instruction for this would help.
[EDIT]
Ok. Well I found the paste button which does all the work for me. Now I found that it was the ntotal = Int(ototal + cgain) line that's causing a problem in the script that I want to use. But I don't see what kind of conflict it's having with the rest. I mean, without that line, we can't get the ntotal which ultimately makes the script useless.
[EDIT]
Ok. New problem... *sigh*
Error number: -2146828282
Event: Execution of line 1 column 1
Description: Overflow: 'CInt'
Line in error:
Called by: Immediate execution
I don't know what this means... as usual...
[EDIT]
Bet you love the fact that I know how to edit posts eh?
Ok. I changed CInt to Int in both instances and it's working fine now. However, I wouldn't mind finding a way to put the commas back into the total number that's displayed.
Function fnAddCom(strNumber)
Dim strTemp
Dim intCounter
For intCounter = Len(strNumber) To 1 Step -1
If (((Len(strNumber) - intCounter) + 1) Mod 3) <> 0 Then
strTemp = strTemp & Mid(strNumber, intCounter, 1)
Else
If intCounter <> 1 Then
strTemp = strTemp & Mid(strNumber, intCounter, 1) & ","
Else
strTemp = strTemp & Mid(strNumber, intCounter, 1)
End If
End If
Next
For intCounter = Len(strTemp) To 1 Step -1
fnAddCom = fnAddCom & Mid(strTemp, intCounter, 1)
Next
End Function
Dang it Poromenos, I was right in the middle of coding and testing something to add commas myself and at the last minute scrolled down to see something only to find you had posted a solution right at the same time as I started writing mine. No fair... lol Anyway, yours is a bit shorter and less complex than mine anyway.
Ok. Let me put my newbie trigger script up here cause I don't know if that will work with what I'm using right now. And it's all about Nick's triggers.
http://www.badtrip-designs.com/PL_Tracker.xml
That is my script thing. I don't know if what you posted would work Poromenos, but god knows.
Let me know if there's anything different I could do to make this more effecient.
Ok Poromenos. How do I use that little tidbit you posted? I tried putting that in my little scripts that are run with various commands, but I can't get it to work.
Ok. Screw it. I don't know what the hell you people are talking about and I've just decided that this plugin is just a lost cause. I'll wait till someone else does something productive.
Function fnAddCom(strNumber)
Dim strTemp
Dim intCounter
For intCounter = Len(strNumber) To 1 Step -1
If (((Len(strNumber) - intCounter) + 1) Mod 3) <> 0 Then
strTemp = strTemp & Mid(strNumber, intCounter, 1)
Else
If intCounter <> 1 Then
strTemp = strTemp & Mid(strNumber, intCounter, 1) & ","
Else
strTemp = strTemp & Mid(strNumber, intCounter, 1)
End If
End If
Next
For intCounter = Len(strTemp) To 1 Step -1
fnAddCom = fnAddCom & Mid(strTemp, intCounter, 1)
Next
End Function
Now. This is what I think you are telling me to do. I have two variables. "power" and "battle" Where I placed them below is what I'm understanding which is prolly very wrong.
Function fnAddCom(strNumber)
Dim strTemp
Dim intCounter
For intCounter = Len(strNumber) To 1 Step -1
If (((Len(strNumber) - intCounter) + 1) Mod 3) <> 0 Then
strTemp = strTemp & Mid(strNumber, intCounter, 1)
Else
If intCounter <> 1 Then
strTemp = strTemp & Mid(strNumber, intCounter, 1) & ","
Else
strTemp = strTemp & Mid(strNumber, intCounter, 1)
End If
End If
Next
For intCounter = Len(strTemp) To 1 Step -1 power = fnAddCom & Mid(strTemp, intCounter, 1)
Next
End Function
Just wanted to know if this would work since I have so many damn triggers, many of which all perform the same function.
<trigger
enabled="y"
match="You stop training your *"
match="has reached it's peak for now."
match="is already at maximum."
regexp="y"
send_to="12"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
<send>SetVariable "battle", "0"
SetVariable "spar", "0"</send>
</trigger>
*crosses his fingers* Hopefully this works.
[EDIT]
It didn't. So now I have to find a way to have tree of my triggers in one kinda and then have them all perform the same SetVariable commands... Great...