Cool VL Viewer forum
http://sldev.free.fr/forum/

Is there a way to have Cool VL viewer auto accept objects?
http://sldev.free.fr/forum/viewtopic.php?f=6&t=2402
Page 1 of 1

Author:  RossoAms [ 2023-10-03 14:57:06 ]
Post subject:  Is there a way to have Cool VL viewer auto accept objects?

As a G&S farmer I get offered hundreds of objects during the harvest every day.
Would there be a way to auto accept these objects?
(I don't remember if there ever was a way to auto accept anything else but 'flat' items like animations, notecards etc. in Viewer 1).

Thanks for your patience. :D
Rosso.

Author:  Henri Beauchamp [ 2023-10-03 16:29:04 ]
Post subject:  Re: Is there a way to have Cool VL viewer auto accept object

While there is no such hard-coded function in the Cool VL Viewer, there is indeed a way, via Lua scripting...

Add (or merge, if you already make use of the OnNotification() callback) this code to your automation.lua script:
Code:
-- Put a list of the regions where you want to auto-accept stuff here:
offer_dialog_auto_accept = { ["Hunburgh"]=true, ["Morris"]=true }

function OnNotification(name, id, message)
   if name == "UserGiveItem" and string.find(message, " object named ") then
      local location = GetGridSimAndPos()
      if location and offer_dialog_auto_accept[location.region] then
         ScriptDialogResponse(id, "Keep")
      end
   end
end

Re-load the automation script from the "Advanced" -> "Lua" menu and enjoy.

It is even better than what a hard-coded feature could offer, because, as in this example, you can restrict it to a given list of locations (I used the sim names here, but you could restrict to parcels only: have a look at what data GetGridSimAndPos() offers), or you could even restrict it to some avatars (in OnNotification(name, id, message), 'message' contains the text of the inventory offer dialog, and it is in the form '<First_name> <Last_name> has given you a object named <something>')...

Note that there is a little trick, here, since ScriptDialogResponse() was designed and is documented to reply to script dialogs. However, it will work just as well for other dialogs.

Author:  RossoAms [ 2023-10-03 22:54:57 ]
Post subject:  Re: Is there a way to have Cool VL viewer auto accept object

Thank you very much. I'll give it a try.

Author:  RossoAms [ 2023-10-05 18:17:49 ]
Post subject:  Re: Is there a way to have Cool VL viewer auto accept object

Hello Henri,

when I run this script I still get the [Keep] [Discard] box from all the G&S objects like vines and fields. (
I have to click a G&S item and use one of the scripted buttons; then an item is offered.)

I probably overlooked something but it would be great to get it to work.

Author:  Henri Beauchamp [ 2023-10-05 20:44:42 ]
Post subject:  Re: Is there a way to have Cool VL viewer auto accept object

RossoAms wrote:
when I run this script I still get the [Keep] [Discard] box from all the G&S objects like vines and fields. (
I have to click a G&S item and use one of the scripted buttons; then an item is offered.)

My bad: I used the notification name for other residents giving an object to you... For scripted items giving you objects, replace name == "UserGiveItem" with string.find(name, "ObjectGiveItem"). And since there will not be any chat reminder in this case, you might want to print(message) too, like so:
Code:
function OnNotification(name, id, message)
   if string.find(name, "ObjectGiveItem") and string.find(message, " object named ") then
      local location = GetGridSimAndPos()
      if location and offer_dialog_auto_accept[location.region] then
         ScriptDialogResponse(id, "Keep")
         print(message)
      end
   end
end

To easily find the notification 'name' you are interested in, just trigger the action and look in the "Notifications console" (CTRL SHIFT 5, or "Advanced" -> "Consoles" ->"Notifications console...").

Author:  RossoAms [ 2023-10-05 21:20:29 ]
Post subject:  Re: Is there a way to have Cool VL viewer auto accept object

Works like a charm now!
Thank you so much!

No more switching to another viewer for the harvest! Yay!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/