Method: InformWriter#start

Defined in:
lib/IFMapper/InformWriter.rb

#startObject



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/IFMapper/InformWriter.rb', line 276

def start
  @f = File.open("#@root.inf", "w")
  @f.puts '!' + '=' * 78
  story = @map.name
  story = 'Untitled' if story == ''
  today = Date.today
  serial = today.strftime("%y%m%d")
  @f.puts "Constant Story \"\#{story}\";\nConstant Headline\n         \"^A game map done with IFMapper\n          ^by \#{@map.creator}.^\";\nRelease 1; \nSerial \"\#{serial}\"; ! \#{Time.now}\n\n! These constants are to make the game also potentially Glulx compatible\n#ifndef WORDSIZE;\nConstant TARGET_ZCODE;\nConstant WORDSIZE 2;\n#endif;\n\n!Constant ZDEBUG;\n\nInclude \"Parser\";\nInclude \"VerbLib\";\n\n\n"
  @f.puts '!' + '=' * 78
  @f.puts "! Object classes"
  @f.puts "\n! We use Andrew MacKinnon's EasyDoors for our doors.\nInclude \"easydoors\";\n\n! We define a class for NPC (non-player characters)\nclass   NPC\nhas   animate;\n\n"

  @f.puts '!' + '=' * 78
  @f.puts "! Map sections"
  @map.sections.each_index { |idx|
    @f.puts "#include \"#@base-#{idx}.inf\";"
  }

  start_location = ''
  if @map.sections.size > 0 and @map.sections[0].rooms[0]
    r   = @map.sections[0].rooms[0]
    tag = get_tag(r)
    start_location = "location = #{tag}"
  end

  @f.puts "!============================================================================\n! Entry point routines\n\n[ Initialise;\n\#{start_location};\nlookmode = 2; ! verbose\ninventory_style = FULLINV_BIT + ENGLISH_BIT + RECURSE_BIT; ! wide\n];\n";

  @f.puts "!============================================================================\n! Standard and extended grammar\n\nInclude \"Grammar\";\n"

  @f.close

  @map.sections.each_with_index { |sect, idx|
    section(sect, idx)
  }
end