ifm2i7 |
ifm2i7 (source code)Convert raw format files generated by ifm (Interactive Fiction Mapper) to Inform 7 source code. . Author: Sergey Goldgaber http://code.wetash.com Summary
Internal includesPlease do not modify. User configurable includes
VariablesSummary
Global, internalPlease do not modify. Exit values
Truth and falseness
Directions
Others
find_direction
Given two positions on the map, find which direction the second is from the first. Parameters
Returnsdirection OutputErrors when positions are not integers, or when source and destination positions are the same. ExamplesGiven: “0 0” and “0 1”, the direction is “North” Given: “0 1” and “1 1”, the direction is “East” Given: “1 1” and “1 0”, the direction is “South” Given: “1 0” and “0 0”, the direction is “West” Given: “1 1” and “0 0”, the direction is “Southwest” fix_5J39_room_bug
Inform 7 build 5J39 has a bug where using the “called” directive can cause rooms to not be connected to one another, in certain cases. See the README file for more details. So in order to avoid this bug and still generate code that the Inform 7 build 5J39 compiler likes, we’re going to have to change some room names. Parameters
Returns
OutputWarnings when the room name has been changed. Example”to House” returns “to_House” get_height
Get a height, if it exists, from a line Parameters
Returnsnothing Outputnothing NOTEThis subroutine directly modifies variables in raw2internal get_item
Get a item, if it exists, from a line Parameters
Returnsnothing Outputnothing NOTEThis subroutine directly modifies variables in raw2internal get_link_and_join
Get a link or join, if it exists, from a line Parameters
Returnsnothing Outputnothing NOTEThis subroutine directly modifies variables in raw2internal get_link_go
Gets the link’s ‘go:’ direction, if there is one. Parameters
Returnsnothing Outputnothing NOTEThis subroutine directly modifies variables in raw2internal get_link_oneway
Gets the link’s ‘oneway:’ value, if there is one. Parameters
Returnsnothing Outputnothing NOTEThis subroutine directly modifies variables in raw2internal get_link_position
Get a link position, if it exists, from a line Parameters
Returnsnothing Outputnothing NOTEThis subroutine directly modifies variables in raw2internal get_room_number
Get a room number, if it exists, from a line Parameters
Returnsnothing Outputnothing NOTEThis subroutine directly modifies variables in raw2internal get_room_name
Get a room name, if it exists, from a line Parameters
Returnsnothing Outputnothing NOTEThis subroutine directly modifies variables in raw2internal get_room_position
Get a room position, if it exists, from a line Parameters
Returnsnothing Outputnothing NOTEThis subroutine directly modifies variables in raw2internal get_region
Get a region (“section” in ifm lingo), if it exists, from a line Parameters
Returnsnothing Outputnothing NOTEThis subroutine directly modifies variables in raw2internal get_task
Get a task, if it exists, from a line Parameters
Returnsnothing Outputnothing NOTEThis subroutine directly modifies variables in raw2internal get_title
Get a title, if it exists, from a line Parameters
Returnsnothing Outputnothing NOTEThis subroutine directly modifies variables in raw2internal get_width
Get a width, if it exists, from a line Parameters
Returnsnothing Outputnothing NOTEThis subroutine directly modifies variables in raw2internal handle_empty_links
Calculate a path to/from two linked rooms if there is no explicit path in the just ended link/join block. Parameters
Returnsnothing OutputThis subroutine directly modifies variables in raw2internal populate_links
Populates %links and prints Inform 7 source code for the direction relation(s) between two rooms. Parametersnone Returnsnothing OutputInform 7 source code. NOTEThis subroutine directly modifies variables in raw2internal populate_regions
Populate %regions if we just exited a region block Then clear temporary region variables. Parametersnone Returnsnothing Outputnothing NOTEThis subroutine directly modifies variables in raw2internal populate_rooms
Populates %rooms and prints Inform 7 source code that creates a room and places it in a region. Parametersnone Returnsnothing OutputInform 7 source code. NOTEThis subroutine directly modifies variables in raw2internal |
my $NOWARNINGS
Checks to see if two directions are opposites of one another.
sub are_opposite_directions
Standardize direction names
sub canonical_direction
Exit with an error if ifm could not be found in the user’s $PATH, or if it isn’t executable.
sub check_ifm
Set the default file name, if there isn’t one, or use the first command line argument, if it’s there.
sub choose_input_file_name
Set the default file name, if there isn’t one, or use the first command line argument, if it’s there.
sub choose_output_file_name
Remove illegal characters from the room, region, and item names, converting some of them to spaces as needed.
sub clean_name
Redirects the output filehandle back to STDOUT and closes the open output file.
sub close_output_file
Enable debugging messages.
sub enable_debug
Disable warnings.
sub enable_quiet
Silence almost all errors and warnings by redirecting STDERR to /dev/null
sub enable_silence
Print an error on STDERR and exit.
sub exiterr
Complain and exit if the given file does not exist, or is not a “-”.
sub file_exists
Given two positions on the map, find which direction the second is from the first.
sub find_direction
Inform 7 build 5J39 has a bug where using the “called” directive can cause rooms to not be connected to one another, in certain cases.
sub fix_5J39_room_bug
Get a height, if it exists, from a line
sub get_height
Get a item, if it exists, from a line
sub get_item
Get a link or join, if it exists, from a line
sub get_link_and_join
Gets the link’s ‘go:’ direction, if there is one.
sub get_link_go
Gets the link’s ‘oneway:’ value, if there is one.
sub get_link_oneway
Get a link position, if it exists, from a line
sub get_link_position
Handle exceptions from Getopt::Lucid->getopt() threw
sub getopt_exception_handler
Use the Getopt::Lucid module to get and return options.
sub get_options
Get a room number, if it exists, from a line
sub get_room_number
Get a room name, if it exists, from a line
sub get_room_name
Get a room position, if it exists, from a line
sub get_room_position
Get a region (“section” in ifm lingo), if it exists, from a line
sub get_region
Get a task, if it exists, from a line
sub get_task
Get a title, if it exists, from a line
sub get_title
Get a width, if it exists, from a line
sub get_width
Calculate a path to/from two linked rooms if there is no explicit path in the just ended link/join block.
sub handle_empty_links
Calls ifm to convert ifm format files to ifm’s raw format.
sub ifm2raw
Increment the number at the end of a word, or add “2” at the end if there is no existing number at the end of that word.
sub increment_word
Main program
sub main
Redirect STDOUT to the output file.
sub open_output_file
Return the opposite of the given direction.
sub opposite_direction
Populates %links and prints Inform 7 source code for the direction relation(s) between two rooms.
sub populate_links
Populate %regions if we just exited a region block Then clear temporary region variables.
sub populate_regions
Populates %rooms and prints Inform 7 source code that creates a room and places it in a region.
sub populate_rooms
Print to STDERR.
sub printerr
Prints Inform 7 source code for putting all possible exits from a room on to the status line.
sub print_exits
Print Inform 7 source code for every link in %links
sub print_links
Print Inform 7 source code for every region in %regions
sub print_regions
Print rooms
sub print_rooms
Read raw format in to internal format
sub raw2internal
Print usage
sub usage
Handle --verbosity options
sub verbosity_handler