Royston123 Posted June 23, 2025 Posted June 23, 2025 I am trying to create a mod to notify me whenever courtier die. Currently I have 2 file: On action file I make like this: on_death = { events = { detailed_message.1 } } And event file I make like this: namespace = detailed_message detailed_message.1 = { hidden = yes trigger = { exists = scope:liege is_courtier_of = scope:liege } immediate = { save_scope_as = dead_character scope:dead_character = { send_interface_message = { type = character_has_died left_icon = scope:dead_character } } } } This do not work. Can anyone see what is problem for here?
Lyskorie Posted June 23, 2025 Posted June 23, 2025 A few problems: By directly nesting in events into a vanilla on_action, you are overriding the entire on_death vanilla on_action, which will break a lot of things. Call your own on_actions in it (since you can append on_actions), and put your events in there. You're firing the interface message in the scope of the dead character. Fundamentally pointless, as it's the dead character that would be receiving the notification, not you (or anyone else). 1
Royston123 Posted June 23, 2025 Author Posted June 23, 2025 23 minutes ago, Lyskorie said: A few problems: By directly nesting in events into a vanilla on_action, you are overriding the entire on_death vanilla on_action, which will break a lot of things. Call your own on_actions in it (since you can append on_actions), and put your events in there. You're firing the interface message in the scope of the dead character. Fundamentally pointless, as it's the dead character that would be receiving the notification, not you (or anyone else). Thank you for advice. What do you suggest is correct code?
magnonimous Posted June 23, 2025 Posted June 23, 2025 I would recommend reading the modding wiki entries for scopes and events, respectively. I'm not very familiar with on_actions but the scope should be something like: namespace = detailed_message detailed_message.1 = { hidden = yes trigger = { exists = scope:liege is_courtier_of = scope:liege } immediate = { save_scope_as = dead_character scope:dead_character = { top_liege = { # This scope might need to be changed send_interface_message = { type = character_has_died left_icon = scope:dead_character } } } } } And from what I can gather the on_action should look like this (double check this): on_death = { on_actions = { my_on_action } } my_on_action = { events = { detailed_message.1 } } 2
Royston123 Posted June 24, 2025 Author Posted June 24, 2025 18 hours ago, magnonimous said: I would recommend reading the modding wiki entries for scopes and events, respectively. I'm not very familiar with on_actions but the scope should be something like: namespace = detailed_message detailed_message.1 = { hidden = yes trigger = { exists = scope:liege is_courtier_of = scope:liege } immediate = { save_scope_as = dead_character scope:dead_character = { top_liege = { # This scope might need to be changed send_interface_message = { type = character_has_died left_icon = scope:dead_character } } } } } And from what I can gather the on_action should look like this (double check this): on_death = { on_actions = { my_on_action } } my_on_action = { events = { detailed_message.1 } } Thank to Lyskorie and magnonimous for try to explain problem. I have absolutely no knowledge of coding. I was try to create mod by examine working mods and reading moders wiki in CK3 wiki. When I read code I think it is saying this: namespace = detailed_message detailed_message.1 = { hidden = yes #I don't know why hidden is important but wiki say hidden so I use hidden trigger = { #I think trigger is condition for action to fire exists = scope:liege #is basically check if scope liege exist is_courtier_of = scope:liege # is check for if courtier is under scope:liege } immediate = { #I do not know purpose for immediate save_scope_as = dead_character #Create new scope named dead_character scope:dead_character = { #Here we take scope dead character and send message to top liege dead_character has die top_liege = { send_interface_message = { type = character_has_died left_icon = scope:dead_character } } } } } I try this and murder courtier with cheat but no message is send to my screen. I don't know if I am understanding correctly. I think it should be easy to send simple message when courtier die. Am I reading this properly or I am wrong?
Lyskorie Posted June 24, 2025 Posted June 24, 2025 1 hour ago, Royston123 said: Thank to Lyskorie and magnonimous for try to explain problem. I have absolutely no knowledge of coding. I was try to create mod by examine working mods and reading moders wiki in CK3 wiki. When I read code I think it is saying this: namespace = detailed_message detailed_message.1 = { hidden = yes #I don't know why hidden is important but wiki say hidden so I use hidden trigger = { #I think trigger is condition for action to fire exists = scope:liege #is basically check if scope liege exist is_courtier_of = scope:liege # is check for if courtier is under scope:liege } immediate = { #I do not know purpose for immediate save_scope_as = dead_character #Create new scope named dead_character scope:dead_character = { #Here we take scope dead character and send message to top liege dead_character has die top_liege = { send_interface_message = { type = character_has_died left_icon = scope:dead_character } } } } } I try this and murder courtier with cheat but no message is send to my screen. I don't know if I am understanding correctly. I think it should be easy to send simple message when courtier die. Am I reading this properly or I am wrong? Check your error logs to see if anything errors out. Also read the vanilla on_death interaction and the events in the death_management_events.txt file - they handle vanilla death notifs, among other things, and seems to be highly relevant to what you're doing. 1
magnonimous Posted June 27, 2025 Posted June 27, 2025 On 6/24/2025 at 10:49 AM, Royston123 said: Thank to Lyskorie and magnonimous for try to explain problem. I have absolutely no knowledge of coding. I was try to create mod by examine working mods and reading moders wiki in CK3 wiki. When I read code I think it is saying this: namespace = detailed_message detailed_message.1 = { hidden = yes #I don't know why hidden is important but wiki say hidden so I use hidden trigger = { #I think trigger is condition for action to fire exists = scope:liege #is basically check if scope liege exist is_courtier_of = scope:liege # is check for if courtier is under scope:liege } immediate = { #I do not know purpose for immediate save_scope_as = dead_character #Create new scope named dead_character scope:dead_character = { #Here we take scope dead character and send message to top liege dead_character has die top_liege = { send_interface_message = { type = character_has_died left_icon = scope:dead_character } } } } } I try this and murder courtier with cheat but no message is send to my screen. I don't know if I am understanding correctly. I think it should be easy to send simple message when courtier die. Am I reading this properly or I am wrong? Yeah, you are correct about what the code is doing! You have to put hidden to true (yes) if you don't want the event to pop up for the player (which I presume that you don't in this case, since you're sending an interface message). Apart from that I'd only check if: is_courtier_of = scope:liege is what you really want since, you then pop the interface message for `scope:top_liege`; i.e. perhaps it should be: is_courtier_of = scope:top_liege Everything under 'immediate' happens before the event is fired. Thus you can use variables or scopes declared in the immediate block before they are declared. Example: example_event.0001 { left_portait = { character = scope:root } right_portait = { character = scope:my_very_silly_scope } immediate = { scope:root.any_child.mother.any_sibling.top_liege.random_knight = { #scope-chaining save_scope_as = my_very_silly_scope } } } This is obviously not a functioning event, but just meant to show that you can use a scope declared in immediate, before it's declared in the code. Seems like you're getting on well though! Best of luck and happy bug hunting! 1
Royston123 Posted July 7, 2025 Author Posted July 7, 2025 (edited) On 6/26/2025 at 9:24 PM, magnonimous said: Yeah, you are correct about what the code is doing! You have to put hidden to true (yes) if you don't want the event to pop up for the player (which I presume that you don't in this case, since you're sending an interface message). Apart from that I'd only check if: is_courtier_of = scope:liege is what you really want since, you then pop the interface message for `scope:top_liege`; i.e. perhaps it should be: is_courtier_of = scope:top_liege Everything under 'immediate' happens before the event is fired. Thus you can use variables or scopes declared in the immediate block before they are declared. Example: example_event.0001 { left_portait = { character = scope:root } right_portait = { character = scope:my_very_silly_scope } immediate = { scope:root.any_child.mother.any_sibling.top_liege.random_knight = { #scope-chaining save_scope_as = my_very_silly_scope } } } This is obviously not a functioning event, but just meant to show that you can use a scope declared in immediate, before it's declared in the code. Seems like you're getting on well though! Best of luck and happy bug hunting! @Lyskorie @magnonimous Thank you for instruction. Is very helpful to me. I think problem is I have wrong scope but I already give up. I did not want to forgot to say the thank you. I thank you again very much for explain to me. I learn many new things from explanation. Maybe soon I will try again when I have more patient, and maybe you can explain my question. 👍 Edited July 7, 2025 by Royston123
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now