• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

KuzuX

degirlsawelshy fan
Dec 31, 2005
993
2
Well,last week i got bored and made an api-like thing to write hoi events in python.The event code became somewhat shorter and if there's a syntax error or an unrecognized command(not a logical error etc.), you can find it before testing it in-game,while converting.
This is an example code in python:
Code:
from doomsday import *

class e94000(Event):
	name = "Preparing for the '36 Election"
	desc = """Although the franchise was finally won for everyone in 1921, the old elites retained a significant influence over government, most notably due to their alliance with the Monarchy.All polls predict a socialist victory in the upcoming elections, unless something is done to prevent this."""
	date = Date(1936, 8, 1)
	offset = 5
	deathdate = Date(1936, 9, 3)
	country = "SWE"
	picture = "politics2"
	
	class trigger:
		t1 = NOT(Trigger("flag","ASD"))
	class a:
		ai_chance = 50
		name = "Let the Election Proceed without interference!"
		c1 = Command("dissent", value=-1)
		c2 = Command("sleepevent", which=94001)
		c3 = Command("domestic", which="democratic", value=1)
	class b:
		ai_chance = 50
		name = "Delay the Election and attempt to force a right-wing victory"
		c1 = Command("dissent", value=5) #Socialists are pissed off
		c2 = Command("sleepevent", which=94002)
		c3 = Command("domestic", which="democratic", value=-1)

class e94002(Event):
	name = "The Election of '36: Left-Wing Victory!"
	desc = "As polls predicted, the vast majority of the votes in the 1936 election fell to the left-wing parties, however, even this vote was very much divided, amongst the various left-wing factions. Almost anything could have altered the balance of power. Which of the following groups should form the new government?"
	date = Date(1936,9,4)
	deathdate = Date(1936,9,8)
	country = "SWE"
	picture = "politics2"
		
	class asd:
		ai_chance = 60
		name = "Per-Albin Hansson and the Social Democrats!"
		c1 = command(type="set_domestic",which="democratic",value=9)
		c2 = command(type="set_domestic",which="political_left",value=7)
		c3 = command(type="set_domestic",which="defense_lobby",value=-1)
		c4 = command(type="headofgovernment",which=7033)
		c5 = command(type="foreignminister",which=7038)
		c6 = command(type="armamentminister",which=7047)
		c7 = command(type="ministerofsecurity",which=7058)
		c8 = command(type="dissent",value=-5)
		c9 = command(type="trigger",which=94003)
		c10 = command(type="sleepevent",which=94004)
		c11 = command(type="sleepevent",which=94005)
	class dsad:
		ai_chance = 40
		name = "Zeth Hoglund and the Radical Leftists!"
		c1 = command(type="set_domestic",which="democratic",value=3)
		c2 = command(type="set_domestic",which="political_left",value=7)
		c1 = command(type="set_domestic",which="free_market",value=-1)
		c4 = command(type="dissent",value=5)
		c10 = command(type="sleepevent",which=94003)
		c11 = command(type="sleepevent",which=94005)
		c9 = command(type="trigger",which=94004)
and its output as an hoi event file
Code:
event={
id=94000
country=SWE
random=no
picture="politics2"

trigger={
not={
flag=ASD
}
}

name="Preparing for the '36 Election"
desc="Although the franchise was finally won for everyone in 1921, the old elites retained a significant influence over government, most notably due to their alliance with the Monarchy.All polls predict a socialist victory in the upcoming elections, unless something is done to prevent this."

date={day=1 month=august year=1936}
offset=5
deathdate={day=3 month=september year=1936}

action_a={
ai_chance=50
name="Let the Election Proceed without interference!"
command={type=dissent value=-1}
command={type=sleepevent which=94001}
command={type=domestic which=democratic value=1}
}
action_b={
ai_chance=50
name="Delay the Election and attempt to force a right-wing victory"
command={type=dissent value=5}
command={type=sleepevent which=94002}
command={type=domestic which=democratic value=-1}
}
}
event={
id=94002
country=SWE
random=no
picture="politics2"

name="The Election of '36: Left-Wing Victory!"
desc="As polls predicted, the vast majority of the votes in the 1936 election fell to the left-wing parties, however, even this vote was very much divided, amongst the various left-wing factions. Almost anything could have altered the balance of power. Which of the following groups should form the new government?"

date={day=4 month=september year=1936}
deathdate={day=8 month=september year=1936}

action_a={
ai_chance=60
name="Per-Albin Hansson and the Social Democrats!"
command={type=set_domestic which=democratic value=9}
command={type=sleepevent which=94004}
command={type=sleepevent which=94005}
command={type=set_domestic which=political_left value=7}
command={type=set_domestic which=defense_lobby value=-1}
command={type=headofgovernment which=7033}
command={type=foreignminister which=7038}
command={type=armamentminister which=7047}
command={type=ministerofsecurity which=7058}
command={type=dissent value=-5}
command={type=trigger which=94003}
}
action_b={
ai_chance=40
name="Zeth Hoglund and the Radical Leftists!"
command={type=set_domestic which=free_market value=-1}
command={type=sleepevent which=94003}
command={type=sleepevent which=94005}
command={type=set_domestic which=political_left value=7}
command={type=dissent value=5}
command={type=trigger which=94004}
}
}
 

unmerged(58571)

Field Marshal
Jul 1, 2006
6.288
0
Not really, with proper indentation and spacing events are quite easy to read - in fact, I find the initial python-code easier to read than its output despite never having touched a python.