Writing a Header

Let's create a header for Ichigo. We have a lot of Gizmos, including ones that don't have Actor equivalents, but we can create custom Gizmos if we wish. Let's do that now. Let's create a custom Gizmo: the GoodBoy.

circle-info

You can find headers for Ichigo Template herearrow-up-right.

triangle-exclamation

Firstly, create a new file called goodboy.lua in the /include folder. We want to make sure our code does not run multiple times, so we need some sort of "load blocker". Type the following into the file:

if GoodBoy then return end

We need to include the Gizmos header in order to create a custom Gizmo. Let's do that. Write underneath our load blocker:

include "gizmos"

Next, we need to define the GoodBoy class. It doesn't have to be anything fancy at the moment, as long as it extends the Gizmo class.

class "GoodBoy" : extends "Gimzo" {
    __ready = function(self)
        print("GoodBoy created.")
    end;
    Bark = function(self)
        SCREENMAN:SystemMessage("Bark!")
    end;
}

Now we can create a GoodBoy within layout.lua:

myBoy = GoodBoy:new()

And we can call its methods within files such as main.lua:

Here is what the code looks like in its entirety:

We have successfully created our first header! Headers are great for creating classes that can then be instantiated as objects, which can come in handy for minigame files.

Last updated