Skip to content
MyLegGuy edited this page Oct 5, 2018 · 6 revisions

A lot of these functions are untested. Contact me if they don't work.


addNote(int slot, image noteImage, table soundTable)

  • Adds a note.
    • slot is the note's internal ID.
    • noteImage is the note's image loaded with the loadImage function.
    • soundTable is a table of 14 loaded sounds loaded with the loadSound function. None of the 14 may be nil. If the note plays the same sound in multiple places, just load the sound once and assign it to both slots in the array. The first slot in the soundTable is the sound played for the highest note, a B in octave 5. The fourteenth slot in the soundTable is the lowest sound that note can play, a C in octave 3.

setBigBg(string path)

  • Switches the background mode to PC mode, where one big image is displayed as the background.
    • The path argument is a string relative to where the exe is. If you look at the example in init.lua, the path is "assets/Free/Images/pcBackground.png". The assets folder is right next to the exe, so we can just start there.

setBgParts(table emptyImages, table labelImages)

  • Switches to the mobile background mode where a bunch of squares are assembled to form the background.
    • Every loaded image should be 32x32, you're not giving it one big image.
    • emptyImages is a table of 14 images loaded with loadImage. The first slot in the table is the image for the top row. The second slot goes down a row and so on.
    • labelImages is a table of 14 images loaded with loadImage. The first slot in the table is label image that is displayed to the right of the top row. The second slot goes down a row and so on.

isMobile()

  • Returns true if the program is in mobile mode.

loadImage(string path)

  • Loads an image. The path is relative to the exe file. So if I wanted to load an image from the assets folder, which is right next to the exe file, I could just do "assets/whatever.png" for my path.

loadSound(string path)

  • Loads a sound. The path is relative to the exe file. So if I wanted to load an image from the assets folder, which is right next to the exe file, I could just do "assets/whatever.ogg" for my path.
    • wav files should be used for note sounds

swapUI(int firstSlot, int secondSlot)

  • Swaps the UI elements at firstSlot and secondSlot.
    • Slots start at 0

deleteUI(int slot)

  • Deletes a UI at the given slot.
    • If you delete the last UI in the row, you're okay. Otherwise the program will probably crash.
      • To get around this, use swapUI to move all the UI elements you don't want to the end and then delete them one by one.
    • Slots start at 0

getTotalUI()

  • Returns the total number of UI icons. UI icons are the things below the song you click.
    • Slots start at 0.
      • This means that if there is one UI icon in total, its slot is slot 0. In this example, this function will return 1 for the total number of UI icons even though the max index you can use is 0.

addUI()

  • Adds a UI icon and returns its slot.
    • This function is useless right now.

setSpecialID(string whichSpecial, int specialID)

  • Tells the program the ID of a certian special note.
    • whichSpecial is a string that is exactly...
      • repeatStart
      • repeatEnd
      • audioGear
    • specialID is what the note ID for the special note will be.
    • Using this function you can do things like make a piano note act as a repeat note. The real use is to tell the program the ID of repeat notes and other special notes if you've changed the ID.

setGearInfo(int noteID, string passedLetter, string passedAccidental)

  • This is to aid audio gears.
    • For the note with the ID noteID, its audio gear letter is set to passedLetter and its accidental (sharp, flat, neutral) is set to passedAccidental
    • An example for the piano note with note ID 0 would be setGearInfo(0,"P","-");
      • If it was a sharp piano note with note ID 1, we'd do it like this: setGearInfo(1,"P","#");
      • If it was a flat piano note with note ID 2, we'd do it like this: setGearInfo(2,"P","b");

swapNoteUIOrder(int uiSlotOne, int uiSlotTwo)

  • The order of notes in the UI is not tied to the note ID.
    • With this function, you can swap two notes' position in the UI.
    • uiSlotOne is the zero based slot of the first position and uiSlotTwo is the zero based slot of the second position.
    • For example, drums are usually in UI slot 7, so I could do swapNoteUIOrder(0,7) to make drums the first note in the UI.

getSongWidth()

  • Returns the song's width in blocks
    • Usually this will be 400 unless the song has been resized

getSongHeight()

  • Returns 14

setSongWidth(int newWidth)

  • Sets the song's width to newWidth
    • newWidth is measured in blocks
    • If you shrink the song, some data may be lost.

getBPM()

  • Returns the song's BPM

setBPM(int **newBPM**)

  • Sets the song's BPM to newBPM.

getNoteSpot(int x, int y)

  • Returns the note ID at the zero based position (x,y)

setNoteSpot(int passedX, int passedY, int passedId)

  • Puts the given note id, passedID, at the zero based position (passedX,passedY) in the song.

getAudioGearSize()

  • Returns the maximum amount of notes that can be put in an audio gear
    • Usually returns 5

getAudioGear()

  • TODO - Document

setAudioGear()

  • TODO - Document

selectFile(string allowedTypes)

  • Returns a string that is the complete path of the file selected by the user
    • allowedTypes is a string that lists the types of files the user can select separated by commas.
      • For example, "GMSF,gtmusic,AngryLegGuy,mylegguy"
    • Can return nothing if the user cancels

findMaxX()

  • Internally recalculates the end of song loop position
    • Use this when you're done placing notes with setNoteSpot

setMaxX(int newMaxX)

  • Sets the zero based end of song loop position to newMaxX.

getNumberInput(string myPrompt, int myDefault)

  • Lets the user enter a number and returns it
    • myPrompt is what the application tells the user. It should be a message telling the user what the number is for.
    • myDefault is the default value for the number. This is also what is returned if the user cancels