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
➜ General
➜ Lets start the conversion.
Lets start the conversion.
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2 3
4
5
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #15 on Mon 13 Dec 2004 12:51 AM (UTC) Amended on Mon 13 Dec 2004 12:52 AM (UTC) by David Berthiaume
|
Message
| That's what I thought originally, but when I setup the triggers, the regular expressing XTL trigger, It didn't work. I setup the variable trigger, it wasn't working
Quote: <triggers>
<trigger
enabled="y"
group="InfoBarScript"
ignore_case="y"
keep_evaluating="y"
match="^\<(.*)\%HP\|(.*)\%Mana\|(.*)\%Move\> \<(.*)\>$"
regexp="y"
repeat="y"
send_to="12"
sequence="1"
>
<send>SetVariable ("aaHP", "%1")
SetVariable ("aaMana", "%2")
SetVariable ("aaMove", "%3")
SetVariable ("aaHunger", "%4")</send>
</trigger>
</triggers>
Also, I have Lua scripting enabled, however... when the triggers that send to script go off I get an error:
Send-to-script cannot execute because scripting is not enabled.
Also, ontop of that... when I reload the script, or make changes to it.
Error number: 0
Event: Run-time error
Description: [string "Script file"]:9: attempt to index global `var' (a nil value)
Called by: Immediate execution
I get that. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #16 on Mon 13 Dec 2004 12:57 AM (UTC) |
Message
| The runtime error disables the script, so it won't work. The runtime error talks about "var" being nil, which I presume is because you didn't add the extra code to your script file. I mentioned on page 1 of this thread:
Quote:
This looks a bit less cluttered. It relies upon this being in your main script file:
The "this" I talk about (directly below that statement) is necessary to make "var" work. It is on the posting, and also in the exampscript.lua file that ships with recent versions of MUSHclient. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #17 on Mon 13 Dec 2004 01:00 AM (UTC) |
Message
| Ok, I changed the script file to the examscript file that comes with 3.58, The script loaded this time around... But I got a different error...
Quote: Error number: 0
Event: Run-time error
Description: [string "Trigger: InfobarScript"]:11: attempt to index global `nvar' (a nil value)
Called by: Immediate execution
The Variable trigger, works quite well now that I got the scripting enabled properly.
But as you can see, there's an error there.
Quote: Don't just change over for the sake of it, if it is all working now I wouldn't bother changing.
I like the versitility of Lua over VBscript. Like the whole idea of being able to run a looping script in the background. That will come in very hand in the near future. I'm also thinking of checking out that whole notepad idea again, instead of using your multi-line infobar. I'm not to sure if that little window is capable of doing what I want, so I'll give notepads another shot.
The main issue I had, was in using multiple notepads. I couldn't figure out how to make the triggers use one notepad for 1 trigger, and a new notepad for a different trigger... Oh well, I'll get it eventually. Plus, I like the idea of changing the colours of the notepads. | Top |
|
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #18 on Mon 13 Dec 2004 01:05 AM (UTC) |
Message
| Ok, I added that part, I still get a run-time error.
I added:
var = {} -- variables table
-- warning - parenthesis must be on same line as setmetatable
setmetatable (var,
{
-- called to access an entry
__index =
function (t, name)
return GetVariable (name)
end;
-- called to change or delete an entry
__newindex =
function (t, name, val)
local result
if val == nil then -- nil deletes it
result = DeleteVariable (name)
else
result = SetVariable (name, tostring (val))
end
-- warn if they are using bad variable names
if result == error_code.eInvalidObjectLabel then
error ("Bad variable name '" .. name .. "'")
end
end;
})
Like you said... I think I might still be missing something.
The error:
Quote: Error number: 0
Event: Run-time error
Description: [string "Trigger: InfobarScript"]:11: attempt to index global `nvar' (a nil value)
Called by: Immediate execution | Top |
|
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #19 on Mon 13 Dec 2004 01:09 AM (UTC) |
Message
| Ok then:
var = {} -- variables table
nvar = {} -- number variables table
svar = {} -- string variables table
-- function called to change variables
function changevar (t, name, val)
local result
if val == nil then -- nil deletes it
result = DeleteVariable (name)
else
result = SetVariable (name, tostring (val))
end
-- warn if they are using bad variable names
if result == error_code.eInvalidObjectLabel then
error ("Bad variable name '" .. name .. "'")
end
end -- function changevar
setmetatable (var,
{
__index =
function (t, name)
return GetVariable (name)
end;
__newindex = changevar;
}
)
setmetatable (nvar,
{
__index =
function (t, name)
return tonumber (GetVariable (name)) or 0
end;
__newindex = changevar;
}
)
setmetatable (svar,
{
__index =
function (t, name)
return GetVariable (name) or ""
end;
__newindex = changevar;
}
)
Found the second part, I missed. I added that in as well, and it worked like a charm. Ok, now in my last posting I put up some of the code from the prior page, my question is: Is that first var () code debunk, due to the second but of var(), nvar(), and svar() code? Meaning, is ut redundant? | Top |
|
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #20 on Mon 13 Dec 2004 01:17 AM (UTC) Amended on Mon 13 Dec 2004 01:21 AM (UTC) by David Berthiaume
|
Message
| Lastly, can you gimme the link to the word replacement script you wrote in Lua... that was another reason I wanted to switch to Lua. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #21 on Mon 13 Dec 2004 02:26 AM (UTC) |
Message
| Yes, the first one is redundant because the second one replaces it. For a start, there is a new:
var = {}
This replaces whatever the first one might have done.
As for the word replacement script, you mean the one that fixes the capitalisation? That is on the first page of this thread. There is no link, it just about 8 lines of code.
You can copy and paste that into a command window (prefixing with the script prefix, usually "/") or use the "Immediate" window, or put it into the script file. All of these methods alter the "global script space" and are interchangeable.
You can experiment with this. Try doing something like:
a = 5
in the immediate window, and then in the command window type:
/print (a)
You should see 5 printed, which shows they are sharing the same script space. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #22 on Mon 13 Dec 2004 02:28 AM (UTC) |
Message
|
Quote:
I couldn't figure out how to make the triggers use one notepad for 1 trigger, and a new notepad for a different trigger...
When you do "AppendToNotepad" the first argument is the notepad title. A different title gives you a different window. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #23 on Mon 13 Dec 2004 03:42 AM (UTC) |
Message
| No, not the one that fixes the capitalization.
The one where you change the output of words.
I believe the example you used was the word "was", which you changed to "*WAS*" Or something like that, I searched the forums, but I haven't had any luck with it.
I know it's in there somewhere, I saw the posting about it. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #24 on Mon 13 Dec 2004 03:45 AM (UTC) |
Message
| |
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #25 on Mon 13 Dec 2004 03:47 AM (UTC) |
Message
| Ok, I'm a dolt... I found it:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4912&page=2
That's what I meant.
Quote:function my_trigger (name, line, wildcards, styles)
for _, v in pairs (styles) do
ColourNote (RGBColourToName (v.textcolour),
RGBColourToName (v.backcolour),
(string.gsub (v.text, "will", "*WILL*")))
end
end
First, could you explain this a little bit, the whole styles aspect of it that is.
Secondly, will this work as well?
Quote: for _, v in pairs (styles) do
ColourNote (RGBColourToName (v.textcolour),
RGBColourToName (v.backcolour),
(string.gsub (v.text, "will", "*WILL*")))
end
Placed in a trigger as send to script?
Haven't tested it, don't have the time right now, perhaps later on after work. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #26 on Mon 13 Dec 2004 04:41 AM (UTC) Amended on Mon 13 Dec 2004 04:45 AM (UTC) by Flannel
|
Message
| You can also (now) do that replacement on the packet level, if you want a trigger to match on *WILL* for whatever reason.
Which is also handy if you want it to be still in the output, and not a note. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| David Berthiaume
(202 posts) Bio
|
Date
| Reply #27 on Mon 13 Dec 2004 04:41 AM (UTC) Amended on Mon 13 Dec 2004 05:18 AM (UTC) by David Berthiaume
|
Message
| Ok, now that I have time to play around, this is my results.
-=Immortals=-
[ Eternal ] [AFK] Altair got owned by the dentist, (censored*)... got another round coming
*I censored the cuss word*
Now then... I wanted to replace the name Altair with Dummy, as a joke mind you, just to test it. It was the first name on the Immortal list, so poor Altair got to be the test dummy.
Now then, I successfully got the above mentioned script to replace the name... HOWEVER! It didn't come out quite as planned.
This was the result:
-=Immortals=-
[
Et
ern
al
]
[
AFK
]
Dummy got owned by the dentist, (censored)... got another round coming
UGLAH!
I should note however that there is a lot of colourized text in that. I'll break it down.
"[" is normal text colour
"Et" is dark cyan
"ern" is light cyan
"al" is dark cyan
"]" normal text colour
"[" dark blue
"AFK" light blue
"]" dark blue
The rest was in normal text colour.
It works great, but for some reason it doesn't like changes in text colour. XML trigger to follow.
<triggers>
<trigger
enabled="y"
keep_evaluating="y"
match="Altair"
omit_from_output="y"
regexp="y"
repeat="y"
script="textreplace"
sequence="100"
>
</trigger>
</triggers>
Any idea's?
Additionally, how does "or" work in Lua?
if (hunger = "H") or (hunger = "T") or (hunger = "HT") then
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #28 on Mon 13 Dec 2004 05:22 AM (UTC) |
Message
| First, the linebreaks. I suggest changing ColourNote to ColourTell. The ColourNote would do a new line for each style run (colour change).
As for the 'or', bear in mind that equality test is ==, you would say:
if (hunger == "H") or (hunger == "T") or (hunger == "HT") then |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #29 on Mon 13 Dec 2004 05:26 AM (UTC) |
Message
| Looks like my example was slightly wrong. Shows you can't believe everything you read. ;)
Still, changing to ColourTell should do it, followed by a final ColourNote to finish off the line. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
149,635 views.
This is page 2, subject is 5 pages long:
1
2 3
4
5
It is now over 60 days since the last post. This thread is closed.
Refresh page
top