Help integrating dusk to my code.

alright, I might have just signed in the forums for the first time ever to ask why I am having so much trouble adding dusk to my code.

Lets start from the beginning,

I downloaded the file and transfered the folder “Dusk” to where my main.lua is, now if I open that folder there is Dusk.lua and a folder named dusk_core.

after so, I add local dusk = require(“Dusk.Dusk”) to my level1.lua, which is where I want to start to display my map. without adding anything else, which you should note that my code is fine and the game works even on my phone, as soon as that line local dusk = require(“Dusk.Dusk”) is entered and I save, I get this Corona runtime Error window saying

module ‘plugin_bit’ not found:

    no field package.preload[‘plugin_bit’]

    no file ‘C:blah blah blah my files on my computer \Corona Labs\Corona SDK\Resources\plugin_bit.lu’

    no file 'C:more files more more

   

more no file anyways a **** ton of no files searching for plugin_bit and different type of extensions like .dll     and .lua, also some odd ones searching for a plugin_bit\init.lua and loadall.dll, after those there are a lot of function ‘require’ errors that seem to come from the dusk_core folder probably trying to reach the plugin_bit files.

so I’m stuck at this and I have no clue whats wrong. I looked around where they were searching for the plugin_bit files and they are not there. Help?

Hi, to fix this you must enable the bit plugin. Edit your build.settings file:

settings = { orientation = { default = "landscapeRight", supported = { "landscapeRight" } }, plugins = { ["plugin.bit"] = { publisherId = "com.coronalabs" }, }, }

@bendikr5 is correct. The latest versions of Dusk require the ‘bit’ plugin for map decoding.

[EDIT]: Added an explanatory error message. Now you get a nice clean error if Dusk tries to use the compression library and the bit plugin isn’t loaded.

  • Caleb

thanks for the feedback, I’ve fixed it but I think I just ran into another problem. my buttons are set under the map once placed and I cant get them up to the front. note the buttons that are hidden under the map is a sprite and I have another button that isn’t a sprite that works perfectly and is at the top layer.

in case if needed, code provided for how i load my sprite in

– add Buttons and their cords

local guiInfo = require(“gui”)

local guiSheet = graphics.newImageSheet(“images/gui.png”, guiInfo:getSheet())

local buttonleft = display.newImage(guiSheet, guiInfo:getFrameIndex(“buttonleft”)) 

local buttonright = display.newImage(guiSheet, guiInfo:getFrameIndex(“buttonleft”))

local buttonup = display.newImage(guiSheet, guiInfo:getFrameIndex(“buttondown”))

local buttondown = display.newImage(guiSheet, guiInfo:getFrameIndex(“buttondown”))

buttonleft.x = 23

buttonleft.y = screenH - 50 

buttonleft.alpha = 1

buttonleft:scale( 0.45, 0.55 )

buttonright.x = 97

buttonright.y = screenH - 50

buttonright.alpha = 1

buttonright.xScale = -1

buttonright:scale( 0.45, 0.55 )

buttonup.x = 60

buttonup.y = screenH - 90

buttonup.alpha = 1 – image alpha

buttonup.yScale = -1

buttonup:scale( 0.5, 0.5 )

buttondown.x = 60

buttondown.y = screenH -10

buttondown.alpha = 1 – image alpha

buttondown:scale( 0.5, 0.5 )

*edit* just debating on just separating the images on separate files because that seems to work fine…

*edit2* while waiting for a answer, mind when you do to tell me how I could possibly get the map bounds? i can get the camera bounds, I just need map bounds. or possibly you guys have a better way to not push the camera off the edge of the map? :slight_smile:

My guess is that they appear under your map because you add them before you load your map. So to fix it:

--load the map local map = dusk.buildMap("map.json") --create a btn local btn = display.new(...)

If you want it a little bit cleaner and make it easier to add buttons later on, use display groups:

local sceneGroup = display.newGroup() local levelGroup = display.newGroup() local guiGroup = display.newGroup() sceneGroup:insert(levelGroup) sceneGroup:insert(guiGroup) guiGroup:insert(btn1) guiGroup:insert(btn2) levelGroup:insert(map) guiGroup:insert(btn3) --All buttons will now appear over the map...

To get the width of the total map, not just the portion of the map that is visible, you can use: 

local v = dusk.getPreference("mathVariables") local mapWidth = v["mapWidth"] \* v["tileWidth"]

I would guess its a better way of getting it, but I could not find any :stuck_out_tongue:

@kevin_dompierre: I’d recommend @bendikr5’s second solution - the map is just a glorified display group, so insert it into your layering system however you want.

Also, Dusk does include the stats as members of the map, so no need to do math variable juggling :D:

map.data.mapWidth/Height = the dimensions of the map in tiles map.data.width/height = dimensions in pixels map.data.tileWidth/Height = dimensions of tiles in pixels
  • Caleb

Hi, to fix this you must enable the bit plugin. Edit your build.settings file:

settings = { orientation = { default = "landscapeRight", supported = { "landscapeRight" } }, plugins = { ["plugin.bit"] = { publisherId = "com.coronalabs" }, }, }

@bendikr5 is correct. The latest versions of Dusk require the ‘bit’ plugin for map decoding.

[EDIT]: Added an explanatory error message. Now you get a nice clean error if Dusk tries to use the compression library and the bit plugin isn’t loaded.

  • Caleb

thanks for the feedback, I’ve fixed it but I think I just ran into another problem. my buttons are set under the map once placed and I cant get them up to the front. note the buttons that are hidden under the map is a sprite and I have another button that isn’t a sprite that works perfectly and is at the top layer.

in case if needed, code provided for how i load my sprite in

– add Buttons and their cords

local guiInfo = require(“gui”)

local guiSheet = graphics.newImageSheet(“images/gui.png”, guiInfo:getSheet())

local buttonleft = display.newImage(guiSheet, guiInfo:getFrameIndex(“buttonleft”)) 

local buttonright = display.newImage(guiSheet, guiInfo:getFrameIndex(“buttonleft”))

local buttonup = display.newImage(guiSheet, guiInfo:getFrameIndex(“buttondown”))

local buttondown = display.newImage(guiSheet, guiInfo:getFrameIndex(“buttondown”))

buttonleft.x = 23

buttonleft.y = screenH - 50 

buttonleft.alpha = 1

buttonleft:scale( 0.45, 0.55 )

buttonright.x = 97

buttonright.y = screenH - 50

buttonright.alpha = 1

buttonright.xScale = -1

buttonright:scale( 0.45, 0.55 )

buttonup.x = 60

buttonup.y = screenH - 90

buttonup.alpha = 1 – image alpha

buttonup.yScale = -1

buttonup:scale( 0.5, 0.5 )

buttondown.x = 60

buttondown.y = screenH -10

buttondown.alpha = 1 – image alpha

buttondown:scale( 0.5, 0.5 )

*edit* just debating on just separating the images on separate files because that seems to work fine…

*edit2* while waiting for a answer, mind when you do to tell me how I could possibly get the map bounds? i can get the camera bounds, I just need map bounds. or possibly you guys have a better way to not push the camera off the edge of the map? :slight_smile:

My guess is that they appear under your map because you add them before you load your map. So to fix it:

--load the map local map = dusk.buildMap("map.json") --create a btn local btn = display.new(...)

If you want it a little bit cleaner and make it easier to add buttons later on, use display groups:

local sceneGroup = display.newGroup() local levelGroup = display.newGroup() local guiGroup = display.newGroup() sceneGroup:insert(levelGroup) sceneGroup:insert(guiGroup) guiGroup:insert(btn1) guiGroup:insert(btn2) levelGroup:insert(map) guiGroup:insert(btn3) --All buttons will now appear over the map...

To get the width of the total map, not just the portion of the map that is visible, you can use: 

local v = dusk.getPreference("mathVariables") local mapWidth = v["mapWidth"] \* v["tileWidth"]

I would guess its a better way of getting it, but I could not find any :stuck_out_tongue:

@kevin_dompierre: I’d recommend @bendikr5’s second solution - the map is just a glorified display group, so insert it into your layering system however you want.

Also, Dusk does include the stats as members of the map, so no need to do math variable juggling :D:

map.data.mapWidth/Height = the dimensions of the map in tiles map.data.width/height = dimensions in pixels map.data.tileWidth/Height = dimensions of tiles in pixels
  • Caleb