Jump to content

Weird issue exporting function


Overkillz

Recommended Posts

Well, Im going to be clear.

Why is this not working ?

--##Resource A
exports["resource_Name"].testExportF("Hello")

--##Resource B
function testExportF(message)
	outputChatBox(testStringA)
end

--RESULT: bad argument @ 'outputChatBox' [Expected string ar argument 1, got nil]

And why is this working with a 2nd argument

--##Resource A
exports["resource_Name"].testExportF("Hello", "hello2")

--##Resource B
function testExportF(message)
	outputChatBox(testStringA)
end

--RESULT: hello2

Exported function is clientside as u can see and resource name doesn't containt illegal characters

Regards.

Link to comment
  • Discord Moderators

It's because you're missing the colon

exports["resource_Name"]:testExportF("Hello")

Basically when you do table:method(arg), Lua passes along "table" as the first parameter, so it's effectively doing table.method(table, arg)

If you just do exports.resource.function then it's expecting that first parameter. Even though you can do exports.resource_Name.testExportF(nil, "hello")

  • Like 1
Link to comment

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...