Zappy's Character Wad tutorial

From SRB2 Wiki
Jump to navigation Jump to search

UNFINISHED

TODO:

  • Think of things to do
  • Play SRB2
  • Listen to music
  • Play SRB2
  • Play SRB2
  • Finish PrefColor table
  • Give up before finishing it
  • Play SRB2
  • More Lua tweaks
  • Play SRB2*
  • Finish PrefColor table
  • Play SRB2
  • Make StartColor table
  • Play SRB2 between starting on the StartColor table and finishing it
  • Give up
  • Play SRB2


A Character Wad is a Wad file used in Sonic Robo Blast 2 to add new playable characters. They can be added with the "AddFile" console command, and (usually) be selected from the singleplayer character select screen, however exceptions do exist.

360 frames in total can be made for a Character Wad, however it can be considered complete with just 150 frames (3 of which will actually be dummies) to 174 frames, depending on the character. A Character Wad can, however, have as few as 23 frames, however if that's the case, it can't be considered used for much other than an MD2 Model, nor can it be considered finished.

To edit Character Wads, lump editors can be used. The creator draws the frames for the character in an image editor, and imports them using a lump editor.


Requirements

To make a Character Wad, you'll need:


A lump editor. Popular ones include Slade and XWE.

An idea for what your character will look like, be like, can do, etcetera.

An image editor, including knowledge of it, and a lot of patience. You won't need anything more advanced than even MS Paint, however it is highly recommended to have something useful.

Knowledge of what a Wad file is, and how to use your lump editor.


Format

A Character Wad consists of several lumps. These include:

  • S_Skin: Required. This lump tells the game this is where the Character Wad "starts", and also defines a few or a lot of things about the character. S_Skin can be named anything, as long as it starts with S_Skin. Which means S_SKIN will work just as well as S_SKIN1, S_SKIN01, S_SKINA, S_SKIN34, S_SKIN69, and whatever you want to name it, literally. The only thing is that it must start with S_Skin, because that's what the game looks for. See S_Skin below.
  • The frames: Required. These lumps usually come right after S_Skin, and are named XXXXYZ or XXXXYZUV. XXXX can be anything you want, Y and U are frame "numbers", and Z and V are frame "directions". See Frame List far below.
  • OjctCfg: This lump is not required, unless you want your character to be playable in singleplayer. It defines how your character appears on the character select screen. See ObjctCfg further below. Required for your character to be considered complete, though.
  • Lua: This lump/these lumps are completely optional. Like S_Skin, it can be named anything, as long as it starts with LUA_. For example, it can be called LUA_GAME, LUA_CAKE, LUA_MLP, LUA_1, or even just LUA_. This lump/these lumps are Lua coding, and can do a lot more than you'd imagine. This article does not cover Lua coding. It will, however, later show a few tweaks.


S_Skin

Making the S_Skin lump is usually the easiest place to start. Especially if you already know your character's speed, ability, jump height, etcetera.

You can start by making the S_Skin lump, either in your lump editor (if it supports text editing) or a text editor outside it (you'll have to import it afterwards if that's the case).


You can start by copying this:

Name =
RealName =
HudName =
Flags =
HighResScale =
Sprite =
CharSel =
Face =
SuperFace =
Ability =
Ability2 =
ActionSpd =
ThokItem =
SpinItem =
RevItem =
MinDash =
MaxDash =
NormalSpeed =
RunSpeed =
AccelStart =
Acceleration =
ThrustFactor =
JumpFactor =
StartColor =
PrefColor =

And then edit it. Some of those things you won't even use. If you're looking for explanations, everything is listed right below, in same order as above.

Examples are shown below all attribute explanations. (Not per-attribute examples, but full examples of the whole of S_Skin.)


Attributes

Name, RealName, HudName

Name is the skinname. It is only used by Lua coding, the ObjctCfg lump, and the "Skin" console command. It must be lowercase, and 16 or less characters long. There is no default, and as such it's required.

RealName is the name displayed in the "Setup Player" screen in multiplayer, and at the end of levels in singleplayer and co-op. Default is "SONIC".

HudName is the name displayed in the lower left corner during play, beside the life icon. Default is "SONIC".

Flags, HighResScale, Sprite

Flags set a few useful things. They can be added together using a plus (+) or a line ( | ) (not an uppercase i or lowercase L). Default is none of them.

Flag name Flag purpose/description
SF_SUPER UNSETTABLE
SF_SUPERANIMS Use special defined frames for when super. Does not include the transformation itself, which is required either way.

If set, frame U is used for super standing, U and V for super walking, W and X for super running, Y for tipping on an edge,

and Z is for getting hurt while super. That effect is possible via A_SuperFireShot and A_SuperTurretFire in other Wads.

SF_SUPERSPIN Use the default spin animations when jumping/spinning when super. Otherwise display idle/running animations when jumping/spinning.
SF_HIRES Resize all character frames by the scale set with HighResScale.
SF_NOSKID Disable skidding sound and animation when running forwards and pressing the opposite movement direction.
SF_NOSPEEDADJUST Don't speed up animations when moving quickly.
SF_RUNONWATER Allow running on water/Techno Hill goop if faster than RunSpeed. Previously tied to CA_SWIM, got its own flag in 2.1.9.

HighResScale sets the scale at which to resize all character frames if SF_HIRES is set in Flags. Default is 0.5.

Sprite seems to let you place the character frames anywhere you want in your Character Wad... thus in fact making it completely useless? Type in the first 4 letters of your character frame names, and the game will look through the whole Wad to find the frame name you defined. Must be 4 characters long. There is no default, and thus it defaults to using the frames right after S_Skin, whatever their names are.

CharSel

The lump name of the picture displayed in the character select screen. It can also be overridden in ObjctCfg, however it's recommended to put it in S_Skin, since then it'll show up for Record Attack, too. Not that it's of any use to most people. Must be 8 or less characters long. Default is "CHRSONIC".

The picture should be 128x128 or 256x256 pixels wide and tall.

Face, SuperFace

Face is the life icon displayed in the lower left corner of the screen. Must be 8 or less characters long. Default is, actually, "MISSING".

SuperFace is the same as Face, but for when super. If unset, changes to match Face. The default for this is also "MISSING".

Ability, Ability2, ActionSpd

Ability is, well, the ability your character has (Thok, Fly, Glide, etcetera) as a midair action. You can only set one, for obvious reasons. Default is "CA_THOK".

Ability name Primary ability purpose/description
CA_NONE No midair action.
CA_THOK Sonic's Speed Thok. Jump and press jump again to get a burst of speed. The speed is the same as ActionSpd.
CA_FLY Tails' flying. Jump and press jump again to start flying. If flying, tap jump to ascend, and hold spin to descend quickly. Lasts for 8 seconds.

Frames U and V are used for flying, and W, X, Y and Z are used for being tired, unable to fly more.

CA_GLIDEANDCLIMB Knuckles' gliding and climbing. Jump and hold jump to glide forwards. Let go to fall down.

If gliding into a wall, you will cling onto it, and can climb around on it. Some walls disallow this, though.

Frames U and V are used for gliding, W for not moving while hanging on a wall, and X, Y and Z for moving while climbing.

CA_HOMINGTHOK Like Sonic's Speed Thok, but slower. Homes into enemies and monitors if used near them. Hitting them allows you to do another Homing Thok.

The speed without any homing target is 1/3 of ActionSpd. The speed when homing is 2/3 of ActionSpd.

CA_SWIM Like Tails' flying, but only allowed underwater. Also allows running and jumping on water. Unlike flying, swimming can be done forever.

Frames U and V are used for swimming, leaving W, X, Y, and Z unused.

CA_DOUBLEJUMP Jump and press jump again to... well, jump again in midair.
CA_FLOAT Jump and hold jump to float, stopping all vertical momentum.
CA_SLOWFALL Jump and hold jump to descend slowly.
CA_TELEKINESIS Jump and press jump again to push enemies slightly away, Jump and press spin to pull enemies slightly closer.
CA_FALLSWITCH Jump, fall down, and press jump again to reverse vertical momentum. Great for horizontal distances, but not a help with vertical distances.
CA_JUMPBOOST Surprisingly, not a midair action. Stand still and jump to jump at normal height. Run quickly and jump to jump higher.
CA_AIRDRILL A bit like Sonic's Speed Thok, but can be controlled for about 2 seconds, and also helps you a bit vertically.
CA_JUMPTHOK A combination of Sonic's Speed Thok and a Double Jump. Lets you burst forward and slightly upwards. The forward speed is 1/2 of ActionSpd. The upward speed is the same as JumpHeight.


Ability2 doesn't directly define a midair action, however it does define how it functions. Surprisingly, you can only set one. Default is "CA2_SPINDASH".

Ability2 name Secondary ability purpose/description
CA2_NONE Don't spin, and functions above work as described, and can only be used once per jump.

Note the spin frames will still show during certain circumstances, being spinning on a mace or zooming through a tube.

CA2_SPINDASH Same as CA2_NONE, but allow spinning by pressing the spin key, and spin when jumping.
CA2_MULTIABILITY Same as CA2_NONE, but allow multiple midair actions for most abilities. For flying/swimming, let ascending be easier by just holding jump instead of tapping jump.

For double jump, floating and slowfall, jump higher instead. For jumpboost, speed makes you jump even higher.

ActionSpd sets the speed at which Ability is used. For CA_THOK, CA_GLIDEANDCLIMB, CA_HOMINGTHOK and CA_JUMPTHOK, sets the forward speed. For CA_FLY, CA_SWIM and CA_AIRDRILL, sets the ascending speed. For CA_JUMPBOOST, sets the height boost. Unused for the rest? Default is 30.

ThokItem, SpinItem, RevItem

ThokItem replaces the translucent "ball" left from some midair actions, including Thokking. Default is "MT_THOK". Only change if you know what you're doing.

SpinItem and RevItem are the same as ThokItem, but for spinning and revving a spindash, respectively.

MinDash, MaxDash

MinDash sets the minimum speed of the spin you get by quickly tapping spin once. Default is 15.

MaxDash sets the maximum speed of the spin you get by charging a spin for a few seconds (the charge is shorter/longer depending on MinDash and MaxDash). Default is 90.

NormalSpeed, RunSpeed, AccelStart, Acceleration, ThrustFactor

NormalSpeed sets the normal running speed you can achieve without any boosts. Default is 36.

RunSpeed misleadingly sets the speed you have to exceed to use running animations. Default is 28.

AccelStart sets the speed at which you start moving if standing still and pressing forward. Default is 96.

Acceleration combined with ThrustFactor sets the speed at which you accelerate if already moving. Default is 40.

ThrustFactor has to do with how quickly you accelerate. Default is 5. Literally found in the source code, Thrust = thrustfactor x acceleration.

JumpFactor

Sets the height at which you jump. Default is 1. As an example, set it to 0.5 for half height, or 2 for double height.

StartColor, PrefColor

StartColor sets the index of the first of the 16 colour samples to use for colour changing in multiplayer. Default is 160, meaning samples 160-175 will change depending on colour chosen.

Here's the palette (click for larger image suitable for colour-picking), with sample numbers:

http://fc03.deviantart.net/fs71/f/2014/222/5/0/palette_by_thezeroteam-d7ujdyk.png

PrefColor sets the colour to use in singleplayer. Default is "Blue".

Here are the colours available:

Colour Name #1 #2 #3 #4 #5 #6 #7 #8 #9 #10 #11 #12 #13 #14 #15 #16
White 0 1 2 3 4 5 6 7
Silver 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Grey 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Black 24 25 26 27 28 29 30 31
Cyan 208 209 210 211 212 213 214 215 216 217 218 219
Teal 247 220 221 222 223
Steel_Blue 200 201 202 203 204 205 206 207
Blue 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
Peach 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
Tan 72 73 74 75 76 77 78 79 48 49 50 51 52 53 54 55
Pink 144 145 146 147 148 149 150 151
Lavender 248 249 250 251 252 253 254 255
Purple 192 193 194 195 196 197 198 199
Orange 82 83 84 85 86 87 88 89 90 91 92 93 94 95 152 153
Rosewood 92 93 94 95 152 153 154 155 156 157 158 159
Beige 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
Brown 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
Red 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
Dark_Red 133 134 135 136 137 138 139 140
Neon_Green 160 184 185 186 187 188 189
Green 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
Zim 176 177 178 179 180 181 182 183
Olive 105 106 107 108 109 110 111
Yellow 103 104 105 106 107 108 109 110
Gold 112 113 114 115 116 117 118 119

Examples

Here are some example S_Skins. Note that not all values have been used. Whatever is left out defaults to... well, what the default values for all attributes were written as above.

Even though almost everything defaults to Sonic's attributes, the Sonic example does have his values included, for reference.

Sonic (vanilla)

Name = sonic
RealName = Sonic
HudName = SONIC
Flags = SF_SUPERANIMS+SF_SUPERSPIN
CharSel = CHRSONIC
Face = LIVSONIC
SuperFace = LIVSUPER
Ability = CA_THOK
ActionSpd = 60
NormalSpeed = 36
AccelStart = 96
Acceleration = 40
ThrustFactor = 5
StartColor = 160
PrefColor = Blue

Tails (vanilla)

Name = tails
RealName = Tails
HudName = TAILS
CharSel = CHRTAILS
Face = LIVTAILS
Ability = CA_FLY
ActionSpd = 100
NormalSpeed = 32
AccelStart = 192
Acceleration = 50
ThrustFactor = 3
StartColor = 160
PrefColor = Orange

Knuckles (vanilla)

Name = knuckles
RealName = Knuckles
HudName = K.T.E
CharSel = CHRKNUX
Face = LIVKNUX
Ability = CA_GLIDEANDCLIMB
ActionSpd = 25
NormalSpeed = 34
AccelStart = 128
Acceleration = 45
ThrustFactor = 4
JumpFactor = 0.85
StartColor = 160
PrefColor = Red

Shadow (custom)

Name = shadow
RealName = Shadow
HudName = SHADOW
CharSel = SHADCHAR
Face = SHADLIFE
Ability = CA_HOMINGTHOK
ActionSpd = 50
StartColor = 160
PrefColor = Black

All attributes, but blank

...And in the order defined inside the source code of the game (the order doesn't matter at all):

Name =
Flags =
Sprite =
RealName =
HudName =
CharSel =
Face =
SuperFace =
Ability =
Ability2 =
ThokItem =
SpinItem =
RevItem =
ActionSpd =
MinDash =
MaxDash =
NormalSpeed =
RunSpeed =
ThrustFactor =
AccelStart =
Acceleration =
JumpFactor =
StartColor =
PrefColor =
HighResScale =


Frames

After making S_Skin, you can go ahead and *gasp* begin making frames for your character. The gasp was because it's going to be tough, not because this is what you should have been looking forward to the whole time.


Before just starting to do so, note these things:

Naming

As stated above, the character frame names must be XXXXYZUV, XXXX being whatever you want, Y and U being animation frames, and Z and V being animation directions.

The directions are as following:

1: Towards the camera
2: Diagonally towards/left of the camera
3: Left of the camera
4: Diagonally away/left of the camera
5: Away from the camera, what you will usually see when playing
6: Diagonally away/right
7: Right
8: Diagonally towards/right
0: All/any directions

Most frames can be named like this:

PLAYX1
PLAYX2X8
PLAYX3X7
PLAYX4X6
PLAYX5

Now why would they be named that? That will just make them face left instead of right, right? No.

The UV part of XXXXYZUV will be flipped horizontally. You can even have something like PLAYF1J1, and it would flip horizontally for frame J, compared to frame F.

Frame List

Knowing what frames are actually for what can be hard to remember, especially if you don't already know.

Refer to this table for an explanation of what frames are for what:

Frame Action
A Standing
B Idle 1
C Idle 2
D Walk 1
E Walk 2
F Walk 3
G Walk 4
H Walk 5
I Walk 6
J Walk 7
K Walk 8
L Spin 1
M Spin 2
N Spin 3
O Spin 4
P Spring up
Q Run 1
R Run 2
S Run 3
T Run 4
U Special 1
V Special 2
W Special 3
X Special 4
Y Special 5
Z Special 6
[ Air bubble gasp
\ Hurt
] Dead
^ Edge 1
_ Edge 2
` Fall 1
a Fall 2
b Hang
c End sign face
d Life monitor face
e Super transform 1
f Super transform 2
g Super transform 3
h Super transform 4
i Super transform 5
j Super transform 6
k Super transform 7
l Super transform 8
m Super transform 9

Frame list notes

A few notes about the frame list can be found below.

Lump names

The first 26 frames have uppercase lump names, A-Z. The next 6 frames have non-letter lump names, [ \ ] ^ _ ` The last 13 frames have lowercase lump names, a-m, as opposed to the first.

Most Wad editors support lowercase lump names, but may have it turned off by default. Go to the options of your Wad editor, and find the "Keep lump names uppercase" or "Disallow lowercase lump names" or similar, which differs between Wad editors.

For Slade users

Slade, a popular Wad editor, has saving non-ascii characters in lump names turned off by default. Surprisingly, this includes ^ and \, which is needed for a Character Wad.

To let it save those names, go to Edit > Preferences, find the Editing group in the list, and turn on "Use percent encoding if needed outside of Wad Archives". The name is misleading, but it works.

Ability2 and the spinning frames

If Ability2 is set to CA2_SPIN, you will have the spin frames shown when jumping and, you guessed it, spinning.

But even if Ability2 is set to CA2_NONE or CA2_MULTIABILITY, it is still required to have the spinning frames, as they are used for spinning on a mace or zooming through a tube, no matter what.

ObjctCfg

Making the ObjctCfg (Object Configuration) lump is the easiest thing to do next. It is required for playing as your character in singleplayer without cheats.

Like S_Skin, you can either make this lump in your lump editor (if it supports text writing) or in a text editor outside it (again, you'll have to import it afterwards).

Unlike S_Skin, naming matters a lot. Only OBJCTCFG and MAINCFG are loaded as "configurations", and thus will let it work.


You can start by copying this:

Character
SkinName =
Status = 32
PlayerText =

Most Character Wads include "SRB2 version = 210", however it is purely optional and not required. SRB2 uses it to output an error if the version doesn't match the currently played version. However, it will complain if you use "SRB2 version = 217" even if you play version 2.1.7 of the game, since only "210" is supported.

Like for S_Skin, explanations and examples of the variables are shown below.


Attributes

Character

This defines that a character selection will be made below it. You can also type "Character = 4" to allow yourself to disable/enable character selection of this character in a mod, however usually just "Character" is enough.

SkinName

You guessed it. This is the name of the skin to use if this character is selected. Use the same name as you used with Name in S_Skin. Not RealName, not HudName, just Name.

You can also define a second skin with the "&" character, for a bot to spawn and follow you and die all the time. See the examples for a... well, example.

Status

This must always be 32. If it is anything other than 32, your character won't be selectable. Mods can use this to make an "unlockable character", by simply defining

Character 0
Status = 0

to turn off Sonic, for example, and Status = 32 to turn on Sonic. How saved data behaves to this is unknown, though. Noone has tried making an unlockable character, unlocking him/her/it, closing the game, and booting it up again.

PicName

This overrides the character selection picture defined via CharSel in S_Skin. Only use this if you have to use a different character selection picture. See the examples for an example.

PlayerText

This defines the text shown on the character selection page. Can be upper- and lower-case. By typing ^ followed by a number, you can also set one of eight colours.

See the below table for a list of colours available. The colours shown are not the exact same colours as in SRB2, only references.

Value ^0 ^1 ^2 ^3 ^4 ^5 ^6 ^7
Colour White Purple Yellow Green Blue Red Gray Orange

Anything above 7 or below 0 will also result in the white colour. See the examples right below for examples on how to use them.

The text can be ended with the # character, but it's not necessary unless you want to put something else (like another character) in the ObjctCfg afterwards.

Examples

Here are some example ObjctCfgs. Everything must be included, with exception of PicName.

Sonic (vanilla)

Character 0
SkinName = sonic
Status = 32
PlayerText = ^2Sonic^0 is the fastest of the three, but also the hardest to control. Beginners beware, but experts will find Sonic very powerful.

^2Ability:^0 Speed Thok
Double jump to zoom forward with a huge burst of speed.

^2Tip:^0 Simply letting go of forward does not slow down in SRB2. To slow down, hold the opposite direction.

Tails (vanilla)

Character 1
SkinName = tails
Status = 32
PlayerText = ^2Tails^0 is the most mobile of the three, but has the slowest speed. Because of his mobility, he's well- suited to beginners.

^2Ability:^0 Fly
Double jump to start flying for a limited time. Repetitively hit the jump button to ascend.

^2Tip:^0 To quickly descend while flying, hit the spin button.

Knuckles (vanilla)

Character 2
SkinName = knuckles
Status = 32
PlayerText = ^2Knuckles^0 is well-rounded and can destroy breakable walls simply by touching them, but he can't jump as high as the other two.

^2Ability:^0 Glide & Climb
Double jump to glide in the air as long as jump is held. Glide into a wall to climb it.

Sonic & Tails (vanilla)

Character 0
SkinName = sonic&tails
Status = 32
PicName = CHRS&T
PlayerText = ^2Sonic & Tails^0 team up to take on Dr. Eggman! Control Sonic while Tails desperately struggles to keep up.

Player 2 can control Tails directly by setting the controls in the options menu. Tails's directional controls are relative to Player 1's camera.

Tails can pick up Sonic while flying and carry him around.

Shadow (custom)

Character
SkinName = shadow
Status = 32
PlayerText = ^2Shadow^0 has the same speed and handling as Sonic, but has slower Thoks.

^2Ability:^7 Homing Thok^0
Homing Thoks are slower than Speed Thoks, but home in on enemies, monitors, and springs.

^2Ability 2:^5 Chaos Blast^0
A small explosion dealing damage to nearby enemies. Has a cooldown of 5 seconds, and costs 10 rings.
Jump and press the spin key to use it.
#
Character
SkinName = sonic&shadow
Status = 32
PicName = SON&SHAD
PlayerText = ^2Sonic^0 must team up with his rival, ^2Shadow^0, to take on Dr. Eggman and rescue Tails.

Control Sonic while Shadow keeps up just fine... if he didn't fall in bottomless pits and die all the time.
Why does he fall down from the sky when he dies?

Player 2 can control Shadow the same way as Tails, but remember he has a Homing Thok instead of being able to Fly.


Lua Tweaks

Warning: All the Lua stuff here is outdated. It might work, it might not, but this section needs to be redone either way.


Now you have a completely functional Character Wad (well, if you made the frames. You might have given up while making the frames, I dunno. It's hard).

So you go play-testing. But... Why can't he/she turn super when Sonic can? Why can't he/she ascend with Fly or Swim simply by holding jump instead of tapping it? Well, he/she can do the hold-fly thing, but that leaves out spinning, and you don't want that, now do you?

This section will cover a few tweaks that can be done with Lua scripting, without it being super advanced.


Short introduction to Lua scripting

This part can be skipped if you already know a lot about Lua in SRB2.


Alright, let's start by taking a Lua thing.

addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo and player.mo.skin=="modern_sonic"
			if not(player.charflags&SF_SUPER)
				player.charflags=$1+SF_SUPER
			end
		end
	end
end)

Now let's examine it, line by line.

addHook("ThinkFrame", do

This line creates a "hook" for the game to know it's supposed to do something, I think. This hook is of the "ThinkFrame" type. Every frame, or Tic, it "runs" the code once.

	for player in players.iterate

This line I think makes it do something for players.

		if player.mo and player.mo.skin=="modern_sonic"

This line checks if a player is "existing", I believe, and also checks the name of the skin this player has on (Sonic, Tails, Knuckles, etcetera). The 'player.mo.skin=="modern_sonic" ' checks if the skin used is "modern_sonic". Remember that it refers to Name in S_Skin, and not RealName or HudName, like ObjctCfg.

			if not(player.charflags&SF_SUPER)

This line checks whether the player has the skinflag SF_SUPER active. Remember it being "unsettable"? If the player does NOT have the SF_SUPER skinflag, things after it will be executed/run, until an "end" line.

				player.charflags=$1+SF_SUPER

This line is only executed if the above "if" check returns true. The "not" after "if" makes it so the result gets flipped, as in false becomes true and true becomes false. But what this line does, is take the skinflags, and add SF_SUPER to it by force. The $1 is what the variable was before, so SF_SUPER gets added, instead of actually overwriting it.

			end
		end
	end
end)

These lines end all the checks and such. The first "end" ends the "if not(player.charflags&SF_SUPER)", the next ends the "if player.mo and player.mo.skin=="modern_sonic" ", the next ends the "for player in players.iterate", and the last ends the "do" after the "ThinkFrame" hook has started. The closing bracket closes the hook.


Now this may seem confusing if you don't know a lot about Lua already, but don't worry, it was only to give you a slight idea of what was going on there.


If you want to know more about Lua coding in SRB2, make sure to check this page: Lua

But beware, it's incomplete (at time of writing this).


Naming

Like stated earlier, you can name Lua scripts whatever you want in your Wad, as long as it starts with LUA_, so move on.


Tweaks

This section covers a few simple tweaks, and explains them.

Make sure to change "SKINNAME" to the name you put in S_Skin, and it must be lower-case to work.

Again, this section only covers a few tweaks. There are more Lua scripts here.

Super in singleplayer

You may have noticed only Sonic can turn super in singleplayer. That's because he's the only one with the SF_SUPER skinflag, which is unsettable via S_Skin. But Lua can force it on...

addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo and player.mo.skin=="SKINNAME"
			if not(player.charflags&SF_SUPER)
				player.charflags=$1+SF_SUPER
			end
		end
	end
end)

This code checks if the player has the SF_SUPER skinflag. If not, it adds it on by force, thus allowing you to turn super if you are ready for it (same requirements as for Sonic).

It also gives the ability to float if you hold spin while jumping when super, also like Sonic.

Spin + MultiAbility

It's quite stupid you can't have both spin and multiability, isn't it? Well, you can.

addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo and player.mo.skin=="SKINNAME"
			if not(player.pflags&(PF_NIGHTSMODE))
				if(player.pflags&(PF_THOKKED))
					player.charability2=CA2_MULTIABILITY
					else player.charability2=CA2_SPINDASH
				end
			end
		end
	end
end)

This code checks if you are in Nights mode, and if not, then it checks if you have used a midair ability, and if you have, it sets Ability2 to CA2_MULTIABILITY. If you haven't, it sets Ability2 to CA2_SPINDASH.

However, it only works for Thok, Fly, Glide, Homing Thok, Swim, Telekinesis, FallSwitch, and AirDrill. SlowFall always has multiability, and Double Jump and JumpBoost just receive a higher jump height, where you could just increase JumpFactor or ActionSpd to get the desired effect while keeping spin. But Float, however... If your character's ability is Float, you'll want this instead:

addHook("ThinkFrame", do
	for player in players.iterate
		if player.mo and player.mo.skin=="SKINNAME"
			if not(player.pflags&(PF_NIGHTSMODE))
				if(P_IsObjectOnGround(player.mo))
					player.charability2=CA2_MULTIABILITY
					else player.charability2=CA2_SPINDASH
				end
			end
		end
	end
end)

The difference between the codes are just that this one only checks if you are touching ground, instead of if you have used your ability, as Float doesn't properly send off a signal to say whether it has been used or not. Either way, the other one is recommended unless you want Float.