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.
Entire forum
➜ MUSHclient
➜ General
➜ Problem again with Logging
Problem again with Logging
|
You need to log onto the forum to reply or create new threads.
Refresh page
Pages: 1 2
Posted by
| Markomo
(28 posts) Bio
|
Date
| Sun 06 Oct 2024 10:32 PM (UTC) Amended on Mon 07 Oct 2024 09:29 AM (UTC) by Nick Gammon
|
Message
| Hello there I am again :)
I hope you can help me. I am using this alias to do research in Mud. Of course there are objects that don't exist because there is no description.
So when I run the alias I get the feedback “XY nicht gefunden.”
Now, if this happens, I want the alias not to save this in the log.
<aliases>
<alias
match="^b ([A-z]+)$"
enabled="y"
group="Forschen"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetLogInput (true)
vitem = "%1"
LogSend("untersuche "..vitem)
LogSend("lausche "..vitem)
LogSend("rieche "..vitem)
LogSend("beruehre "..vitem)
LogSend("fuehle "..vitem)
FlushLog()
</send>
</alias>
</aliases>
Now I have customized the alias.
<aliases>
<alias
match="^b ([A-z]+)$"
enabled="y"
group="Forschen"
regexp="y"
send_to="12"
sequence="100"
>
<send>
vitem = "%1"
SendNoEcho("untersuche "..vitem)
SendNoEcho("lausche "..vitem)
SendNoEcho("rieche "..vitem)
SendNoEcho("beruehre "..vitem)
SendNoEcho("fuehle "..vitem)
function CheckResult(result)
if not string.find(result, "nicht gefunden") then
SetLogInput(true)
LogSend("untersuche "..vitem)
LogSend("lausche "..vitem)
LogSend("rieche "..vitem)
LogSend("beruehre "..vitem)
LogSend("fuehle "..vitem)
FlushLog()
end
end
GetResponse("CheckResult")</send>
</alias>
</aliases>
But unfortunately Mushclient tells me this error.
[string "Alias: "]:22: attempt to call global 'GetResponse' (a nil value)
stack traceback:
[string "Alias: "]:22: in main chunk
Does anyone have any other ideas?
Thanks!
/edit: Ah, that's because the GetResponse function does not exist in the MUSHclient. The MUSHclient does not have a built-in system to wait directly for the server response and process it before taking any further action. Right? | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #1 on Mon 07 Oct 2024 09:30 AM (UTC) |
Message
| Yes. Did ChatGPT write that? It tends to make up functions it hopes exists.
Read this: http://www.gammon.com.au/forum/?id=4957
It shows how you can send something and wait for a response. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Markomo
(28 posts) Bio
|
Date
| Reply #2 on Mon 07 Oct 2024 09:45 AM (UTC) |
Message
|
Nick Gammon said:
Yes. Did ChatGPT write that? It tends to make up functions it hopes exists.
Read this: http://www.gammon.com.au/forum/?id=4957
It shows how you can send something and wait for a response.
Hello Nick!
First of all, thank you for answering me. No, I did not use ChatGPT. I had several browser tabs open at the time and used the wrong function.
I didn't even know that I could ask ChatGPT about it. Good to know, but I don't think an AI can help me here. That's where I need you! :)
But if I look at your link, I don't think I can implement the whole thing. My experience in Lua/Scripting is very basic.
Too bad. Thank you anyway.
BR | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #3 on Mon 07 Oct 2024 10:22 AM (UTC) |
Message
| Simple example from that page:
require "wait"
wait.make (function () --- coroutine below here
repeat
Send "cast heal"
line, wildcards =
wait.regexp ("^(You heal .*|You lose your concentration)$", 10)
until line and string.match (line, "heal")
-- wait a second for luck
wait.time (1)
Note ("heal done!")
end) -- end of coroutine
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #4 on Mon 07 Oct 2024 10:32 AM (UTC) |
Message
| OK, so you are basically sending "investigate XY" and you possibly might get the response "XY not found" or "XY (something else)".
So you could do what I posted above and send "investigate XY" and then wait for a line starting with "XY" and if it isn't followed by "not found" then log it and then do your next research, namely "listen XY" and so on.
Something like that. :) |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Markomo
(28 posts) Bio
|
Date
| Reply #5 on Mon 07 Oct 2024 11:07 AM (UTC) Amended on Mon 07 Oct 2024 11:08 AM (UTC) by Markomo
|
Message
|
Nick Gammon said:
OK, so you are basically sending "investigate XY" and you possibly might get the response "XY not found" or "XY (something else)".
So you could do what I posted above and send "investigate XY" and then wait for a line starting with "XY" and if it isn't followed by "not found" then log it and then do your next research, namely "listen XY" and so on.
Something like that. :)
That is correct. I send the alias “b boden” and get this output back:
b boden
untersuche boden
lausche boden
rieche boden
beruehre boden
fuehle boden
Text from untersuche
202/202AP 213/213PE 113EP 12:44> my Prompt
Text from lausche
202/202AP 213/213PE 113EP 12:44> my Prompt
Text from rieche
202/202AP 213/213PE 113EP 12:44> my Prompt
Text from berühre
202/202AP 213/213PE 113EP 12:44> my Prompt
Text from fühle
202/202AP 213/213PE 113EP 12:44> my Prompt
My current alias now saves the echo of my alias:
b boden
untersuche boden
lausche boden
rieche boden
beruehre boden
fuehle boden
It works perfectly! What I want now is. If I type in “b xdxdxd” I get
b xdxdxd
untersuche xdxdxd
lausche xdxdxd
rieche xdxdxd
beruehre xdxdxd
fuehle xdxdxd
Xdxdxd nicht gefunden. (it means in german "Xdxdxd not found."
202/202AP 213/213PE 115EP 13:00> my promot
Xdxdxd nicht gefunden.
202/202AP 213/213PE 115EP 13:00>
Xdxdxd nicht gefunden.
202/202AP 213/213PE 115EP 13:00>
Xdxdxd nicht gefunden.
202/202AP 213/213PE 115EP 13:00>
Xdxdxd nicht gefunden.
202/202AP 213/213PE 115EP 13:00>
That the echo (Commandecho/Inputecho?) I mean this:
b xdxdxd
untersuche xdxdxd
lausche xdxdxd
rieche xdxdxd
beruehre xdxdxd
fuehle xdxdxd
should not be saved in the log file. This is currently happening. It always saves the command output
I suspect that I need some kind of logic to check this and my skills are not sufficient for that. | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #6 on Mon 07 Oct 2024 10:19 PM (UTC) |
Message
| What do you see if the item *is* found? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Markomo
(28 posts) Bio
|
Date
| Reply #7 on Mon 07 Oct 2024 11:27 PM (UTC) Amended on Tue 08 Oct 2024 12:36 AM (UTC) by Markomo
|
Message
|
Nick Gammon said:
What do you see if the item *is* found?
Whatever the mud answers me. I will gladly describe it in English.
Player -> look floor
Mushclient Input Echo -> look flor
OutputMud ->The floor looks nice.
and if you haven't found something, the mud will tell you.
look wall
wall not found.
And I would like that when I get a result from mud like “look floor” that my command “look floor” is saved in the logfile.
But currently it also saves “look wall” and that's exactly what I don't want. | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #8 on Tue 08 Oct 2024 05:24 AM (UTC) |
Message
| Well, the simple approach is to make a trigger that omits "not found" from the log file, like this:
<triggers>
<trigger
enabled="y"
match="* nicht gefunden."
omit_from_log="y"
sequence="100"
>
</trigger>
</triggers>
|
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
That way, if you are logging, and something is not found, it just won't log that line.
You might conceivably also omit the prompt, as that would just clog up the log file. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Markomo
(28 posts) Bio
|
Date
| Reply #9 on Tue 08 Oct 2024 11:17 AM (UTC) |
Message
|
Nick Gammon said:
Well, the simple approach is to make a trigger that omits "not found" from the log file, like this:
<triggers>
<trigger
enabled="y"
match="* nicht gefunden."
omit_from_log="y"
sequence="100"
>
</trigger>
</triggers>
(pasting)
That way, if you are logging, and something is not found, it just won't log that line.
You might conceivably also omit the prompt, as that would just clog up the log file.
I want to save my alias commands echo and not the output from the mud in the log file. Currently it saves every command/echo from my alias.
But if the alias finds an item that contains “not found.”... I don't want the alias command to be saved. | Top |
|
Posted by
| Markomo
(28 posts) Bio
|
Date
| Reply #10 on Wed 09 Oct 2024 11:10 PM (UTC) |
Message
| hello nick.
I see that you don't have a solution to my problem either.
i still wanted to thank you for your time :)
thank you very much! | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #11 on Thu 10 Oct 2024 03:53 AM (UTC) |
Message
|
Quote:
look wall
wall not found.
...
But currently it also saves “look wall” and that's exactly what I don't want.
Your problem here is that you have already logged "look wall" before you find out that there is no wall there. So you have to rethink your approach.
For example, rather than have the client log your commands you could save them into a variable. Then when you get a response, other than "not found" then you manually log the command. See:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Markomo
(28 posts) Bio
|
Date
| Reply #12 on Thu 10 Oct 2024 05:20 AM (UTC) Amended on Thu 10 Oct 2024 05:50 AM (UTC) by Markomo
|
Message
|
Nick Gammon said:
Quote:
look wall
wall not found.
...
But currently it also saves “look wall” and that's exactly what I don't want.
Your problem here is that you have already logged "look wall" before you find out that there is no wall there. So you have to rethink your approach.
For example, rather than have the client log your commands you could save them into a variable. Then when you get a response, other than "not found" then you manually log the command. See:
(function=WriteLog)
thanks again nick. but that's exactly where i get stuck. that's where i would have needed your help.
I just don't have a clue.
--------------
i ask chatgpt (thanks for this information @nick). what do you think about it?
<aliases>
<alias
match="^b ([A-z]+)$"
enabled="y"
group="Forschen"
regexp="y"
send_to="12"
sequence="100"
>
<send>
local message = GetLineInfo(1)
local vitem = "%1"
if not string.find(message, "%w+ nicht gefunden") then
commands = {
"untersuche "..vitem,
"lausche "..vitem,
"rieche "..vitem,
"beruehre "..vitem,
"fuehle "..vitem
}
for _, cmd in ipairs(commands) do
LogSend(cmd)
end
FlushLog()
else
Note("Text mit 'nicht gefunden' erkannt. Befehle werden nicht ausgeführt.")
end
</send>
</alias>
</aliases>
-------------
another approach would be this
<aliases>
<alias
match="^b ([A-z]+)$"
enabled="y"
group="Forschen"
regexp="y"
send_to="12"
sequence="100"
>
<send>
local vitem = "%1"
commands = {
"untersuche "..vitem,
"lausche "..vitem,
"rieche "..vitem,
"beruehre "..vitem,
"fuehle "..vitem
}
local all_commands = table.concat(commands, "\n")
if not string.find(all_commands, "nicht gefunden.") then
for _, cmd in ipairs(commands) do
LogSend(cmd)
end
FlushLog()
else
Note("A command with 'nicht gefunden.' detected.")
end
</send>
</alias>
</aliases> | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #13 on Thu 10 Oct 2024 06:30 AM (UTC) |
Message
| ChatGPT can get things right. In this case it has ignored what I suggested. To help you further I need to see exactly what you see when you run your alias. I am guessing you don't see "my prompt" or "Text from lausche".
From your earlier post:
Text from untersuche
202/202AP 213/213PE 113EP 12:44> my Prompt
Text from lausche
202/202AP 213/213PE 113EP 12:44> my Prompt
Text from rieche
202/202AP 213/213PE 113EP 12:44> my Prompt
Text from berühre
202/202AP 213/213PE 113EP 12:44> my Prompt
Text from fühle
202/202AP 213/213PE 113EP 12:44> my Prompt
Copy and paste the exact MUD output from a successful attempt and an unsuccessful one. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Markomo
(28 posts) Bio
|
Date
| Reply #14 on Thu 10 Oct 2024 06:41 AM (UTC) Amended on Thu 10 Oct 2024 06:43 AM (UTC) by Markomo
|
Message
|
Nick Gammon said:
ChatGPT can get things right. In this case it has ignored what I suggested. To help you further I need to see exactly what you see when you run your alias. I am guessing you don't see "my prompt" or "Text from lausche".
From your earlier post:
Text from untersuche
202/202AP 213/213PE 113EP 12:44> my Prompt
Text from lausche
202/202AP 213/213PE 113EP 12:44> my Prompt
Text from rieche
202/202AP 213/213PE 113EP 12:44> my Prompt
Text from berühre
202/202AP 213/213PE 113EP 12:44> my Prompt
Text from fühle
202/202AP 213/213PE 113EP 12:44> my Prompt
Copy and paste the exact MUD output from a successful attempt and an unsuccessful one.
i use this alias atm:
--------------------
<aliases>
<alias
match="^b ([A-z]+)$"
enabled="y"
group="Forschen"
regexp="y"
send_to="12"
sequence="100"
>
<send>vitem = "%1"
LogSend("untersuche "..vitem)
LogSend("lausche "..vitem)
LogSend("rieche "..vitem)
LogSend("beruehre "..vitem)
LogSend("fuehle "..vitem)
FlushLog()</send>
</alias>
</aliases>
-----------
i'll take a screenshot for you. i think that will help you the most.
https://ibb.co/Ldm9J7K (imagehoster)
as you can see, i execute the alias twice. yellow = it has found an object. this is also saved with the current alias.
then i run the alias again. it doesn't find the object and outputs “Xdxdxd not found.” for the alias, of course, it looks as if something has been found, because i get an output from mud. i want the alias not to save this in the logfile (see right side). but it currently does. | 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.
1,913 views.
This is page 1, subject is 2 pages long: 1 2
You need to log onto the forum to reply or create new threads.
Refresh page
top