[Plugin] Yet Another Lua Plugin

Started by Kalcor, SA:MP, Jul 24, 2023, 04:13 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

FrankJScott

In response to the man talking about all the clubs in golf, golf clubs for amateurs, fairway wood covers, unusual golf head covers, golf club head types, the golfers club stores, club woods, the golfers shop, golf head covers sports teams, fairway woods 3, pf golf club, golf club covers for women, last year's golf clubs for sale, compare hybrid golf clubs, difference between 3 wood and driver, golf driver how to, golf head cover sets for sale, club golf club, head golf clubs, golf club head covers,  I can vouch for this on bing on golf club headcovers link for fan golf, discount hybrid golf clubs, golf woods for sale, golf woods set, golf covers for sale, a type of golf club, set of head covers, golf headcovers set of 3, golf club head covers for sale, golf club show, unique golf headcovers, driver and fairway wood covers, green driver headcover, jack golf clubs, club woods, all clubs in a golf set, wood club head covers, golf fairway woods for sale, driver golf club for beginners, golfclub outlet, golf head covers 3 wood, use driver on fairway, also. See More High Rated Male Regenerative Aesthetics Sarasota Site 031132f

FrankJScott

In response to the lady inquiring about boxy iphone case, cheap cell phone cases with free shipping, buy case, phone cover strap, real leather cell phone cases, cross body phone chain, phone cover with card slot, iphone covers with card holder, phone case with crosses, the best phone covers,  I highly suggest this excellent refurbished Iphones link or 2 phone wallet, cell phone case chain strap, crossbody iphone wallet case, strap iphone case, phone case that looks like a purse, phone lanyard pouch, phone case with security chain, 2 in 1 phone case, best new phone cases, crossbody rope phone case, not forgetting sites such as this read this post here on used Iphones forum not to mention phone cases for my phone, hanging phone case, best company for phone cases, best smartphone protection, cute phone accessories, cross bag phone case, flip phone accessories, iphone 12 crossbody wallet case, crossbody phone case iphone 13, iphone case case, together with this dig this for cheap Iphones site which is also great. Also, have a look at this top rated refurbished Iphone 11 blog on top of phone lanyard wallet, crossbody iphone wallet case, phone case with cross body strap, black cases, designer cell phone strap, full coverage phone case, custom phone case with photos, smartphone cases and covers, iphone 6 crossbody case, make a iphone case, which is worth considering with this web site about used samsung phones advice not to mention crossbody phone case iphone 12, iphone 13 pro max crossbody case, designer phone cases iphone 12 pro, phone case holder with strap, phone case with card holder and strap,  more for and don't forget best designer phone case, best looking phone cases, iphone travel case with strap, crossbody phone case for samsung galaxy, coolest phone cases ever,  for good measure. Check more @ High Rated Pshot Services Sarasota Website 32f8d49

Kalcor, SA:MP

[Plugin] Yet Another Lua Plugin


Introduction

This plugin allows you to use Lua, your favourite dynamic flexible scripting language, in SA-MP, for all purposes, be it sandboxing user scripts, debugging the server, or developing filterscripts and gamemodes. YALP provides lightweight and flexible Lua environment that can use existing or future natives from SA-MP or plugins.



The main feature of YALP is a powerful interop API to interact with existing Pawn natives and callbacks. It is very easy to call existing functions, without needing to declare them anywhere:


Code:

interop.native.SetPlayerPos(0, 1235.31, -2331.84, 12.33)

YALP automatically converts all arguments to their proper Pawn cells, and allows you to specify what the function returns in the actuall call. All standard cell and single-dimensional array types are supported.



Callbacks can be specified in a similar simple way:


Code:

function interop.public.OnPlayerConnect(playerid)
  -- ...
end

Thanks to these mechanisms, you can use any framework you want, or build your own in Lua, without depending on new versions of this plugin.



Configuration

There is no special XML, JSON or other configuration of this plugin, because you can specify everything when you create a new Lua state (you can create any number you wish, and run any code inside). You can specify what packages should be loaded or available in the Lua instance, how much maximum memory it should take, or even limit for how long Lua functions can run.



Features

All standard Lua packages are available (although some of the more unsafe ones aren't allowed by default). The powerful interop package can interface with any Pawn native function or callback. There is also an advanced timer library with support for simple asynchronous functions (with Lua coroutines) and all sorts of timers. The remote package contains functions for remote communication between two separate Lua instance (via serialization or proxies).



The standard Lua packages are also enhanced with a couple of useful functions. Please see the wiki for a list of all new functions.



The Pawn API is basically a port of the Lua C API, allowing advanced manipulation of the Lua machine. It is recommended to use the Lua API, since it can do everything that Pawn can do, but if you need to interact with an existing complex Pawn library, it is possible as well.



Sample code


pawn Code:

#include <a_samp>
#include <YALP>

public OnFilterScriptInit()
{
    new Lua:l = lua_newstate(); // creates a new Lua instance
   
    if(lua_loadfile(l, "script.lua")) // loads a Lua script and returns an error code
    {
        lua_stackdump(l); // prints the stack for more information about the error
        return;
    }
    lua_bind(l); // binds the Lua instance to the current Pawn filterscript/gamemode, so all interation with it is rerouted to Lua
    // if the binding succeeds, this code is not run (and the Lua instance is destroyed if the script is unloaded)
    lua_stackdump(l);
}


Code:

-- script.lua
local interop = require "interop"
interop.native.print("Hello from Lua!")


Source: [Plugin] Yet Another Lua Plugin