Cool VL Viewer forum http://sldev.free.fr/forum/ |
|
I try to prevent deleting a locked item with a LUA script http://sldev.free.fr/forum/viewtopic.php?f=6&t=2501 |
Page 1 of 1 |
Author: | RossoAms [ 2024-05-18 12:49:46 ] |
Post subject: | I try to prevent deleting a locked item with a LUA script |
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 |
Author: | Henri Beauchamp [ 2024-05-18 13:20:43 ] |
Post subject: | Re: I try to prevent deleting a locked item with a LUA scrip |
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. |
Author: | RossoAms [ 2024-05-18 14:57:27 ] | |||||||||
Post subject: | Re: I try to prevent deleting a locked item with a LUA scrip | |||||||||
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. |
Author: | Henri Beauchamp [ 2024-05-31 15:56:59 ] |
Post subject: | Re: I try to prevent deleting a locked item with a LUA scrip |
Rejoice ! OnAlertDialog() callback and AlertDialogResponse() function implemented for tomorrow's releases... |
Author: | RossoAms [ 2024-06-01 11:53:27 ] | |||||||||
Post subject: | Re: I try to prevent deleting a locked item with a LUA scrip | |||||||||
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 |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |