Luawe All pages

Categories

Some values can only be one of a few fixed words: an ease is quad or sine or bounce, a text is set to the left, the center or the right, a key is space or enter. In Luawe each such set is a category (cat for short), and each word in it is an item: a value of its own, written as cat, the category's name and the item.

local door = things.find("Door")
door:tween({ y = 4 }, 1, cat.Ease.quadratic, cat.Direction.out)

local label = things.new(cat.Kind.text, { text = "Ready?" })
label.align = cat.Align.left
label.font = cat.Font.headline

The editor knows every category. Type cat. and it lists them; type cat.Ease. and it lists the eases; inside tween(door, {}, 1, it offers them before anything else. Rest the mouse on an item to see what it does.

What an item is

An item knows its category, and prints the way it is written:

print(cat.Ease.quadratic, type(cat.Ease.quadratic), cat.Ease.quadratic.name)

It prints

cat.Ease.quadratic Ease quadratic

type gives the category's name, so an item of cat.Ease is an Ease. An item is equal only to itself: cat.Ease.quadratic == cat.Ease.quadratic is true, cat.Ease.quadratic == cat.Ease.sinusoidal is false. It can be a key in a table, like a number or a string. A category itself is a cat: type(cat.Ease) is "cat".

A name a category doesn't have is a mistake, and the message lists the ones it has:

local asked = "middle"
print(pcall(function() return cat.Align[asked] end))

It prints

false door.luawe:2: cat.Align has no 'middle': left, center, right

Items the game gives you

What the game hands a script is an item too, wherever it is one of a few fixed words: thing.kind is cat.Kind.object, cat.Kind.floor, cat.Kind.text or cat.Kind.group, a text's align is an Align, input.keyDown gives the key that went down as a Key, and input.mouseDown gives a MouseButton:

input.keyDown:connect(function(key)
    if key == cat.Key.space then
        print("jump")
    end
end)
print(input.isDown(cat.MouseButton.left))

Going through a category

A for loop goes through a category's items in order, and has asks whether a word is one of them. # counts the items, pairs and ipairs go through them like a list, and an item's name is its last word:

for _, item in cat.Align do
    print(item)
end
print(cat.Align:has("left"), cat.Align:has("middle"))
print(#cat.Direction, cat.Direction.inAndOut.name)

It prints

cat.Align.left
cat.Align.center
cat.Align.right
true false
4 inAndOut

Categories of your own

cat.new makes a category from a list of words, in quotes. It takes the name of the variable it is given to, and that name is the type of its items:

local weather = cat.new({ "sunny", "rainy", "stormy" })
local today: weather = weather.rainy
print(today, type(today), today == weather.rainy)
for _, w in weather do
    print(w.name)
end

It prints

weather.rainy weather true
sunny
rainy
stormy

weather.snowy is a mistake, just as cat.Ease.wobble is. The words are written like variable names: letters, digits and _, not starting with a digit.

Items and text

Where text is wanted, an item is its name: "kind: " .. door.kind is "kind: object", and string.upper(cat.Kind.decoration) is "DECORATION". print and tostring show it as it is written in a script (cat.Kind.decoration), so what a script prints can be pasted back into one.

A word in quotes is not an item: door.kind == "object" is false, and tween(door, {}, 1, "quadratic") is a mistake that says what to write instead (cat.Ease.quadratic). The editor marks such a word before the script runs.

Every category

The reference page Categories lists every item of every category. These are the categories:

  • For glides: cat.Ease (how a glide speeds up and slows down) and cat.Direction (which end of it the ease is at).
  • For things: cat.Kind (what a thing is: thing.kind, thing.type, things.new, and the kind a search or a ray looks for), cat.Child (thing:addChild), cat.TouchEffect (what touching an object does), cat.ButtonMode and cat.HitboxShape.
  • For texts: cat.Align, cat.Font, cat.TextAnimation (how a text comes in and goes) and cat.IdleAnimation (what its letters do).
  • For the player's input: cat.Key (keys, fingers and a controller's buttons) and cat.MouseButton (the mouse's buttons). input.isDown takes either.
  • For the camera: cat.CameraEffect (camera:effect), cat.DisplayStyle, cat.NoisePattern and cat.MeltBehind.
  • For children: cat.MoveMode, cat.Target, cat.FollowMode, cat.Axes, cat.ProximityMode, cat.GradientShape, cat.Spread, cat.ParticleShape, cat.ParticleEnd, cat.Aim, cat.ParticleArea, cat.ParticleHit (what a particle does when it hits something), cat.Collision (what it hit: Particles that bounce), cat.FramePlay (how a picture's frames play, for a picture or for particles), cat.PictureStart, cat.PictureFit, cat.BlendMode (also how the noise effect is blended), cat.MaskKind, cat.MaskShape and cat.MaskReads.
  • For colors: cat.Theme (the theme's colors: a thing's color given cat.Theme.water follows the theme's water, see Colors).
  • For sound: cat.PitchMode (whether a higher pitch is also quicker: Sound and music).
  • For the theme: cat.FloorPattern, cat.BlockStyle and cat.Background.