Gorescript Editor – Elevators, Switches and Scripting

3 November 2017 Adrian Rusu

In this editor tutorial video we go over the final touches. First off, the red “end level” ball is an entity called “letter” (don’t ask), similar to weapons and powerups.

Secondly, we illustrate two advanced topics:

  • Elevators are sectors, similar to doors, that allow you to move up and down on top of them. Elevators are usually scripted.
  • Switches are special segments that are drawn on top of existing wall segments and render an on/off switch. Switches are always scripted since they don’t do anything by themselves.

 

via GIPHY

Thirdly, we go over scripting.

A Lua scriptfile can be added to a map by creating a “script.lua” file in the map folder and checking the “Has script” checkbox in the Map menu.

The following functions will be called if the script provides an implementation:

  • init(). Called every time you respawn.
  • onZoneEnter(zone: Zone). Called every time you enter a zone (as defined in the Zone layer).
  • onZoneLeave(zone: Zone). Called every time you leave a zone.
  • onPowerupPickup(powerup: Powerup). Called every time you pick up a powerup.
  • onPlayerOpenDoor(door: Door). Called every time you open a door.
  • onSwitchStateChange(switch: Switch). Called every time you use a switch.

Exposed classes:

  • Door
    • getId() : number
    • setAutomatic(value: boolean) : void
    • setSpeed(value: number) : void
    • open() : void
    • close() : void
    • setCrusher(value: boolean) : void
  • Elevator
    • getId() : number
    • getDownY() : number
    • setDownY() : number
    • getUpY() : number
    • setUpY() : number
    • setAutomatic(value: boolean) : void
    • setSpeed(value: number) : void
    • setPositionUp() : void
    • setPositionDown() : void
    • goUp() : void
    • goDown() : void
  • Powerup
    • getId() : number
  • Switch
    • getId() : number
    • isOn() : boolean
    • block() : void
  • Monster
    • getId() : number
    • awaken() : void
    • makeScripted() : void
  • Zone
    • name : string

Exposed globals:

  • doors: table of Door, key is door ID
  • elevators: table of Elevator, key is elevator ID
  • powerups: table of Powerup, key is powerup ID
  • switches: table of Switch, key is switch ID
  • monsters: table of Monster, key is monster ID

For reference you can check the full tutorial.

We’re also available on other stores and for now you can get Gorescript on WinGameStore¬†as well!