Cool VL Viewer forum

View unanswered posts | View active topics It is currently 2024-10-11 03:15:29



Reply to topic  [ 5 posts ] 
I try to prevent deleting a locked item with a LUA script 
Author Message

Joined: 2023-10-03 14:07:30
Posts: 53
Reply with quote
When I'm trying to delete items in a skybox, it happens quite often that I hit the floor in stead. Ofcourse I locked the box but when I'm in a hurry I still say 'yes' once in a while when the system asks if I want to delete the object anyway. I thought I'd intercept that with LUA, but then I read in the manual for OnNotification(name, id, message), the note "for now alerts and group notifications do not trigger such an event".

I tried to make this work, but now I wonder if these are such alerts that will not trigger an event:

--Stop locked items from being taken into inventory
function OnNotification(name, id, message)
if string.find(name, "ConfirmObjectTakeLock") and string.find(message, " sure you want ") then
CancelNotification(dialog_id)
print(message)
end
end

--Stop locked items from being deleted: locked should be locked
function OnNotification(name, id, message)
if string.find(name, "ConfirmObjectTakeDelete") and string.find(message, " sure you want ") then
CancelNotification(dialog_id)
print(message)
end
end


2024-05-18 12:49:46
Profile

Joined: 2009-03-17 18:42:51
Posts: 5798
Reply with quote
Since these are alerts and not notifications, they are indeed not intercepted by Lua...

Alerts would need a different Lua callback since they expect a reply and cannot normally "just be cancelled" (ignored) without one proper reply.

I will see what can be done but, for now, you cannot intercept these.


2024-05-18 13:20:43
Profile WWW

Joined: 2023-10-03 14:07:30
Posts: 53
Reply with quote
Henri Beauchamp wrote:
Since these are alerts and not notifications, they are indeed not intercepted by Lua...

Alerts would need a different Lua callback since they expect a reply and cannot normally "just be cancelled" (ignored) without one proper reply.

I will see what can be done but, for now, you cannot intercept these.


Thank you. The CoolVL viewer is often safer for me than other viewers when I'm at work. I was trying to make a few things even safer.


2024-05-18 14:57:27
Profile

Joined: 2009-03-17 18:42:51
Posts: 5798
Reply with quote
Rejoice !

OnAlertDialog() callback and AlertDialogResponse() function implemented for tomorrow's releases...


2024-05-31 15:56:59
Profile WWW

Joined: 2023-10-03 14:07:30
Posts: 53
Reply with quote
Henri Beauchamp wrote:
Rejoice !

OnAlertDialog() callback and AlertDialogResponse() function implemented for tomorrow's releases...


Thank you very much for adding these!

This now prevents me from deleting or taking floors from under items that are not always easy to select. It comes handy when I do G&S farming and wine making:

--Stop locked items from being deleted: locked should be locked
function OnAlertDialog(name, dialog_id, message, buttons)
if string.find(name, "ConfirmObjectDeleteLock") and string.find(message, " sure you want ") then
AlertDialogResponse(dialog_id, 2)
print("You cannot delete this object since you locked it.")
else
--Stop locked items from being taken into inventory
if string.find(name, "ConfirmObjectTakeLock") and string.find(message, " sure you want ") then
AlertDialogResponse(dialog_id, 2)
print("You can not take the item as long as it is locked.")
end
end


2024-06-01 11:53:27
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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.