Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

I just wrote a guide here :

https://adventuron.io/docs/tut/#AdvancedDarkness

is_movement_command () is a boolean function that tests the logical sentence for anything that matches a compass direction. Essentially the is_inaccessible_darkness_verb boolean dynamic variable returns true if it's not a compass direction, or quit, load, save, inventory, turns or look. You can then use that to print a message instead of performing any further actions when the state of the game is also dark (which is another boolean variable).

This blocks the get and examine commands and all other verbs.

The "light lamp" action appears ahead of the darkness override, so it's permitted to occur when it is dark.

If you have any question, I'm the one to fly to.  Read my mind.

start_at                 = start_room
locations {
   start_room : location "You are in a lovely treasure room." ;
}
objects {
   // The crown is in the same location as the player at the start, but GET is blocked
   // so cannot be taken even if the player knows it's there.
   crown : object "a gold crown" start_at = "start_room" ;
   // The lamp description is dynamic, based on the state of the lamp
   lamp  : object "a lamp{is_lamp_lit ? ` (lit)`}" start_at = "inventory" ;
}
booleans {
   is_lamp_lit : boolean "false" ;
   is_dark     : boolean_dynamic  {(
      is_at "start_room" && is_lamp_lit == false
   )}
   // Everything except [movement, quit, save, load,
   // inventory, turns, look] is banned in the dark.
   is_inaccessible_darkness_verb : boolean_dynamic {(
      (
         /* is movement command matches any system compass direction verb + all aliases */
         is_movement_command () ||
         verb_is "quit"         ||
         verb_is "save"         ||
         verb_is "load"         ||
         verb_is "inventory"    ||
         verb_is "turns"        ||
         verb_is "look"
      ) == false
   )}
}
on_command {
   // This comes before the darkness action block, so we can perform this action in the dark.
   : match "light lamp"  {
      : if (is_carried "lamp" && is_lamp_lit == false) {
         : set_true "is_lamp_lit" ;
         : print "You light the lamp" ;
         : press_any_key ;
         : redescribe;
      }
   }
   // Blocks everything except movement, quit, save, load, inventory, turns, look
   : if (is_dark && is_inaccessible_darkness_verb) {
      : print "You fumble in the dark." ;
      : done ;
   }
}
settings {
   // Tells Adventuron when to override the location description with
   // the darkness message (in the theme system messages), plus will remove direction list
   // and object list from the location layout (when is_dark resolves to true)
   dark_expression = is_dark
}
themes {
   my_theme : theme {
      colors {
         // Set the darkness pen colour to dark blue.
         dark_pen = 9
      }
      system_messages {
         it_is_dark = Darkness surrounds you.
      }
   }
}

This works nicely, except that I use a lot of on_command{} blocks within the locations{} block for room-specific commands and these are apparently processed first, so I've moved the darkness check inside the general on_command block{} to the specific on_command block{} for the room. Fortunately for me, I only have one dark room.

Put the code on the on_pre_command {} block to prempt the per-location on_command {} handlers. Updated the documentation to put it in this block. You may need to press F5.