Search

open.mp forum

RegisterLogin

Discussion

General
Chat
Tech
Life
Art
Programming
open.mp
Development Updates
Questions and Suggestions
SA-MP
General Discussions
Videos and Screenshots
Support
Pawn Scripting
Tutorials
Releases
Plugins
Libraries
Filterscripts
Gamemodes
Maps
Advertisements
Other languages
Spanish/Espa?ol
Programaci?n
Discusi?n GTA SA Multijugador
Mods
Offtopic
Juegos
Portuguese/Portugu?s
Russian/???????
Italian/Italiano
Dutch/Nederlands
German/Deutsch
Romanian/Rom?na
Ex-Yu
Polish/Polski
Og?lne
Serwery
Skryptowanie
Filmiki i zdjecia
Lithuanian/Lietuvi?kas
French/Fran?ais
Hungarian/Magyar
Hindi/Urdu
Turkish
Other
Internal
Team
Hidden
Archived

Library

 Collections Links Members Roles

Yet Another Lua Plugin

YALP v1.0

ID
d6ouivfilegovhg7b7r0
author
illidans4's avatar

IllidanS4

@illidans4


View profile
Copy link
  Report member
started
Apr 20, 2019
replies
0
participating
No

scroll to top

powered by storyden

Login
Discussion
Plugins
Yet Another Lua Plugin
illidans4's avatar

IllidanS4

@illidans4


View profile
Copy link
  Report member
• 7y
Plugins

Yet Another Lua Plugin

plugin

YALP v1.0



Download



Tutorials





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:



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:



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



#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);

}





-- script.lua

local interop = require "interop"

interop.native.print("Hello from Lua!")

0 likes0 replies

    Please sign up or log in to reply