def flashlight(storage, obj, m): storage._go() tr = GlobalServices.getTextRenderer() ad = GlobalServices.getAudioDevice() storage._faceObject(m.getPlayer(), obj) if not storage._playerInDistance(m.getPlayer().position, obj.rect): tr.write("I can't reach that from here.", 3) else: # Bed scare sequence done if storage._getData('bedroom_bedscare_done'): # Add the flashlight to the inventory m.getPlayer().inventory.add(\ ItemFactory.create(INVENTORY_ITEM_FLASHLIGHT, 1)) ad.play(SOUND, 'pick_item', VOLUME_SOUND) tr.write("Got 'Flashlight'", 3, COLOR_GOT_ITEM) # Delete the note from the map m.removeObject(obj) remove_from_map(get_savegame(), OBJECT, 'bedroom', 'bedroom_flashlight') # Set a flag that this script was executed storage._setData('flashlight_obtained', True) # Add the global flashlight overlay, deleting the others flashlight = OverlayFactory.create_flashlight() set_global_overlays([flashlight]) # Add the overlay to this map, too m.clearOverlays() m.addOverlay(flashlight) ad.play(SOUND, 'flashlight_toggle', VOLUME_SOUND) ad.stop(SOUND, 1500, 'insanity_bug3') else: storage._toggleCutscene(True) tr.write("Sometimes I need my flashlight when the power tends to get all freaky.", 3) storage._wait(3000) tr.write("I don't know if that's because the mansion is just old or haunted, though.", 3) storage._toggleCutscene(False) storage._halt()
def load(self, name): # Point the shelf to be used to the additional argument set_shelf(name) # Open the save game shelf s = shelve.open(CURRENT_SHELF_FILENAME[0], "w") # Open the savegame dict s2 = get_savegame() # Set global overlays set_global_overlays(s['global_overlays']) # Copy shelf data to temp dict: exclude persistent stuff # that does not refer to "what the player has done gameplay-wise" copy_to_dict(s, s2, SHELF_PERSISTENT_KEYS) # Fadeout the (menu) music GlobalServices.getAudioDevice().stop(AudioDevice.MUSIC, FADEOUT_TIME) # Set persistently stored information like position and inventory self.gh.player.setPosition(s['player_position']) self.gh.player.setInventory(s['player_inventory']) # Re-play the saved ambient sounds and music GlobalServices.getAudioDevice().playList(s['current_sounds']) # Load the last map # Initialize the loading of testmap (for now) self.gh.initMapLoading(s['current_map']) # Finally, close the shelf again. s.close()