Giter Club home page Giter Club logo

a1-lua-shim's Introduction

This is a simple Lua script for the Aleph One engine. It makes it easier for multiple scripts to cooperate in the same context. It is intended to be especially helpful for scenario scripting.

Usage

Add this as the first script in your level/plugin/whatever. Make sure it runs before any other scripts.

In each script, you can declare triggers either of the ways that normally work in Aleph One. Piecemeal:

Triggers = {}

function Triggers.player_damaged(victim)
    victim.life = 300
end

function Triggers.idle()
   Players.print("Console spam!!!")
end

Or using the all-at-once method:

Triggers = {
   player_damaged = function(victim)
      victim.life = 300
   end,
   idle = function()
      Players.print("Console spam!!!")
   end,
}

This shim also provides an optional, extra classy method:

Triggers {
   player_damaged = function(victim)
      victim.life = 300
   end,
   idle = function()
      Players.print("Console spam!!!")
   end,
}

Triggers will be called, with all the normal parameters, in whatever order they are provided. If scripts A, B, and C all provide an idle trigger, then A's idle will be called first, B's second, and C's third. If a trigger has an error, the next triggers will still be called; in the previous example, if B's idle trigger throws a Lua error, C's idle trigger will still be called.

You can prevent subsequent triggers from being called by explicitly returning false from a trigger (e.g. if you prevented damage and don't want the next player_damaged trigger to be called).

Bonus Features

Danger Pairs

pairs gets its name changed to danger_pairs, so that casual use will be caught. pairs is a very useful function, irreplaceable for some purposes, and when used properly it can grant nice performance with no problems. However, careless use will cause films and multiplayer to desync. Thus, this shim renames it to danger_pairs. If you need it, and you're sure you're not going to cause a desync by using it, just use the longer name and you're all set. (In fact, this script contains two film-safe uses of danger_pairs!)

Print

This script makes it so that print will print both to the screen and to the Aleph One log. It will even work during Triggers.init or at the top level of the script.

Extras

  • secret-menu-lib.lua: A script designed to be used in conjunction with -a1-lua-shim.lua. It provides an overlay-based menu system which you can use to provide configuration, ancillary information, etc. at game time. It claims one overlay slot, normally visible only when the "Lua key" is held down. The menu is navigated with previous/next weapon, and items can be activated with the primary and secondary triggers. The interface is documented in the script itself.

Legalese

Copyright 2023 Solra Bizna. I expressly authorize you (the reader) to use this script, change it to fit your needs, strip out my name and claim it as your own, whatever. This copyright claim is solely to assert authorship long enough to immediately disclaim all copy-rights.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.