Jump to content

OOP Functions


3B00DG4MER

Recommended Posts

Posted

Hi guys,

I tried to Export an OOP function like that:

function dxEditBox:create() 
  
end 

<export function="dxEditBox:create" type="client" /> 

i Called it like that :

exports.RESOURCENAME:dxEditBox:create() 

Posted
    local menu = exports[ "SAFMenu" ].Menu_create( localPlayer, bot:getData("name"),155,0, 0 ) 
    loadstring(exports[ "SAFMenu" ].Menu_open( localPlayer,absoluteX, absoluteY ))(menu) 

failed to call 'SAFMenu:Menu_open' [string "?"]

Bad Argument 1 [Expected String got Boolean]

attempt to call a boolean

Posted

Why are you using loadstring? loadstring is used to run code, you're passing the returned value of Menu_open to loadstring.

Posted
  
Menu = {} 
Menu.__index = Menu 
Menu.instances = {} 
Menu_open = Menu.open 
function Menu:open(x, y) 
... 
     return self 
end 
  

        <export function="Menu_open" type="client" /> 

Posted
local menu = exports[ "SAFMenu" ].Menu_create( localPlayer, bot:getData("name"),155,0, 0 ) 

As far as I know, exports is a table, but exports["SAFMenu"] is more like a class... I think you were meant to put a semi-colon ( : ) instead of the period ( . ) between exports["SAFMenu"] and Menu_create

Posted

Not really. Just replace the dot with a semi-colon.

   local menu = exports[ "SAFMenu" ]:Menu_create( localPlayer, bot:getData("name"),155,0, 0 ) 
exports[ "SAFMenu" ]:Menu_open( localPlayer,absoluteX, absoluteY ) 

Posted (edited)
Menus = {} 
Menus.main = exports[ "SAFMenu" ]:Menu_create("Test",155,0, 0 ) 

That Line Works

That one is killing ME !

exports[ "SAFMenu" ]:Menu_open(Menus.main,absoluteX, absoluteY ) 

Failed to call:"SAFMenu:Menu_open" [string: ?]

Edited by Guest
Posted

Did you even read the replies in the topic TAPL linked you to? Meta tables are resource specific not global.

If you don't understand then it's time to learn more about OOP or just drop it and use procedural syntax.

Posted

Well, you can't export OOP functions right now, a bug is reported (again, TAPL's links) so you just have to wait or try something different.

The topic covered a possible work around, check it.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...