Cool VL Viewer forum

View unanswered posts | View active topics It is currently 2024-04-27 17:10:12



Reply to topic  [ 5 posts ] 
I try to use a Lua function to send an automated answer 
Author Message

Joined: 2023-10-03 14:07:30
Posts: 43
Reply with quote
When I work in the G&S Butchery, after a product is delivered, I get a ScriptDialogOurs that says:
Your 'Carniceria / Butchery [G&S]'
Do you want to repeat the same process?
buttons: [Yes] [No]

I thought I could send an automated yes by using:

function OnScriptDialog(dialog_id, message, buttons)
if string.find(dialog_id, "ScriptDialogOurs") and string.find(message, " to repeat ") then
ScriptDialogResponse(id, "Yes")
print(message)
end
end

which doesn't work.

Would it be possible at all to give this automated answer from the automation script?
Thanks for looking into this.


2024-02-20 17:29:19
Profile

Joined: 2009-03-17 18:42:51
Posts: 5554
Reply with quote
It is quite possible that the "Yes" button is actually a " Yes " or "Yes " or " Yes" one, i.e. with one (or more) space before "Yes" or after it, in which case the reply you give won't be recognized by the script...


2024-02-20 17:47:00
Profile WWW

Joined: 2023-10-03 14:07:30
Posts: 43
Reply with quote
Henri Beauchamp wrote:
It is quite possible that the "Yes" button is actually a " Yes " or "Yes " or " Yes" one, i.e. with one (or more) space before "Yes" or after it, in which case the reply you give won't be recognized by the script...

Ah, I will try some variants. Thanks.


2024-02-20 17:53:15
Profile

Joined: 2009-03-17 18:42:51
Posts: 5554
Reply with quote
In fact, I did not notice at first (you know, blue text on blue background is painful to read for old eyes), but your code is all wrong... dialog_id is an UUID, not the script dialog type name, and you send 'id', which is not even defined in your code...

The right code would be:
Code:
function OnScriptDialog(dialog_id, message, buttons)
    if string.find(message, "Do you want to repeat the same process?") then
        ScriptDialogResponse(dialog_id, "Yes")
        print(message)
    end
end


2024-02-20 19:13:39
Profile WWW

Joined: 2023-10-03 14:07:30
Posts: 43
Reply with quote
Thank you for making it work!
In the mean time I had found out through a channel listener that the script sent "Yes" when I pushed the button and it still didn't work.
Sorry I just like the navy blue we used to write with in school, but I will stop using colours here.

Henri Beauchamp wrote:
In fact, I did not notice at first (you know, blue text on blue background is painful to read for old eyes), but your code is all wrong... dialog_id is an UUID, not the script dialog type name, and you send 'id', which is not even defined in your code...

The right code would be:
Code:
function OnScriptDialog(dialog_id, message, buttons)
    if string.find(message, "Do you want to repeat the same process?") then
        ScriptDialogResponse(dialog_id, "Yes")
        print(message)
    end
end


2024-02-20 19:31:53
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 33 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.