Files

> > CS2D > Lua Scripts > Vehk's Lua Wrapper
Files overviewCS2D overviewLua Scripts overview

English Vehk's Lua Wrapper >

6 comments13 kb, 497 Downloads

old Vehk's Lua Wrapper

Vehk
User Off Offline

I will not be updating the file on the archive often! Most updates will be done on the github repo. Get the latest updates there!


This is my attempt to simplify CS2D's Lua API. It was inspired by user Livia's API mentioned here thread cs2d Extending native functions, but that project appears to be dead.

The wrapper allows you to treat players like objects (similar to classes or structures) by using tables and metatables. It also overrides a few CS2D functions to make them easier to use, while maintaining compatibility with existing code.

I'm not going to give a lot of details here because I've already written a large readme, available on github and in the file archive.

The archive also includes samples which are also available on github. These are based on the samples in sys/lua/samples and include gungame.lua and utsfx.lua.

A snippet from gungame.lua
More >


The wrapper will detect if user EngiN33R's file cs2d [EngiN33R] UTF-8 Wrapper Library is loaded and update the colorcode symbol (©) accordingly. A function is provided to get the correct color code or create a color string given RGB, C (see section 4 of the readme).
edited 2×, last 16.12.17 11:44:31 pm
Approved by SQ

Download Download

13 kb, 497 Downloads

Comments

6 comments
To the start Previous 1 Next To the start

Log in!

You need to log in to be able to write comments!Log in

old ⚠️Important!

Earthkin
User Off Offline

Hello everyone! I have a very important update regarding this file. Firstly thank you Vehk for making this project. Unfortunately the archive's files contain an error rendering this totally useless!

Vehk made a comment about this and suggested copying the changes from the GitHub repo. Unfortunately the repo has been deleted and it doesn't look like Vehk is around anymore (I tried PM'ing him).

Fortunately the fix is really simple. It just requires two changes to players.lua.

First on line 198 it should be changed to this
1
if (player_index[key] ~= nil) then
(" ~= nil" is added, otherwise this check will fail for read-only values which are set to false in the table)

Then on line 208 it should be changed to
1
return f(rawget(table, "id"), value, key)
Here we add "return ". Without returning here the code continues and a few lines down "rawset" is called adding the key to the table. Because of this the first time you alter a player value it works as expected, the player value is updated. However any further changes will only be applied to the value stored in the table and the player's value is not updated!

With those fixes you will be able to use this wrapper! I'm considering making a post to explain the issue. I also plan to upload my own version of this wrapper with the fixes included. Before I do so I want to do further testing to ensure it works correctly and I also need to update it to support new cs2d Lua features. Thank you for reading this post, and thank you again to Vehk for this wonderful wrapper! ❤️
I like it!
edited 1×, last 22.07.25 11:34:36 pm

old Bugfixes

Vehk
User Off Offline

There was a bug in players.lua that caused some CS2D player values to not be accessible (read or write) with the wrapper. It has been fixed, available on github. Or you can simply copy the changes from here (only two different lines): commit page.

I've also made a few minor additions to the wrapper that are not available from this file, get the latest from github!

old

Masea
Super User Off Offline

@user Gaios: Yeah and I'm getting used to that nowadays.
I like it!

old

Gaios
Reviewer Off Offline

@user Masea: That's what I did in my framework..
I like it!

old

Masea
Super User Off Offline

I'll check it once I'm home. Something probably I want.
I like it!
To the start Previous 1 Next To the start