LunaDLL Tutorial
Using lunadll.txt scripts
The most important things to think about are the action you want to do and the point at which the action should happen. The scripting engine only deals with those two things: A time, and an action.
Example times:
- While loading a level
- Always
- In section 1
- In section 2
- When a timer runs down
- When touching a block of a certain type
- When typing a custom cheat code
- When a condition is met such as NPC with ID 138 no longer exists
Example actions:
- Change the player character
- Change the powerup
- Change the reserve powerup
- Play a sound
- Change the music
- Show text
- Trigger an event
- Manipulate game memory somehow
The basics
The first step is creating a file named lunadll.txt in your level folder. That's it.
Structure
There's only 4 things you'll be writing in your lunadll.txt.
Time designator - #
# designates a time of an action. They mostly correspond to sections of the level #-1 means during level load #0 means "always" #1 means section 1 #2 means section 2 ... #21 means section 21
#1000 and up is an advanced feature for designating custom events / custom blocks of commands
Once you write say #-1, then all commands you write from then on will be run during the level load time of your level, until you write #1 or some other designator.
Comments - // comment
Any line that contains a // will be understood as a comment. Comments are only for humans to read, and the scripting engine ignores them. They're actually important for remembering just what the hell your code is supposed to do, and for others to understand what your code does.
Commands - Kill,0,0,0,0,0,0
Commands are the most important part of lunadll scripts, and the most complicated. There's no way to remember them all or what all of the parts of one do usually, so you have to check the reference.
They mostly have the same parts, separated by commas
"Kill" - This first part is the command name. It's the easiest part to remember and explains what the command does, usually. This one kills something. "Infinite flying" activates infinite flying for the player, and so on.
After each command name, there are 6 parameters separated by commas. What each one does is specific to each command, and they're quite hard to remember, which is why you'll have to refer to the reference. But there is some underlying pattern.
First - The target parameter
The first number is usually the "target" of the command. If you want the command to target the player, 0 is usually the player. If you want to target the "key" NPC (the thing you pick up that opens lockd doors), well you need to target the key's NPC ID (the key is NPC ID 38)
Second, Third, Fourth - Options
Parameter 2, 3, 4 are extra parameters that can mean just about anything, but for a lot of commands that aren't complicated, they usually aren't used and are just 0. Check the command reference.
Fifth - Active time
Parameter 5 is virtually always the "active time" specifier. Basically it's how long the command will "run" before finally deleting itself. 0 means it never runs out. 1 means it lasts 1 frame. 60 means it lasts 60 frames (1 second), and so on.
Keep in mind that commands don't run at all unless they're in the section you're in. A command in #21 with 1 frame active time will sit there forever until the player actually gets to section 21, and then it will run once and then die.
Sixth - Text
Unlike the others, the 6th parameter can also be entered as text, but is oftentimes just left as 0 anyway. It's usually where you type messages, decimal numbers, and options.
That's all you need to know about commands.
#END is a special string you should put at the end of your .txt file. It's pretty simple - just put #END after everything else.
Examples
Here's a bunch of examples in ascending level of complexity with lots of comments
Basic filter script
#-1
FilterToBig,0,0,0,0,0,0
#ENDThat's the whole thing. First we have the level load designator, which is where you normally want a filter. FilterToBig lowers Demo's powerup down to mushroom level if she has anything higher than a mushroom, and does nothing if she's small.
FilterToBig's 6 parameters do nothing except the 5th, the active time. It's set to 0 which means "always", but since it's in the level load section, it only works for that 1 frame when the level is loading. If this were in section #0, Demo would never be able to get a powerup higher than a mushroom because she would constantly be filtered to bigness.