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 ➜ variables

variables

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


Posted by Mm1mark   (24 posts)  Bio
Date Sat 14 Feb 2009 12:17 AM (UTC)

Amended on Sun 15 Feb 2009 12:35 AM (UTC) by Mm1mark

Message
Ok i've just started using mush. and my friend helped me with scripts for my game using vb. my question is. Is it possible to call a list of variables in a window form 100>2, while auto updating everytime i improve.
my trigger
* You think your parry skill has improved. *
you have recieved 100 improves in parry.
i'm hoping for something thats like
parry 100
control 99
something like that. it gets to be a hassle opening variable window when i want to check variables.
i have it set up at moment to do something like skill*
skill parry
parry 100.

Ok. after many hours of reading. i've found the miniwindow options. i can't seem to reposition it. so it takes up top right to lower right. i'm trying to get it to getVariablelist
and have it displayed in the window. but it keeps getting sent to output window. any suggestions on how to add the 2 together? i'm fine with it taking up right side. though i need to get rid of that light blue background.
Top

Posted by Mm1mark   (24 posts)  Bio
Date Reply #1 on Sat 21 Feb 2009 10:09 PM (UTC)

Amended on Sat 21 Feb 2009 10:42 PM (UTC) by Mm1mark

Message
Figured easier for me to keep track of one post.
I'm currently trying to work on a trigger timer.
* You think your %2 skill has improved. *
is the trigger. i have it set up to send to world. my script has it set up to display number of improves. i'm trying to make the timer work in conjunction with the trigger to display time since last.
5:00:00 pm
you think your brawling skill has improved.
brawling 100
5:00:02 pm
you think your parry skill has improved
parry 200
5:03:00 pm
you think your brawling skill has improved
brawling 101
time since last brawling improve 3 minutes.
5:04:00 pm
you think your parry skill has improved.
parry 201
time since last parry improve 3 minutes 58 seconds
i'm trying to make it universal so everytime i improve it goes back to the last time i improved that skill. so if ones sent to world and the other has to be sent to script how can i do this. open for ideas and thoughts.
my current setup bypasses my improve counter.
so while it displays the time difference it stop counting and displays no improve #. thats set in a trigger geting sent to script. i'm sure i did something backwards but not sure what. so i scrapped and am now starting at square one.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #2 on Sat 21 Feb 2009 10:47 PM (UTC)
Message
It isn't clear to me what you are doing exactly. Can you please copy the exact triggers/timers you are using like this:

http://mushclient.com/copying

That way we can see what exactly you are up to.

- Nick Gammon

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

Posted by Mm1mark   (24 posts)  Bio
Date Reply #3 on Sat 21 Feb 2009 11:15 PM (UTC)

Amended on Sat 21 Feb 2009 11:32 PM (UTC) by Mm1mark

Message
sub mytest(name,line,wildcards)
Dim myVar
Dim mySkill, skillFirst, skillLast
Dim twoWord
mySkill = wildcards(2)


twoWord = InStr(mySkill, "'")
if(twoWord > 0) then '
skillFirst = left ( mySkill, twoWord - 1 )
skillLast = right ( mySkill, len(mySkill) - twoWord)
mySkill = skillFirst & skillLast
end if

twoWord = InStr(mySkill, "-")
if(twoWord > 0) then '
skillFirst = left ( mySkill, twoWord - 1 )
skillLast = right ( mySkill, len(mySkill) - twoWord)
mySkill = skillFirst & skillLast
end if

twoWord = InStr(mySkill, "#")
if(twoWord > 0) then '
skillFirst = left ( mySkill, twoWord - 1 )
skillLast = right ( mySkill, len(mySkill) - twoWord)
mySkill = skillFirst & skillLast
end if
twoWord = InStr(mySkill, " ")
if(twoWord > 0) then '
skillFirst = left ( mySkill, twoWord - 1 )
skillLast = right ( mySkill, len(mySkill) - twoWord)
mySkill = skillFirst & "_" & skillLast
end if

myVar = getVariable(mySkill)
if isEmpty (myVar) then
note "Not Tracking this skill yet!!"
setVariable mySkill, 1
else
myVar = myVar + 1
setVariable mySkill, myVar
note " You have received " & myVar & " improvements in: " & mySkill
world.sound "ding.wav"
end if
end sub


sub save (name)
world.save ""
end sub


sub repeat_command (name, line, wildcards)
dim number
dim comm
dim preamb
dim post
if(InStr(line, "^")) then
number = mid(line, 2, InStr(line, " ")-1)
comm = right(line, len(line) - InStr(line, " "))
if(IsNumeric(number) = 0) then
note("Wrong syntax!!")
exit sub
end if
i=1
number = cint(number)
do while i <= number
preamb = left(comm, instr(comm,"^")-1)
if( len(preamb) < len(comm)-1 ) then
post = right(comm, len(comm)-instr(comm,"^"))
end if
send(preamb & i & post)
i = i+1
loop
else
number = mid(line, 2, InStr(line, " ")-1)
if(IsNumeric(number) = 0) then
note("Wrong syntax!!")
exit sub
end if
comm = right(line, len(line) - InStr(line, " "))
number = Cint(number)
do while number > 0
send(comm)
number = number - 1
loop
end if
end sub


is my script

barrowed from plugin's level_timer and adjusted for me.


<triggers>
<trigger
enabled="y"
match="^(&gt; )?\* You think your ([a-z#_\' -]*) skill has improved\. \*"
regexp="y"
script="mytest"
send_to="12"
sequence="100"
>
<send>sub mytest (name, line, wildcards)
dim oldtime
dim newtime
dim days, hours, minutes
dim s1, s2, s3
dim msg

oldtime = GetVariable ("last_%2_improve_time")

'
' First time - just remember when we levelled

'
if IsEmpty (oldtime) or not IsDate (oldtime) then
SetVariable "last_%2_improve_time", now
Note "Level time noted."
exit sub
end if

'
' Find total minutes it took to improve
'
minutes = DateDiff ("n", CDate (oldtime), Now)

'
' Convert to days, hours, minutes
'

days = Fix (minutes / 1440)
minutes = minutes - (days * 1440) ' remainder
hours = Fix (minutes / 60)
minutes = minutes - (hours * 60) ' remainder

'
' Add "s" if plural
'
s1 = "s"
s2 = "s"
s3 = "s"
if days = 1 then s1 = ""
if hours = 1 then s2 = ""
if minutes = 1 then s3 = ""

'
' Make message
'

msg = "Time to level = " _
&amp; days &amp; " day" &amp; s1 &amp; ", " _
&amp; hours &amp; " hour" &amp; s2 &amp; ", " _
&amp; minutes &amp; " minute" &amp; s3 &amp; "."

ColourNote "white", "blue", msg
SetVariable "last_%2_improve_time", now

end sub

</send>
</trigger>
</triggers>

if i disable timer and reload script my counter works. with timer enabled it quits counting or displaying # of improves.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #4 on Sun 22 Feb 2009 10:52 PM (UTC)
Message
For a start, this won't work:


<triggers>
  <trigger
   enabled="y"
   match="^(&gt; )?\* You think your ([a-z#_\' -]*) skill has improved\. \*"
   regexp="y"
   script="mytest"
   send_to="12"
   sequence="100"
  >
  <send>

sub mytest (name, line, wildcards)

' blah blah blah

end sub

</send>
  </trigger>
</triggers>



Making a sub like that only defines "mytest", it doesn't execute it. Take a look at my examples on:

http://www.gammon.com.au/scripting

The sub stuff should be in the script file, not inside the trigger.

- Nick Gammon

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

Posted by Mm1mark   (24 posts)  Bio
Date Reply #5 on Thu 05 Mar 2009 04:14 PM (UTC)
Message
ok. fine tuning the timer to get exactly what i want but have the basics down.
next project. i'm not having much luck with the windows so i'm using note pad for now till i have it completly worked out. i'd like to have a timer every 30 seconds AppendToNotepad GetVariable list. but i'm not sure the easiest way to go about it.
would it be easier to put in script then have the timer call from script and append results to notepad?

<timers>
<timer name="skill_list" enabled="y" second="30.00" offset_second="0.00" send_to="7"
>
<send>world.GetVariableList ""</send>

</timer>
</timers>

I'm still a beginner so bear with me. i no whats displayed will just put world.getvariablelist in the notepad window but i want the results of list...
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #6 on Thu 05 Mar 2009 07:43 PM (UTC)
Message
Try this. To execute a script inside a timer (like GetVariableList) you have to "send to script". Inside the script you can decide to output to a notepad window.


<timers>
  <timer name="skill_list" 
    enabled="y" 
    second="30.00" 
    send_to="12"
>
  <send>

dim varList

ReplaceNotepad "my_variables", ""

varList = GetVariableList

If Not IsEmpty (varList) Then
  
  For Each v In varList 
    AppendToNotepad "my_variables", v &amp; " = " &amp; GetVariable (v) &amp; VbCrLf
  Next

End If

</send>

  </timer>
</timers>


- Nick Gammon

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

Posted by Mm1mark   (24 posts)  Bio
Date Reply #7 on Fri 06 Mar 2009 03:17 AM (UTC)
Message
thanks worked like i wanted. i had the basics right was the structure i had wrong. keep up the great work.
Top

Posted by Mm1mark   (24 posts)  Bio
Date Reply #8 on Thu 19 Mar 2009 02:03 PM (UTC)
Message
is there a way to sort the list. either numerically or alphabetically? it just appears any old fashion or at least not in a way that makes sense to me.

oh is there a reason when i open variables and sort by the value it has 2 as being greater then 1700?
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #9 on Thu 19 Mar 2009 09:15 PM (UTC)
Message
There probably is a way under VB to sort them, offhand I don't know it. Under Lua it would be easy. :)

The variables in the variable list are stored as strings, and thus "2" is greater than "1700".

If you install the plugin below, written in Lua, it will show your world variables, in alphabetic order:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, March 20, 2009, 8:12 AM -->
<!-- MuClient version 4.40 -->

<!-- Plugin "Show_Variables" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Show_Variables"
   author="Nick Gammon"
   id="dffeb3db157e34ab0999a933"
   language="Lua"
   purpose="Shows world variables in alphabetic order in the main window"
   date_written="2009-03-20 08:11:14"
   requires="4.00"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Shows all world variables, in a notepad window, in alphabetic order.
]]>
</description>

</plugin>


<!--  Timers  -->

<timers>
  <timer 
  enabled="y" 
  second="30.00" 
  send_to="12"
>
  <send>

ReplaceNotepad ("World Variables", "")

varList = GetPluginVariableList ("")  -- get global variables

require "pairsbykeys"

if varList then

  for k, v in pairsByKeys (varList) do
    AppendToNotepad ("World Variables", k .. " = " .. v .. "\r\n")
  end -- for

end -- if

</send>

  </timer>
</timers>

</muclient>


- Nick Gammon

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

Posted by Mm1mark   (24 posts)  Bio
Date Reply #10 on Fri 25 Feb 2011 05:59 PM (UTC)
Message
^(.*?) You think that Uxmal\'s (.*?) skill has improved\. (.*?)$

I have multiple pets in Dartmud, and we can track them like our own. is there a way to piggy back pets off my script or do i need to redo one strictly for pets.

maybe adjust trigger to uxmal|scrap|new pets
but adjust variable to match each pets. then through in a plugin to save on spam from pet_variables.
Something like Uxmal_fighting 30
easier to stick to one topic since it has script already.
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.


37,222 views.

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.