Code Monkey home page Code Monkey logo

lua_utils's People

Contributors

exabytede avatar jushar avatar patrikjuvonen avatar qualiti avatar sbx320 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lua_utils's Issues

[classlib.lua] Question about destroying an object

Hey,

I love classlib, thanks for distributing it open source.

I have a question though, I am probably using destroy( ) wrong and I'm trying to look for the right way to do it but cannot find good examples and I am not sure if this is an error of my own or if it's the utility's fault.

ERROR: classlib.lua:126: bad argument #1 to 'pairs' (table expected, got nil)

That points to parentClasses and according to my knowledge my class/object has no parent classes, or at least I don't define them anywhere.

Here is the script I am trying to create.

local Class = { }

function Class:connect( hostname, username, password, database )
    self.instance = enew( Connection.create( 'mysql', 'dbname=' .. database .. ';host=' .. hostname, username, password, 'share=0;batch=0;log=1;tag=script' ), self )

    if ( self.instance ) then
        return self.instance
    end

    return false
end

function Class:disconnect( )
    if ( isElement( self.instance ) ) then
        self.instance:destroy( )
    end

    -- delete( self )
end

local database = new( Class )
database:connect( 'hostname', 'username', 'password', 'database' )
database:disconnect( )

What possibly could be wrong? The delete( self ) has been commented out, but what I want Class:disconnect( ) to do, is destroy the Connection element and essentially just delete the object.

Feel free to let me know if I should be doing my class in any different way. I am really new to the MTA OOP/Lua OOP scene so I'm trying to get into that to get better :-)

Warning when creating new class object with a player element

Whenever I try to create a new class object with enew of a player element, it throws a warning to the debug log, saying that onElementDestroy event is already being handled by the function, how is this possible? MTA restricts listening to certain player events?

enew( getPlayerFromName( 'Socialz' ), classes.player )

WARNING: classlib.lua:59: Bad usage @ 'addEventHandler' ['onElementDestroy' with this function is already handled]

I added getElementType(element) ~= 'player' to my version, but if I understand it right, we should never ignore this event as it deletes stuff from memory and if it's never deleted we have a memory leak.

Using onPlayerQuit instead of onElementDestroy did not resolve the warning.

enew is not work

i copy enew example from wiki ,but it can not work and ouput attempt to call method 'boom' (a nil value)

Virtual constructor call sequence ist wrong

Class1
|
Class2 (inherits from 1)
|
Class3 (inherits from 2)
|
Class4 (inherits from 3)

currently: new Class4 => call Class 3 virtual => call Class 2 virtual => call Class 1 virtual => call Class 4 constructor
expected:  new Class4 => call Class 1 virtual => call Class 2 virtual => call Class 3 virtual => call Class 4 constructor

Did addChangeHandler was removed forever?

Great job sbx320, your lib is very usefull for me. I saw function addChangeHandler at wiki, but cant find it in current sources. May be, is equivalent exists now?

Wiki please

Hello! You can add a wiki using your classlib?
Thx

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.