WAD
Inherits WritingAdditions::WAD < RaylibAdditions::WAD < Reference < Object
Reading a .WAD file's data
To simply read in a WAD file, you just call WAD.read(file : Path | String | IO) : WAD:
my_string_wad = WAD.read("Path/To/Wad")
my_path_wad = WAD.read(Path["Path/To/Wad"])
File.open("Path/To/Wad") do |file|
my_io_wad = WAD.read(file)
end
Creating a new WAD
To create a new WAD, you call WAD.new(type), with type being of WAD::Type
my_new_internal_wad = WAD.new(WAD::Type::Internal)
my_new_patch_wad = WAD.new(WAD::Type::Patch)
Using the WAD's data
wa-cr sorts the the parsed wad's data into easy to use variables.
To get the sample rate of the sound "MYSOUND":
my_wad.sounds["MYSOUND"].sample_rate # => returns the sample rate of the sound
To get y_position of the 34th thing in the map "MAP23":
# Gets the thing index 33 because it is zero indexed: the 33rd index is the 34th thing
my_wad.maps["MAP23"].things[33].y_position # => returns the y_position of the thing
Lumps
You can also read in .lmp lump files:
NOTE: Graphic.parse can take 2 arguments: The file to read and
the position of the start of the data (Default is -1. Should almost always be -1 when reading a .lmp)
my_string_graphic = WAD::Graphic.parse("Path/To/MyGraphic.lmp")
my_path_graphic = WAD::Graphic.parse(Path["Path/To/MyGraphic.lmp"])
File.open("Path/To/MyGraphic.lmp") do |file|
my_io_graphic = WAD::Graphic.parse(file)
end
my_string_flat = WAD::Flat.parse("Path/To/MyFlat.lmp")
my_path_flat = WAD::Flat.parse(Path["Path/To/MyFlat.lmp"])
File.open("Path/To/MyFlat.lmp") do |file|
my_io_flat = WAD::Flat.parse(file)
end
my_string_sound = WAD::Sound.parse("Path/To/MySound.lmp")
my_path_sound = WAD::Sound.parse(Path["Path/To/MySound.lmp"])
File.open("Path/To/MySound.lmp") do |file|
my_io_sound = WAD::Sound.parse(file)
end
Constants
The size of the header in bytes
Constructors
Reads in a WAD file given the filename:
my_wad = WAD.read("Path/To/Wad")
Reads in a WAD file given the io:
File.open("Path/To/Wad") do |file|
my_wad = WAD.read(file)
end
Reads in a WAD file given the io but returns all errors thrown when parsing lumps:
File.open("Path/To/Wad") do |file|
my_wad = WAD.read!(file)
end
Reads in a WAD file given the filename but returns all errors thrown when parsing lumps:
my_wad = WAD.read!("Path/To/Wad")
Class methods
Reads in a WAD file given the io
but returns Nil if parsing the WAD throws an error:
File.open("Path/To/Wad") do |file|
my_wad = WAD.read?(file)
end
Reads in a WAD file given the filename
but returns Nil if parsing the WAD throws an error:
my_wad = WAD.read?("Path/To/Wad")
Cuts a slice down to length len if it is larger than len:
my_slice = "My Test Slice".to_slice # => Bytes[77, 121, 32, 84, 101, 115, 116, 32, 83, 108, 105, 99, 101]
WAD.slice_cut(my_slice, 5) # => Bytes[77, 121, 32, 84, 101]
Cuts a string down to length len if it is larger than len:
WAD.string_cut("Aberdine", 4) # => "Aber"
Replaces all instances of ms-dos name incompatible chars of a string with "~":
my_string = "My.TestString"
WAD.string_sub_chars(my_string) # => "My~Test~String"
Instance methods
Allows easy parsing of lumps into the WAD
my_wad = WAD.new(WAD::Type::Internal)
my_wad.add("MyTest", WAD::AddTypes::Sound, "Path/To/SoundTest.lmp")
Allows easy parsing of lumps into the WAD
my_wad = WAD.new(WAD::Type::Internal)
File.open("Path/To/Sound.lmp") do |file|
my_wad.add("MyTest", WAD::AddTypes::Sound, file)
end
Returns a copy of self with all instance variables cloned.
The Colormap in the WAD.
The Colormap in the WAD.
Array of Demos in the WAD.
Array of Demos in the WAD.
Array of all directories in the WAD.
Array of all directories in the WAD.
An integer specifying the number of lumps in the WAD.
An integer specifying the number of lumps in the WAD.
An integer holding a pointer to the location of the directory.
An integer holding a pointer to the location of the directory.
The Dmxgus in the WAD.
The Dmxgus in the WAD.
The Endoom in the WAD.
The Endoom in the WAD.
Array of Flats in the WAD.
Array of Flats in the WAD.
The Genmidi in the WAD.
The Genmidi in the WAD.
Array of Graphics and patches in the WAD.
Array of Graphics and patches in the WAD.
Array of maps in the WAD.
Array of maps in the WAD.
Array of music in the WAD.
Array of music in the WAD.
Creates a new empty directory with name and puts it onto the list of directories. WARNING: Directory will not work if name is not the correct name of the data
File.open("Path/To/MySound.lmp", "w+") do |file|
my_wad.["MYSOUND"] = WAD::Sound.parse(file)
my_wad.new_dir("MYSOUND")
end
Array of speaker sounds in the WAD.
Array of speaker sounds in the WAD.
The Playpal in the WAD.
The Playpal in the WAD.
The Pnames in the WAD.
The Pnames in the WAD.
Renames a lump that can be renamed in the WAD Usually used when renaming a directory
Array of sounds in the WAD.
Array of sounds in the WAD.
Array of Sprites in the WAD.
Array of Sprites in the WAD.
Array of texture maps in the WAD.
Array of texture maps in the WAD.
Type of WAD: Either Internal, IWAD, or Patch, PWAD.
Type of WAD: Either Internal, IWAD, or Patch, PWAD.
Finds what a name is in the WAD
Usually used to find what type a directory points to