Jump to content

CK2 Modding Quick Question Thread


Recommended Posts

So, your targeted decision is only a bracket problem.  If you view the image I have attached below, you'll see a nice feature of Notepad++.  Notepad++ will highlight in red the bracket that is currently closing any string.  Allowing you to quickly see where you might have an issue.  So in the picture you can see that "ALLOW" isn't closed until the end of the decision and that your "EFFECT" is within the allow.

 

(( Having Effect, Revoke_allowed, and AI_WILL_DO within the "Allow" bracket is whats giving you those three empty conditions. ))

 

post-766254-0-92731600-1490461420_thumb.png

 

What you need to do there is change it so that it looks like this... 

		allow	=	{ # Target requirements.
			prisoner	=	no # Target can't be in prison.
			NOT	=	{	trait	=	in_hiding	} # Target can't be 'in hiding'.
			in_command	=	no # Target shouldn't be leading troops.
			custom_tooltip	=	{ # Target shouldn't have been visited in the past 30 days.
				text	=	pervmod_visit_recovery
				NOT	=	{	has_character_flag	=	pervmod_visit_recovery	}
			}
		}

Adding another bracket at the end of the allow string is the only change I made.  I did load up the game and test to see that the decision was available now and did not have the 3 empty conditions.

 

--------------------------------------------------

 

To change the minimum age of something, under "POTENTIAL" just add a line "age = 14" and it will be allowed for anyone 14 and past.

"min_age" is not an acceptable condition.

 

For a list of conditions that can be used check out the wiki.  http://www.ckiiwiki.com/Conditions

Link to comment
  • 3 months later...

Oh my gawsh, I hope this topic is checked!

Can someone explain please! Or link to a guide or something, explaining how to what what/where/when of

 

ROOT. FROM and FROMFROM

 

Basically I've no idea how to make sure I'm scoping (is that the right term?) to who I want. It's infuriating.

 

I've managed to scrape together some complexish personal mods, but it's all from editing someone else's base, then just reloading the game 30 times in a row as I trial and error different arrangements of FROM, who, ROOT  etc over 2 hours.

Link to comment

Hi. Yes, scoping is the right term.

As a routinary piece of advice, check the ckiiwiki pages on scripting and scopes.

 

As a general rule, root is the scope a bloxk (a part of an event/decision/ec.) started pointing to.

If the current wvent was sent by another event/decision, from points to the root scope of that other event or decision and so on.

 

Events that are fired from certain on_actions use from and sometimes fromfrom in different ways (check the comments in the on_action files) as well as targeted decisions, biulding definitions, etc.

 

In you are using some complex scoping schemes, it might be worth using event targets.

 

And also, if you're using complex patterns, try and use explanatory comments as much as you need so that if you return to the code one month later, you can remember at a glance what does the code do.

Link to comment

As a general rule, root is the scope a bloxk (a part of an event/decision/ec.) started pointing to.

...right... what is "started pointing to"? For example a brand  new event, called by a targeted decision, I right click on someone, who/what is the ROOT?

---Here's an example---

 

Let's say I want to mod a conversation in. I'm the ruler of course. I right click on a character (called Bob), choose my targeted decision and in the event I want to:

 

Compare my intrigue, to Bobs intrigue.

 

If my intrigue is higher than Bobs,

then I get an Opinion Modifier

 

If Bobs' Intrigue is higher than me

He gets an OpinonModifer.

 

If our intrigue is the same

An entirely different charater - MY wife

Gets an opinion modifier.

 

How exactly would that look  please? Who is the from/root etc please?

Link to comment

 

As a general rule, root is the scope a bloxk (a part of an event/decision/ec.) started pointing to.

...right... what is "started pointing to"? For example a brand  new event, called by a targeted decision, I right click on someone, who/what is the ROOT?

---Here's an example---

 

Let's say I want to mod a conversation in. I'm the ruler of course. I right click on a character (called Bob), choose my targeted decision and in the event I want to:

 

Compare my intrigue, to Bobs intrigue.

 

If my intrigue is higher than Bobs,

then I get an Opinion Modifier

 

If Bobs' Intrigue is higher than me

He gets an OpinonModifer.

 

If our intrigue is the same

An entirely different charater - MY wife

Gets an opinion modifier.

 

How exactly would that look  please? Who is the from/root etc please?

 

 

When you start a block -say, an event's trigger, immediate or option-, the things there refer to an object. For example, if you put "prestige = 100" into a character_event's trigger, you are asking the person who received the event, if it has at least 100 prestige. The person who receives the event is "the starting point", so to speak, of the event, that is, the ROOT scope. 

 

So you can do e.g.

trigger = {
  prestige = 100 #this is in ROOT scope
  any_child = { #this is a scope change, so code inside here is pointing to any_child.
    employer = ROOT # asking if the emplyer of any child is ROOT. That is, asking if any child of ROOT is at it's court.
  }
}

So for your "conversation" example:

1) You use a targeted decision on Bob. Bob is the ROOT of the targeted decision and you are the FROM of the targeted decision (this is a special case).

2) if inside the targeted decision's effect you send an event to yourself with FROM = { character_event = { id = youreventid } }, then IN THE EVENT, you are ROOT (the person who receives the event) and Bob is FROM (the person from whom the event was sent.

3) the effect you want would be something like this 

#the block starts refering to ROOT.
FROM = {
  if = {
    limit = { 
      attribute_diff = { #checks if enclosing scope (FROM, Bob) have at least 1 more points of intrigue than ROOT (you).
        character = ROOT
        attribute = intrigue
        value = 1
      }
    }
    #Do some stuff to FROM
  }
}
break = yes #exit the option/immediate here, since we don't want to do the rest.
if = {
  limit = {
    attribute_diff = { #checks if enclosing scope (FROM, Bob) have at least 1 more points of intrigue than ROOT (you)
      character = ROOT
      attribute = intrigue
      value = 1
    }
  }
  #Do some stuff to FROM
}
break = yes #exit the option/immediate here, since we don't want to do the rest
spouse = { #this is a scope change, things in here are done to the spouse. Note: this is lazy scripting that assume that ROOT is monogampous. I don't know if this equates to primary_spouse for characters with polygamy, but you get the gist of it.
  #Do stuff to the spouse
} 

This should give you a sense of it. I didn't put the opinion part, because opinions go from one character to another and you didn't specify who do you want the opinions going to.

Link to comment

Oh wow, I feel like my eyes have been opened. I've had a shattering day, and can't really focus, but your opening made so much sense to me  upon reading.

I'll look tomorrow with fresh eyes, and give proper feedback. But just wanted to say thank you immediately so you know this is very much being read and incredibly appreciated.

-But my initial reaction is ''yes - at last!''.

 

Thanks man.

Link to comment

Age can only be changed throgh the console.

 

You can reload all events (reloadevents console command), all the gui files (reloadinterface console command) reload a single .gui file )(reload <namefile> console command), or all the localisation (reloadloc console command). Note that such reloading might cause some glitches in the game until you reboot it, but normally it works when you're testing small modifications.

 

There is also a reloadtexture <texture name> that does not working ATM. The devs a re aware of the bugs so hopefully it'll get fixed sooner rather than later.

 

For all other files, you need closing and restarting the game to test, sorry.

 

Ah, also, if you put, say, a test.txt file in the folder immediately outside the mod folder, and write some CK2 script commands inside that file, you then can directly execute it with "run test.txt" in the console. Really handy to testing quick scripts (ROOT points yt your player character in there).

Link to comment

For all other files, you need closing and restarting the game to test, sorry.

Which is why it pays to have a strong PC for modding. The faster you load onto the game and world map, the sooner you can test things. Its not a big deal for simple mods, but when your mod gets bigger, loading 100's or 1000's of times is a god send.

Link to comment

Ok so I am trying to get names/pronouns into my description text. ngppgn has really helped me with his post so far, but I'm clearly still a little short on my understanding of scoping.

 

zbTMN2h.jpg

 

In the above image, ALBION is my character's name, I want it to say the name of the woman, Altruda . In the localisation file I've tried. [ROOT/FROM/FROMFROM/THIS/PREV.GetFirstName] but they all end up just being blank or saying my characters name, what command do I need please?

 

Targeted Decision >Character Event > Character Event > Character Event>Character Event

IS the chain upto this point. Is it just not possible to retrieve the info this deep?

Link to comment

Ok so I am trying to get names/pronouns into my description text. ngppgn has really helped me with his post so far, but I'm clearly still a little short on my understanding of scoping.

 

zbTMN2h.jpg

 

In the above image, ALBION is my character's name, I want it to say the name of the woman, Altruda . In the localisation file I've tried. [ROOT/FROM/FROMFROM/THIS/PREV.GetFirstName] but they all end up just being blank or saying my characters name, what command do I need please?

 

Targeted Decision >Character Event > Character Event > Character Event>Character Event

IS the chain upto this point. Is it just not possible to retrieve the info this deep?

Based on the screenshot, it should be from. But mind you, in localisation it has to be [From.GetFirstName], not [FROM.GetFirstName]. I hope that helps! If it doesn't post the events code.

Link to comment

in localisation it has to be [From.GetFirstName], not [FROM.GetFirstName].

 

 

lol that actually helped my dumb self, thanks, but didn't actually help in the specific instance I posted about :(

 

If you're really sure you want to look at the event, that'd be nice of you, but as I can just use gender neutral replacement words, it's not  big issue, and I'd rather not have you not burnt out to so you are unable to help me when I have a real problem lol. You're being so damn helpful, and I'm definitely already taking advantage, -but I don't wanna take the piss! It WOULD be good to LEARN why it does not work though.

 

Targeted Trigger>Character event> option IST.0101  arrives at:

 

 

namespace = IST

# Breaking1
	character_event = { 
	id = IST.0101
	desc = IST.0b1desc
	picture = GFX_evt_ksv.trainseduction1
	is_triggered_only = yes
#Broke1
	option = {
		name = ISToptionfurtherb0
		character_event = { id = IST.0102 }
			trigger = {
			FROMFROM = {
				NOR ={  
			trait = strong
			trait = proud
			trait = unyielding
			trait = wroth
			trait = brawny
			trait = stubborn 	
				}
			}
		        }
		} 	
#stubborn1
	option = {
		name = ISTstubborn1opt	
		character_event = { id = IST.0110 }
		trigger = {
			FROMFROM = {
				OR ={  
			trait = strong
			trait = proud
			trait = unyielding
			trait = wroth
			trait = brawny
			trait = stubborn 	
				}
			}
		}
	} 
}		
#Broke 2
	character_event = { 
		id = IST.0102
		desc = IST0b.2desc
		picture = GFX_evt_ksv.trainseduction2
		is_triggered_only = yes
		option = {
		name = IST0b.2option
		}
	}
#stubborn2
	character_event = { 
	id = IST.0110
	desc = ISTstubborn2desc
	picture = GFX_evt_ksv.trainseduction1
	is_triggered_only = yes
		option = {
		name = ISTstubborn2opt
		character_event = { id = IST.0111 }
		}
}	

 

 

The screen shot (that says Albion) is the text called by desc = IST0b.2desc under #Broke 2

which in my localisation file is:

IST0b.2desc;[FromFrom.GetFirstName] is helpless to stop their defilement, you mercilessly fuck them, strangle them, and tear at their skin. Beating them down. Ignoring their initial cries, and then relishing their quiet sobs. Finishing, you assess their pathetic state and notice they seem to have lost one of their rather more stubborn traits.;;;;;;;;;;;;;x

 

Btw the  PRIOR description call desc = IST.0b1desc

I have  [FromFrom.GetFirstName]  and that FromFrom calls her name just fine.

 

Link to comment

 

in localisation it has to be [From.GetFirstName], not [FROM.GetFirstName].

 

 

lol that actually helped my dumb self, thanks, but didn't actually help in the specific instance I posted about :(

 

If you're really sure you want to look at the event, that'd be nice of you, but as I can just use gender neutral replacement words, it's not  big issue, and I'd rather not have you not burnt out to so you are unable to help me when I have a real problem lol. You're being so damn helpful, and I'm definitely already taking advantage, -but I don't wanna take the piss! It WOULD be good to LEARN why it does not work though.

 

Targeted Trigger>Character event> option IST.0101  arrives at:

 

 

namespace = IST

# Breaking1
	character_event = { 
	id = IST.0101
	desc = IST.0b1desc
	picture = GFX_evt_ksv.trainseduction1
	is_triggered_only = yes
#Broke1
	option = {
		name = ISToptionfurtherb0
		character_event = { id = IST.0102 }
			trigger = {
			FROMFROM = {
				NOR ={  
			trait = strong
			trait = proud
			trait = unyielding
			trait = wroth
			trait = brawny
			trait = stubborn 	
				}
			}
		        }
		} 	
#stubborn1
	option = {
		name = ISTstubborn1opt	
		character_event = { id = IST.0110 }
		trigger = {
			FROMFROM = {
				OR ={  
			trait = strong
			trait = proud
			trait = unyielding
			trait = wroth
			trait = brawny
			trait = stubborn 	
				}
			}
		}
	} 
}		
#Broke 2
	character_event = { 
		id = IST.0102
		desc = IST0b.2desc
		picture = GFX_evt_ksv.trainseduction2
		is_triggered_only = yes
		option = {
		name = IST0b.2option
		}
	}
#stubborn2
	character_event = { 
	id = IST.0110
	desc = ISTstubborn2desc
	picture = GFX_evt_ksv.trainseduction1
	is_triggered_only = yes
		option = {
		name = ISTstubborn2opt
		character_event = { id = IST.0111 }
		}
}	

 

 

The screen shot (that says Albion) is the text called by desc = IST0b.2desc under #Broke 2

which in my localisation file is:

IST0b.2desc;[FromFrom.GetFirstName] is helpless to stop their defilement, you mercilessly fuck them, strangle them, and tear at their skin. Beating them down. Ignoring their initial cries, and then relishing their quiet sobs. Finishing, you assess their pathetic state and notice they seem to have lost one of their rather more stubborn traits.;;;;;;;;;;;;;x

 

Btw the  PRIOR description call desc = IST.0b1desc

I have  [FromFrom.GetFirstName]  and that FromFrom calls her name just fine.

 

 

Oh, then the portraits misled me (they seem to behave slightly differently compared to what I thought...

 

Anyway, the gist of the problem you are having is that for each event called with character/long_character/province/narrative_event you go "deeper" in the chain, the stack of FROMs also grows. So if you refer to a character with FROMFROM in IST.0b1desc  then in IST.0b2desc  you must refer to it with FROMFROMFROM.

 

So, In general, if in an event/decision ROOT = x FROM = y FROMFROM = z and you call a second event from it, in that second event FROM = x FROMFROM = y FROMFROMFROM = z and so on.

 

(There is one way to get further events to not have this behaviour, and is calling them with repeat_event, but that's a bit beyond the scope of this problem).

 

Edit: don't worry about "burning" me. If I know how and I have free time, I'm glad to help.

Link to comment

FromFromFrom... I could have absolutely fucking SWORE I tried that... bah!

Still sorted, my thanks once again! Thanks for being cool about it, out of curiosity, any idea how deep can a FROMFROM stack go? :shy:

 

It just seems such a strange language to me, why does it not just assign each individual their own ID to a variable? Would be a much more straight forward system, not having to keep track of  where you are in a stack.

 

Speaking of which, I am about to try my hand at variables for the 1st time in CK2... . Wish me luck!

 

Link to comment

FromFromFrom... I could have absolutely fucking SWORE I tried that... bah!

Still sorted, my thanks once again! Thanks for being cool about it, out of curiosity, any idea how deep can a FROMFROM stack go? :shy:

 

It just seems such a strange language to me, why does it not just assign each individual their own ID to a variable? Would be a much more straight forward system, not having to keep track of  where you are in a stack.

 

Speaking of which, I am about to try my hand at variables for the 1st time in CK2... . Wish me luck!

 

It is indeed a very awkward and ad-hoc language.

 

One curiosity, the CK2script calls "variable" only to variables that hold numbers.

What in other language would be variables of different types in ck2script is called "event targets.

WIthin an event chain, you can use save_event_target_as = some_name. That would save the current scope as a variable("event_target") which you can reference later.

 

For example, within an event immediate or option (but not within a trigger) you can do:

FROMFROM = {

  save_event_target_as = my_custom_target

}

 

And later down the event chain (but not outside of it) you can do

event_target:my_custom_target = {

  # do things to the character/province/title you saved before

}

 

There is also a global version: save_global_event_target_as = xx. These CAN be used outside the event-chain they were saved in.

 

You can chain up to 4 FROM (FROMFROMFROMFROM). 

Link to comment

Hmm I've got stuck :/

option = {
name = ISTstubborn0110opt2
character_event = { id = IST.0112 }	

	IF = {
          Limit ={ 
		check_variable = { which = global_ISTbks value = 1 }
		check_variable = { which = global_ISTbkw value = 1 }  
	  }
		FROMFROMFROM  = {
			random_list = {
			   50 = {remove_trait = stubborn}
			   50 = {remove_trait = wroth 	}
			}
		}
         }
}

I have earlier set

hidden_tooltip =set_variable = { which = global_ISTbkw value = 1 }

hidden_tooltip =set_variable = { which = global_ISTbks value = 1 }

 

I was hoping the IF would check that they were both =1, and then the 50/50 random trait loss.

But alas no. Nothing at all shows up on the options tooltip. Any tips please?

 

 

 

Link to comment

Argh!

What I did was test setting the variable, and check that it worked- it did yay- but I didn't like the variable being viewable- so edited it to hidden.

And then of course I set about testing the code I posted above to CHECK the variables in an IF statement and they didn't work- but not because I'd got that bit wrong- but because of the tooltip edit error to SETTING the variables, I'd just check worked. :s

 

Gawsh bleeding darn it! You have such amazing eyes. I'd NEVER have got that as I'd tested the variable setting to be working and was ignoring it in my attempts to fix it..

 

Wow. you're impressive.

 

I have another question --- and not yet I don't actually! - Double checked before posting and I'd left an erroneous bracket in my code. I'm learning! :P

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use