Cool VL Viewer forum

View unanswered posts | View active topics It is currently 2025-01-14 07:19:35



Reply to topic  [ 6 posts ] 
Is there a way to have Cool VL viewer auto accept objects? 
Author Message

Joined: 2023-10-03 14:07:30
Posts: 58
Reply with quote
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.


2023-10-03 14:57:06
Profile

Joined: 2009-03-17 18:42:51
Posts: 5899
Reply with quote
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.


2023-10-03 16:29:04
Profile WWW

Joined: 2023-10-03 14:07:30
Posts: 58
Reply with quote
Thank you very much. I'll give it a try.


2023-10-03 22:54:57
Profile

Joined: 2023-10-03 14:07:30
Posts: 58
Reply with quote
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.


2023-10-05 18:17:49
Profile

Joined: 2009-03-17 18:42:51
Posts: 5899
Reply with quote
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...").


2023-10-05 20:44:42
Profile WWW

Joined: 2023-10-03 14:07:30
Posts: 58
Reply with quote
Works like a charm now!
Thank you so much!

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


2023-10-05 21:20:29
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 2 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.