Skip to Content
TutorialsA stronger pistol

A stronger pistol

The smallest useful pack: the starting pistol hits harder, fires faster and its bolts fly further. No code. About five minutes.

Open or make a project

Any project works, even one with no levels: weapon values apply everywhere while the pack is loaded.

Open the Weapons window

It’s a tab on the right (or Window › Weapons). Each weapon has a section; Weapon 0 is the pistol.

The Weapons window with Weapon 0 open
Tick a field to change it in this pack; unticked fields keep the game's value.

Change three fields

Open Weapon 0 and tick:

FieldValueEffect
damage12Each bolt hits harder
delay6Fewer frames between shots: faster fire
lifetime40Bolts live longer: more range

The section title gets “(changed)”.

Save and play

Save weapons (or Ctrl+S), then Play. Fire away.

The player’s own F9 Weapons tab wins over a pack: if they ticked “Modify” for the pistol there, they see their values, not yours.

Which numbers to try

FieldRangeNotes
damage0–2550 hits for nothing
delay0–255Frames at 30 fps between shots
throw_delay1–127Thrown weapons only
lifetime1–255Laser bolts live lifetime × 6 frames
spread_x, spread_y0–819265536 is a full turn; 0 is dead accurate
speed0.1–2000Projectile speed

Not every weapon uses every field: see the table on Weapons API.

The same in Lua

Studio turns the Weapons window into a script for you. Written by hand it’s:

scripts/weapons.lua
jfg.weapon(0, { damage = 12, delay = 6, lifetime = 40 }) -- the pistol jfg.weapon(5, { spread_x = 0, spread_y = 0 }) -- a dead-accurate Tri-Rocket Launcher

Lua lets you change weapons as the game goes: say, a faster gun only in one level.

jfg.on("level", function(level) if level == jfg.level_id("level_landing") then jfg.weapon(0, { delay = 4 }) else jfg.weapon(0, { delay = 8 }) end end)
Last updated on