Skip to content

Instantly share code, notes, and snippets.

@squiddy
Created May 8, 2013 14:53
Show Gist options
  • Save squiddy/5541001 to your computer and use it in GitHub Desktop.
Save squiddy/5541001 to your computer and use it in GitHub Desktop.
diff --git a/content/scenarios/tutorial_en.yaml b/content/scenarios/tutorial_en.yaml
index 3845ecc..1be531d 100644
--- a/content/scenarios/tutorial_en.yaml
+++ b/content/scenarios/tutorial_en.yaml
@@ -410,8 +410,7 @@ events:
- type: set_var
arguments: ["tutorial_progress", 16]
conditions:
- - type: time_passed
- arguments: [0]
+ - type: game_started
- # Tell the player to build the first building - lumberjack
actions:
diff --git a/horizons/scenario/actions.py b/horizons/scenario/actions.py
index 029efb5..ec66701 100644
--- a/horizons/scenario/actions.py
+++ b/horizons/scenario/actions.py
@@ -81,7 +81,7 @@ def show_logbook_entry_delayed(session, *parameters):
"""Adds an entry to the logbook and displays it.
On logbook close, displays a notification message defined in the YAML."""
session.ingame_gui.logbook.add_captainslog_entry(parameters, show_logbook=True)
- delay = MESSAGES.LOGBOOK_DEFAULT_DELAY
+ delay = 0#MESSAGES.LOGBOOK_DEFAULT_DELAY
callback = Callback(write_logbook_entry, session, parameters)
Scheduler().add_new_object(callback, session.scenario_eventhandler, run_in=Scheduler().get_ticks(delay))
diff --git a/horizons/scenario/conditions.py b/horizons/scenario/conditions.py
index 08eafab..49964b4 100644
--- a/horizons/scenario/conditions.py
+++ b/horizons/scenario/conditions.py
@@ -183,10 +183,9 @@ def building_in_range(session, building_class1, building_class2):
"""Checks whether there is a building_class2 in range of a building_class1."""
return _building_in_range_of(session, building_class1, building_class2)
-@register(periodically=True)
-def time_passed(session, seconds):
- """Returns whether at least *seconds* seconds have passed since the game started."""
- return (Scheduler().cur_tick >= Scheduler().get_ticks(seconds))
+@register()
+def game_started(session):
+ return True
@register()
def var_eq(session, variable, value):
@@ -266,4 +265,4 @@ def _building_in_range_of(session, building_class, *classes):
for building2 in settlement.buildings_by_id[other_class]: # iterate through all buildings of other_class
if building.position.distance( building2.position ) <= building.radius: # building in range of building2
return True
- return False # building not found in range
\ No newline at end of file
+ return False # building not found in range
diff --git a/horizons/scenario/scenarioeventhandler.py b/horizons/scenario/scenarioeventhandler.py
index 6d18b46..4400b54 100644
--- a/horizons/scenario/scenarioeventhandler.py
+++ b/horizons/scenario/scenarioeventhandler.py
@@ -79,14 +79,12 @@ class ScenarioEventHandler(LivingObject):
self.sleep_ticks_remaining = 0
- self.start()
-
-
def start(self):
# Add the check_events method to the scheduler to be checked every few seconds
Scheduler().add_new_object(self._scheduled_check, self,
run_in=Scheduler().get_ticks(self.CHECK_CONDITIONS_INTERVAL),
loops=-1)
+ self.check_events("game_started")
def sleep(self, ticks):
"""Sleep the ScenarioEventHandler for number of ticks. This delays all
diff --git a/horizons/session.py b/horizons/session.py
index d3f5335..1259fd5 100644
--- a/horizons/session.py
+++ b/horizons/session.py
@@ -121,6 +121,7 @@ class Session(LivingObject):
def start(self):
"""Actually starts the game."""
self.timer.activate()
+ self.scenario_eventhandler.start()
self.reset_autosave()
SettingChanged.subscribe(self._on_setting_changed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment