# Zwoptex and external modules?

**URL:** <https://forums.solar2d.com/t/zwoptex-and-external-modules/294894>\
**Category:** Zwoptex\
**Created:** [October 8, 2011, 3:01pm UTC](https://forums.solar2d.com/t/zwoptex-and-external-modules/294894 "2011-10-08T15:01:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Inkoqnito](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/i/34f0e0/32.png) [@Inkoqnito](https://forums.solar2d.com/u/Inkoqnito)\
**Post date:** [October 8, 2011, 3:01pm UTC](https://forums.solar2d.com/t/zwoptex-and-external-modules/294894/1 "2011-10-08T15:01:27Z")

</div>

Hey Everyone!

I have been trying to get external modules to work with external modules but can’t get it to work!?

I keep getting the error: attempt to index local ‘test’ (a nil value)

in main i have:

[lua]local test = require (“test”)

local test1 = test.new()[/lua]

and in my external module:

[lua]local test = {}  
local test\_mt = {\_\_index = test}

function test.new()

local newTest = {

}

return setmetatable(newTest, test\_mt)

end

return test[/lua]

as you can see i even took out all my zwoptex code i first had :

[lua]local zwoptexData = require “testsheet2”  
local data = zwoptexData.getSpriteSheetData()  
local spriteSheet = sprite.newSpriteSheetFromData( “testsheet2.png”, data )

local spriteSet = sprite.newSpriteSet(spriteSheet,1,33)

sprite.add(spriteSet, “ufo”, 1, 1, 300, 0)  
sprite.add(spriteSet, “explosion”, 2, 33, 300, 1)  
local spriteInstance = sprite.newSprite(spriteSet)

spriteInstance.x = 200  
spriteInstance.y = 100  
spriteInstance:prepare(“ufo”)  
spriteInstance:play(“ufo”)[/lua]

in newTest, guess i am not understanding this yet? but would really like some help:)

Thanks in advance=) [import]uid: 90942 topic\_id: 16124 reply\_id: 316124[/import]

---

<div class="post-metadata">

**Author:** ![PerturbedMollusk](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/p/49beb7/32.png) [@PerturbedMollusk](https://forums.solar2d.com/u/PerturbedMollusk)\
**Post date:** [December 1, 2011, 6:32am UTC](https://forums.solar2d.com/t/zwoptex-and-external-modules/294894/2 "2011-12-01T06:32:50Z")

</div>

bump. Same problem. [import]uid: 106739 topic\_id: 16124 reply\_id: 70801[/import]

---

<div class="post-metadata">

**Author:** ![Ludicrous\_Software](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/l/a87d85/32.png) [@Ludicrous\_Software](https://forums.solar2d.com/u/Ludicrous_Software)\
**Post date:** [December 10, 2011, 1:19pm UTC](https://forums.solar2d.com/t/zwoptex-and-external-modules/294894/3 "2011-12-10T13:19:19Z")

</div>

Just tried copying and pasting your code (without the Zwoptex stuff) into a couple of sample files, and it seems to work fine for me.

If you’re getting a nil error with ‘test’, then the problem seems to be with loading the module in the first place.

[import]uid: 1294 topic\_id: 16124 reply\_id: 72966[/import]
