now my displayInventory function:
function displayInventory()
local i
local imagem2, displayImte
local posX, posY
if not fundoInventario then
fundoInventario = display.newImageRect( "textura\_bag.png", 320, 58 )
fundoInventario.x = 451
fundoInventario.y = 160
fundoInventario.rotation = 90
invGroup:insert( fundoInventario )
end
for i=1,slots do
local itemInSlot = inventoryBag[i]
print("ItemInSlot",i,itemInSlot)
if itemInSlot ~= nil or itemInSlot ~= 0 then
if i == 1 and itemInSlot == 1 or i == 2 and itemInSlot == 1 or i == 3 and itemInSlot == 1 or i == 4 and itemInSlot == 1 or i == 4 and itemInSlot == 1 or i == 5 and itemInSlot == 1 then
imagem2 = items[1]
if \_G.pauMarretaNoInvCreate-0 == 0 then
\_G.pauMarretaNoInvCreate = 1
saveit.save()
displayImte = display.newImageRect( imagem2 .. ".png", 28, 58 )
displayImte.xScale = 0.6
displayImte.yScale = 0.6
displayImte.alpha = 0
displayImte.x = 451
invGroup:insert( displayImte )
if i == 1 then
displayImte.y = 30
elseif i == 2 then
displayImte.y = 95
elseif i == 3 then
displayImte.y = 160
elseif i == 4 then
displayImte.y = 225
elseif i == 5 then
displayImte.y = 290
end
transition.to( displayImte, { delay = 300, time = 500, alpha = 1 } )
clickPauMarretaInv = function(e)
if e.phase == "ended" then
itemSelecionado = items[1]
if \_G.podeFucao-0 == 0 then
if item1Fucao == nil and item2Fucao ~= items[1] then
item1Fucao = items[1]
elseif item2Fucao == nil and item1Fucao ~= items[1] then
item2Fucao = items[1]
end
end
if \_G.podeFucao-0 == 1 then
borda.x = 451
if i == 1 then
borda.y = 30
elseif i == 2 then
borda.y = 95
elseif i == 3 then
borda.y = 160
elseif i == 4 then
borda.y = 225
elseif i == 5 then
borda.y = 290
end
borda.alpha = 1
borda:toFront()
elseif \_G.podeFucao-0 == 0 and item1Fucao == items[1] then
if borda then
borda.alpha = 0
end
bordaFucao.x = 451
if i == 1 then
bordaFucao.y = 30
elseif i == 2 then
bordaFucao.y = 95
elseif i == 3 then
bordaFucao.y = 160
elseif i == 4 then
bordaFucao.y = 225
elseif i == 5 then
bordaFucao.y = 290
end
bordaFucao.alpha = 1
bordaFucao:toFront()
elseif \_G.podeFucao-0 == 0 and item2Fucao == items[1] then
if borda then
borda.alpha = 0
end
bordaFucao2.x = 451
if i == 1 then
bordaFucao2.y = 30
elseif i == 2 then
bordaFucao2.y = 95
elseif i == 3 then
bordaFucao2.y = 160
elseif i == 4 then
bordaFucao2.y = 225
elseif i == 5 then
bordaFucao2.y = 290
end
bordaFucao2.alpha = 1
bordaFucao2:toFront()
end
if \_G.podeFucao-0 == 1 then
clickPauMarreta = clickPauMarreta + 1
end
fucaoItens = function()
if item1Fucao == items[1] and item2Fucao == items[2] or item1Fucao == items[2] and item2Fucao == items[1] then
-- audio.play( fucaoAceita ) -- som para a combinacao de itens
\_G.podeFucao = 1
saveit.save()
transition.to( bordaFucao, { time = 1000, alpha = 0 } )
transition.to( bordaFucao2, { time = 1000, alpha = 0 } )
item1Fucao = nil
item2Fucao = nil
removeItemFromInventory(1)
removeItemFromInventory(2)
saveInventory()
itemSelecionado = "vazio"
transition.to( displayImte, { time = 1000, alpha = 0, onComplete = function() displayImte:removeSelf(); end } )
transition.to( displayImte2, { time = 1000, alpha = 0, onComplete = function() displayImte2:removeSelf(); end } )
if inventoryBag[1] == 0 then
addItemToInventory(4,1)
saveInventory()
displayInventory()
elseif inventoryBag[2] == 0 then
addItemToInventory(4,2)
saveInventory()
displayInventory()
elseif inventoryBag[3] == 0 then
addItemToInventory(4,4)
saveInventory()
displayInventory()
elseif inventoryBag[4] == 0 then
addItemToInventory(4,4)
saveInventory()
displayInventory()
elseif inventoryBag[5] == 0 then
addItemToInventory(4,5)
saveInventory()
displayInventory()
end
else
--audio.play( erroFucao )
\_G.podeFucao = 1
saveit.save()
transition.to( bordaFucao, { time = 1000, alpha = 0 } )
transition.to( bordaFucao2, { time = 1000, alpha = 0 } )
item1Fucao = nil
item2Fucao = nil
end
end
if item1Fucao ~= nil and item2Fucao ~= nil then
fucaoItens()
end
itemGrandePauMarreta = function()
if clickPauMarreta \< 2 then
clickPauMarreta = 0
end
if clickPauMarreta \>= 2 then
clickPauMarreta = 0
pauMarretaGrande.alpha = 1
pauMarretaGrande:toFront()
end
end
if \_G.podeFucao-0 == 1 then
tPauMarreta = timer.performWithDelay( 500, itemGrandePauMarreta, 1 )
end
end
end
displayImte:addEventListener( "touch", clickPauMarretaInv )
end
elseif i == 1 and itemInSlot == 2 or i == 2 and itemInSlot == 2 or i == 3 and itemInSlot == 2 or i == 4 and itemInSlot == 2 or i == 4 and itemInSlot == 2 or i == 5 and itemInSlot == 2 then
imagem2 = items[2]
if \_G.cabecaMarretaNoInvCreate-0 == 0 then
\_G.cabecaMarretaNoInvCreate = 1
saveit.save()
displayImte2 = display.newImageRect( imagem2 .. ".png", 28, 12 )
displayImte2.xScale = 1
displayImte2.yScale = 1
displayImte2.alpha = 0
displayImte2.x = 451
invGroup:insert( displayImte2 )
if i == 1 then
displayImte2.y = 30
elseif i == 2 then
displayImte2.y = 95
elseif i == 3 then
displayImte2.y = 160
elseif i == 4 then
displayImte2.y = 225
elseif i == 5 then
displayImte2.y = 290
end
transition.to( displayImte2, { delay = 300, time = 500, alpha = 1 } )
clickCabecaMarretaInv = function(e)
if e.phase == "ended" then
itemSelecionado = items[2]
if \_G.podeFucao-0 == 0 then
if item1Fucao == nil and item2Fucao ~= items[2] then
item1Fucao = items[2]
elseif item2Fucao == nil and item1Fucao ~= items[2] then
item2Fucao = items[2]
end
end
if \_G.podeFucao-0 == 1 then
borda.x = 451
if i == 1 then
borda.y = 30
elseif i == 2 then
borda.y = 95
elseif i == 3 then
borda.y = 160
elseif i == 4 then
borda.y = 225
elseif i == 5 then
borda.y = 290
end
borda.alpha = 1
borda:toFront()
elseif \_G.podeFucao-0 == 0 and item1Fucao == items[2] then
if borda then
borda.alpha = 0
end
bordaFucao.x = 451
if i == 1 then
bordaFucao.y = 30
elseif i == 2 then
bordaFucao.y = 95
elseif i == 3 then
bordaFucao.y = 160
elseif i == 4 then
bordaFucao.y = 225
elseif i == 5 then
bordaFucao.y = 290
end
bordaFucao.alpha = 1
bordaFucao:toFront()
elseif \_G.podeFucao-0 == 0 and item2Fucao == items[2] then
if borda then
borda.alpha = 0
end
bordaFucao2.x = 451
if i == 1 then
bordaFucao2.y = 30
elseif i == 2 then
bordaFucao2.y = 95
elseif i == 3 then
bordaFucao2.y = 160
elseif i == 4 then
bordaFucao2.y = 225
elseif i == 5 then
bordaFucao2.y = 290
end
bordaFucao2.alpha = 1
bordaFucao2:toFront()
end
fucaoItens = function()
if item1Fucao == items[1] and item2Fucao == items[2] or item1Fucao == items[2] and item2Fucao == items[1] then
-- audio.play( fucaoAceita ) -- som para a combinacao de itens
\_G.podeFucao = 1
saveit.save()
transition.to( bordaFucao, { time = 1000, alpha = 0 } )
transition.to( bordaFucao2, { time = 1000, alpha = 0 } )
item1Fucao = nil
item2Fucao = nil
removeItemFromInventory(1)
removeItemFromInventory(2)
saveInventory()
itemSelecionado = "vazio"
transition.to( displayImte, { time = 1000, alpha = 0, onComplete = function() displayImte:removeSelf(); end } )
transition.to( displayImte2, { time = 1000, alpha = 0, onComplete = function() displayImte2:removeSelf(); end } )
if inventoryBag[1] == 0 then
addItemToInventory(4,1)
saveInventory()
displayInventory()
elseif inventoryBag[2] == 0 then
addItemToInventory(4,2)
saveInventory()
displayInventory()
elseif inventoryBag[3] == 0 then
addItemToInventory(4,4)
saveInventory()
displayInventory()
elseif inventoryBag[4] == 0 then
addItemToInventory(4,4)
saveInventory()
displayInventory()
elseif inventoryBag[5] == 0 then
addItemToInventory(4,5)
saveInventory()
displayInventory()
end
else
--audio.play( erroFucao )
\_G.podeFucao = 1
saveit.save()
transition.to( bordaFucao, { time = 1000, alpha = 0 } )
transition.to( bordaFucao2, { time = 1000, alpha = 0 } )
item1Fucao = nil
item2Fucao = nil
end
end
if item1Fucao ~= nil and item2Fucao ~= nil then
fucaoItens()
end
if \_G.podeFucao-0 == 1 then
clickCabecaMarreta = clickCabecaMarreta + 1
end
itemGrandeCabecaMarreta = function()
if clickCabecaMarreta \< 2 then
clickCabecaMarreta = 0
end
if clickCabecaMarreta \>= 2 then
clickCabecaMarreta = 0
\_G.itemGrande = 1
saveit.save()
cabecaMarretaGrande.alpha = 1
cabecaMarretaGrande:toFront()
end
end
if \_G.podeFucao-0 == 1 then
tCabecaMarreta = timer.performWithDelay( 500, itemGrandeCabecaMarreta, 1 )
end
end
end
displayImte2:addEventListener( "touch", clickCabecaMarretaInv )
end
elseif i == 1 and itemInSlot == 3 or i == 2 and itemInSlot == 3 or i == 3 and itemInSlot == 3 or i == 4 and itemInSlot == 3 or i == 4 and itemInSlot == 3 or i == 5 and itemInSlot == 3 then
imagem2 = items[3]
if \_G.celularNoInvCreate-0 == 0 then
\_G.celularNoInvCreate = 1
saveit.save()
displayImte3 = display.newImageRect( imagem2 .. ".png", 28, 58 )
displayImte3.xScale = 0.5
displayImte3.yScale = 0.5
displayImte3.alpha = 0
displayImte3.rotation = 25
displayImte3.x = 451
invGroup:insert( displayImte3 )
if i == 1 then
displayImte3.y = 30
elseif i == 2 then
displayImte3.y = 95
elseif i == 3 then
displayImte3.y = 160
elseif i == 4 then
displayImte3.y = 225
elseif i == 5 then
displayImte3.y = 290
end
transition.to( displayImte3, { delay = 300, time = 500, alpha = 1 } )
clickCelularInv = function(e)
if e.phase == "ended" then
itemSelecionado = items[3]
if \_G.podeFucao-0 == 0 then
if item1Fucao == nil and item2Fucao ~= items[3] then
item1Fucao = items[3]
elseif item2Fucao == nil and item1Fucao ~= items[3] then
item2Fucao = items[3]
end
end
if \_G.podeFucao-0 == 1 then
borda.x = 451
if i == 1 then
borda.y = 30
elseif i == 2 then
borda.y = 95
elseif i == 3 then
borda.y = 160
elseif i == 4 then
borda.y = 225
elseif i == 5 then
borda.y = 290
end
borda.alpha = 1
borda:toFront()
elseif \_G.podeFucao-0 == 0 and item1Fucao == items[3] then
if borda then
borda.alpha = 0
end
bordaFucao.x = 451
if i == 1 then
bordaFucao.y = 30
elseif i == 2 then
bordaFucao.y = 95
elseif i == 3 then
bordaFucao.y = 160
elseif i == 4 then
bordaFucao.y = 225
elseif i == 5 then
bordaFucao.y = 290
end
bordaFucao.alpha = 1
bordaFucao:toFront()
elseif \_G.podeFucao-0 == 0 and item2Fucao == items[3] then
if borda then
borda.alpha = 0
end
bordaFucao2.x = 451
if i == 1 then
bordaFucao2.y = 30
elseif i == 2 then
bordaFucao2.y = 95
elseif i == 3 then
bordaFucao2.y = 160
elseif i == 4 then
bordaFucao2.y = 225
elseif i == 5 then
bordaFucao2.y = 290
end
bordaFucao2.alpha = 1
bordaFucao2:toFront()
end
fucaoItens = function()
--audio.play( erroFucao )
\_G.podeFucao = 1
saveit.save()
transition.to( bordaFucao, { time = 1000, alpha = 0 } )
transition.to( bordaFucao2, { time = 1000, alpha = 0 } )
item1Fucao = nil
item2Fucao = nil
end
if item1Fucao ~= nil and item2Fucao ~= nil then
fucaoItens()
end
if \_G.podeFucao-0 == 1 then
clickCelular = clickCelular + 1
end
itemGrandeCelular = function()
if clickCelular \< 2 then
clickCelular = 0
end
if clickCelular \>= 2 then
clickCelular = 0
\_G.itemGrande = 1
saveit.save()
celularGrande.alpha = 1
celularGrande:toFront()
end
end
if \_G.podeFucao-0 == 1 then
tCelular = timer.performWithDelay( 500, itemGrandeCelular, 1 )
end
end
end
displayImte3:addEventListener( "touch", clickCelularInv )
end
elseif i == 1 and itemInSlot == 4 or i == 2 and itemInSlot == 4 or i == 3 and itemInSlot == 4 or i == 4 and itemInSlot == 4 or i == 4 and itemInSlot == 4 or i == 5 and itemInSlot == 4 then
imagem2 = items[4]
if \_G.marretaNoInvCreate-0 == 0 then
\_G.marretaNoInvCreate = 1
saveit.save()
itemFundido1 = display.newImageRect( imagem2 .. ".png", 28, 58 )
itemFundido1.xScale = 0.6
itemFundido1.yScale = 0.6
itemFundido1.alpha = 0
itemFundido1.rotation = 25
itemFundido1.x = 451
invGroup:insert( itemFundido1 )
if i == 1 then
itemFundido1.y = 30
elseif i == 2 then
itemFundido1.y = 95
elseif i == 3 then
itemFundido1.y = 160
elseif i == 4 then
itemFundido1.y = 225
elseif i == 5 then
itemFundido1.y = 290
end
transition.to( itemFundido1, { delay = 1000, time = 300, alpha = 1 } )
clickItemFundido1Inv = function(e)
if e.phase == "ended" then
itemSelecionado = items[4]
if \_G.podeFucao-0 == 0 then
if item1Fucao == nil and item2Fucao ~= items[4] then
item1Fucao = items[4]
elseif item2Fucao == nil and item1Fucao ~= items[4] then
item2Fucao = items[4]
end
end
if \_G.podeFucao-0 == 1 then
borda.x = 451
if i == 1 then
borda.y = 30
elseif i == 2 then
borda.y = 95
elseif i == 3 then
borda.y = 160
elseif i == 4 then
borda.y = 225
elseif i == 5 then
borda.y = 290
end
borda.alpha = 1
borda:toFront()
elseif \_G.podeFucao-0 == 0 and item1Fucao == items[4] then
if borda then
borda.alpha = 0
end
bordaFucao.x = 451
if i == 1 then
bordaFucao.y = 30
elseif i == 2 then
bordaFucao.y = 95
elseif i == 3 then
bordaFucao.y = 160
elseif i == 4 then
bordaFucao.y = 225
elseif i == 5 then
bordaFucao.y = 290
end
bordaFucao.alpha = 1
bordaFucao:toFront()
elseif \_G.podeFucao-0 == 0 and item2Fucao == items[4] then
if borda then
borda.alpha = 0
end
bordaFucao2.x = 451
if i == 1 then
bordaFucao2.y = 30
elseif i == 2 then
bordaFucao2.y = 95
elseif i == 3 then
bordaFucao2.y = 160
elseif i == 4 then
bordaFucao2.y = 225
elseif i == 5 then
bordaFucao2.y = 290
end
bordaFucao2.alpha = 1
bordaFucao2:toFront()
end
fucaoItens = function()
--audio.play( erroFucao )
\_G.podeFucao = 1
saveit.save()
transition.to( bordaFucao, { time = 1000, alpha = 0 } )
transition.to( bordaFucao2, { time = 1000, alpha = 0 } )
item1Fucao = nil
item2Fucao = nil
end
if item1Fucao ~= nil and item2Fucao ~= nil then
fucaoItens()
end
if \_G.podeFucao-0 == 1 then
clickMarreta = clickMarreta + 1
end
itemGrandeItemFundido1 = function()
if clickMarreta \< 2 then
clickMarreta = 0
end
if clickMarreta \>= 2 then
clickMarreta = 0
\_G.itemGrande = 1
saveit.save()
marretaGrande.alpha = 1
marretaGrande:toFront()
end
end
tItemFundido1 = timer.performWithDelay( 500, itemGrandeItemFundido1, 1 )
end
end
if \_G.podeFucao-0 == 1 then
itemFundido1:addEventListener( "touch", clickItemFundido1Inv )
end
end
elseif i == 1 and itemInSlot == 5 or i == 2 and itemInSlot == 5 or i == 3 and itemInSlot == 5 or i == 4 and itemInSlot == 5 or i == 4 and itemInSlot == 5 or i == 5 and itemInSlot == 5 then
imagem2 = items[5]
if \_G.chave1InvCreate-0 == 0 then
\_G.chave1InvCreate = 1
saveit.save()
displayImage5 = display.newImageRect( imagem2 .. ".png", 28, 18 )
displayImage5.xScale = 0.6
displayImage5.yScale = 0.6
displayImage5.alpha = 0
displayImage5.x = 451
invGroup:insert( displayImage5 )
if i == 1 then
displayImage5.y = 30
elseif i == 2 then
displayImage5.y = 95
elseif i == 3 then
displayImage5.y = 160
elseif i == 4 then
displayImage5.y = 225
elseif i == 5 then
displayImage5.y = 290
end
transition.to( displayImage5, { delay = 300, time = 500, alpha = 1 } )
clickChave1Inv = function(e)
if e.phase == "ended" then
itemSelecionado = items[5]
if \_G.podeFucao-0 == 0 then
if item1Fucao == nil and item2Fucao ~= items[5] then
item1Fucao = items[5]
elseif item2Fucao == nil and item1Fucao ~= items[5] then
item2Fucao = items[5]
end
end
if \_G.podeFucao-0 == 1 then
borda.x = 451
if i == 1 then
borda.y = 30
elseif i == 2 then
borda.y = 95
elseif i == 3 then
borda.y = 160
elseif i == 4 then
borda.y = 225
elseif i == 5 then
borda.y = 290
end
borda.alpha = 1
borda:toFront()
elseif \_G.podeFucao-0 == 0 and item1Fucao == items[5] then
if borda then
borda.alpha = 0
end
bordaFucao.x = 451
if i == 1 then
bordaFucao.y = 30
elseif i == 2 then
bordaFucao.y = 95
elseif i == 3 then
bordaFucao.y = 160
elseif i == 4 then
bordaFucao.y = 225
elseif i == 5 then
bordaFucao.y = 290
end
bordaFucao.alpha = 1
bordaFucao:toFront()
elseif \_G.podeFucao-0 == 0 and item2Fucao == items[5] then
if borda then
borda.alpha = 0
end
bordaFucao2.x = 451
if i == 1 then
bordaFucao2.y = 30
elseif i == 2 then
bordaFucao2.y = 95
elseif i == 3 then
bordaFucao2.y = 160
elseif i == 4 then
bordaFucao2.y = 225
elseif i == 5 then
bordaFucao2.y = 290
end
bordaFucao2.alpha = 1
bordaFucao2:toFront()
end
if \_G.podeFucao-0 == 1 then
clickChave1 = clickChave1 + 1
end
fucaoItens = function()
--audio.play( erroFucao )
\_G.podeFucao = 1
saveit.save()
transition.to( bordaFucao, { time = 1000, alpha = 0 } )
transition.to( bordaFucao2, { time = 1000, alpha = 0 } )
item1Fucao = nil
item2Fucao = nil
end
if item1Fucao ~= nil and item2Fucao ~= nil then
fucaoItens()
end
itemGrandeChave1 = function()
if clickChave1 \< 2 then
clickChave1 = 0
end
if clickChave1 \>= 2 then
clickChave1 = 0
chave1Grande.alpha = 1
chave1Grande:toFront()
end
end
if \_G.podeFucao-0 == 1 then
tChave1 = timer.performWithDelay( 500, itemGrandeChave1, 1 )
end
end
end
displayImage5:addEventListener( "touch", clickChave1Inv )
end
elseif i == 1 and itemInSlot == 6 or i == 2 and itemInSlot == 6 or i == 3 and itemInSlot == 6 or i == 4 and itemInSlot == 6 or i == 4 and itemInSlot == 6 or i == 5 and itemInSlot == 6 then
imagem2 = items[6]
if \_G.livroInvCreate-0 == 0 then
\_G.livroInvCreate = 1
saveit.save()
displayImage6 = display.newImageRect( imagem2 .. ".png", 48, 38 )
displayImage6.xScale = 0.6
displayImage6.yScale = 0.6
displayImage6.alpha = 0
displayImage6.x = 451
invGroup:insert( displayImage6 )
if i == 1 then
displayImage6.y = 30
elseif i == 2 then
displayImage6.y = 95
elseif i == 3 then
displayImage6.y = 160
elseif i == 4 then
displayImage6.y = 225
elseif i == 5 then
displayImage6.y = 290
end
transition.to( displayImage6, { delay = 300, time = 500, alpha = 0.7 } )
clickLivroInv = function(e)
if e.phase == "ended" then
itemSelecionado = items[6]
if \_G.podeFucao-0 == 0 then
if item1Fucao == nil and item2Fucao ~= items[6] then
item1Fucao = items[6]
elseif item2Fucao == nil and item1Fucao ~= items[6] then
item2Fucao = items[6]
end
end
if \_G.podeFucao-0 == 1 then
borda.x = 451
if i == 1 then
borda.y = 30
elseif i == 2 then
borda.y = 95
elseif i == 3 then
borda.y = 160
elseif i == 4 then
borda.y = 225
elseif i == 5 then
borda.y = 290
end
borda.alpha = 1
borda:toFront()
elseif \_G.podeFucao-0 == 0 and item1Fucao == items[6] then
if borda then
borda.alpha = 0
end
bordaFucao.x = 451
if i == 1 then
bordaFucao.y = 30
elseif i == 2 then
bordaFucao.y = 95
elseif i == 3 then
bordaFucao.y = 160
elseif i == 4 then
bordaFucao.y = 225
elseif i == 5 then
bordaFucao.y = 290
end
bordaFucao.alpha = 1
bordaFucao:toFront()
elseif \_G.podeFucao-0 == 0 and item2Fucao == items[6] then
if borda then
borda.alpha = 0
end
bordaFucao2.x = 451
if i == 1 then
bordaFucao2.y = 30
elseif i == 2 then
bordaFucao2.y = 95
elseif i == 3 then
bordaFucao2.y = 160
elseif i == 4 then
bordaFucao2.y = 225
elseif i == 5 then
bordaFucao2.y = 290
end
bordaFucao2.alpha = 1
bordaFucao2:toFront()
end
if \_G.podeFucao-0 == 1 then
clickLivro = clickLivro + 1
end
fucaoItens = function()
--audio.play( erroFucao )
\_G.podeFucao = 1
saveit.save()
transition.to( bordaFucao, { time = 1000, alpha = 0 } )
transition.to( bordaFucao2, { time = 1000, alpha = 0 } )
item1Fucao = nil
item2Fucao = nil
end
if item1Fucao ~= nil and item2Fucao ~= nil then
fucaoItens()
end
itemGrandeLivro = function()
if clickLivro \< 2 then
clickLivro = 0
end
if clickLivro \>= 2 then
clickLivro = 0
livroGrande.alpha = 1
livroGrande:toFront()
end
end
if \_G.podeFucao-0 == 1 then
tLivro = timer.performWithDelay( 500, itemGrandeLivro, 1 )
end
end
end
displayImage6:addEventListener( "touch", clickLivroInv )
end
elseif i == 1 and itemInSlot == 7 or i == 2 and itemInSlot == 7 or i == 3 and itemInSlot == 7 or i == 4 and itemInSlot == 7 or i == 4 and itemInSlot == 7 or i == 5 and itemInSlot == 7 then
imagem2 = items[7]
if \_G.coisaNoLivroInvCreate-0 == 0 then
\_G.coisaNoLivroInvCreate = 1
saveit.save()
displayImage7 = display.newImageRect( imagem2 .. ".png", 18, 36 )
displayImage7.xScale = 0.6
displayImage7.yScale = 0.6
displayImage7.alpha = 0
displayImage7.x = 451
invGroup:insert( displayImage7 )
if i == 1 then
displayImage7.y = 30
elseif i == 2 then
displayImage7.y = 95
elseif i == 3 then
displayImage7.y = 160
elseif i == 4 then
displayImage7.y = 225
elseif i == 5 then
displayImage7.y = 290
end
transition.to( displayImage7, { delay = 300, time = 500, alpha = 1 } )
clickCoisaDoLivroInv = function(e)
if e.phase == "ended" then
itemSelecionado = items[7]
if \_G.podeFucao-0 == 0 then
if item1Fucao == nil and item2Fucao ~= items[7] then
item1Fucao = items[7]
elseif item2Fucao == nil and item1Fucao ~= items[7] then
item2Fucao = items[7]
end
end
if \_G.podeFucao-0 == 1 then
borda.x = 451
if i == 1 then
borda.y = 30
elseif i == 2 then
borda.y = 95
elseif i == 3 then
borda.y = 160
elseif i == 4 then
borda.y = 225
elseif i == 5 then
borda.y = 290
end
borda.alpha = 1
borda:toFront()
elseif \_G.podeFucao-0 == 0 and item1Fucao == items[7] then
if borda then
borda.alpha = 0
end
bordaFucao.x = 451
if i == 1 then
bordaFucao.y = 30
elseif i == 2 then
bordaFucao.y = 95
elseif i == 3 then
bordaFucao.y = 160
elseif i == 4 then
bordaFucao.y = 225
elseif i == 5 then
bordaFucao.y = 290
end
bordaFucao.alpha = 1
bordaFucao:toFront()
elseif \_G.podeFucao-0 == 0 and item2Fucao == items[7] then
if borda then
borda.alpha = 0
end
bordaFucao2.x = 451
if i == 1 then
bordaFucao2.y = 30
elseif i == 2 then
bordaFucao2.y = 95
elseif i == 3 then
bordaFucao2.y = 160
elseif i == 4 then
bordaFucao2.y = 225
elseif i == 5 then
bordaFucao2.y = 290
end
bordaFucao2.alpha = 1
bordaFucao2:toFront()
end
if \_G.podeFucao-0 == 1 then
clickCoisaDoLivro = clickCoisaDoLivro + 1
end
fucaoItens = function()
--audio.play( erroFucao )
\_G.podeFucao = 1
saveit.save()
transition.to( bordaFucao, { time = 1000, alpha = 0 } )
transition.to( bordaFucao2, { time = 1000, alpha = 0 } )
item1Fucao = nil
item2Fucao = nil
end
if item1Fucao ~= nil and item2Fucao ~= nil then
fucaoItens()
end
itemGrandeCoisaDoLivro = function()
if clickCoisaDoLivro \< 2 then
clickCoisaDoLivro = 0
end
if clickCoisaDoLivro \>= 2 then
clickCoisaDoLivro = 0
coisaDoLivroGrande.alpha = 1
coisaDoLivroGrande:toFront()
end
end
if \_G.podeFucao-0 == 1 then
tCoisaDoLivro = timer.performWithDelay( 500, itemGrandeCoisaDoLivro, 1 )
end
end
end
displayImage7:addEventListener( "touch", clickCoisaDoLivroInv )
end
elseif i == 1 and itemInSlot == 8 or i == 2 and itemInSlot == 8 or i == 3 and itemInSlot == 8 or i == 4 and itemInSlot == 8 or i == 4 and itemInSlot == 8 or i == 5 and itemInSlot == 8 then
imagem2 = items[8]
if \_G.lanternaInvCreate-0 == 0 then
\_G.lanternaInvCreate = 1
saveit.save()
displayImage8 = display.newImageRect( imagem2 .. ".png", 20, 38 )
displayImage8.xScale = 0.6
displayImage8.yScale = 0.6
displayImage8.alpha = 0
displayImage8.x = 451
invGroup:insert( displayImage8 )
if i == 1 then
displayImage8.y = 30
elseif i == 2 then
displayImage8.y = 95
elseif i == 3 then
displayImage8.y = 160
elseif i == 4 then
displayImage8.y = 225
elseif i == 5 then
displayImage8.y = 290
end
transition.to( displayImage8, { delay = 300, time = 500, alpha = 1 } )
clickLanternaInv = function(e)
if e.phase == "ended" then
itemSelecionado = items[8]
if \_G.podeFucao-0 == 0 then
if item1Fucao == nil and item2Fucao ~= items[8] then
item1Fucao = items[8]
elseif item2Fucao == nil and item1Fucao ~= items[8] then
item2Fucao = items[8]
end
end
if \_G.podeFucao-0 == 1 then
borda.x = 451
if i == 1 then
borda.y = 30
elseif i == 2 then
borda.y = 95
elseif i == 3 then
borda.y = 160
elseif i == 4 then
borda.y = 225
elseif i == 5 then
borda.y = 290
end
borda.alpha = 1
borda:toFront()
elseif \_G.podeFucao-0 == 0 and item1Fucao == items[8] then
if borda then
borda.alpha = 0
end
bordaFucao.x = 451
if i == 1 then
bordaFucao.y = 30
elseif i == 2 then
bordaFucao.y = 95
elseif i == 3 then
bordaFucao.y = 160
elseif i == 4 then
bordaFucao.y = 225
elseif i == 5 then
bordaFucao.y = 290
end
bordaFucao.alpha = 1
bordaFucao:toFront()
elseif \_G.podeFucao-0 == 0 and item2Fucao == items[8] then
if borda then
borda.alpha = 0
end
bordaFucao2.x = 451
if i == 1 then
bordaFucao2.y = 30
elseif i == 2 then
bordaFucao2.y = 95
elseif i == 3 then
bordaFucao2.y = 160
elseif i == 4 then
bordaFucao2.y = 225
elseif i == 5 then
bordaFucao2.y = 290
end
bordaFucao2.alpha = 1
bordaFucao2:toFront()
end
if \_G.podeFucao-0 == 1 then
clickLanterna = clickLanterna + 1
end
fucaoItens = function()
--audio.play( erroFucao )
\_G.podeFucao = 1
saveit.save()
transition.to( bordaFucao, { time = 1000, alpha = 0 } )
transition.to( bordaFucao2, { time = 1000, alpha = 0 } )
item1Fucao = nil
item2Fucao = nil
end
if item1Fucao ~= nil and item2Fucao ~= nil then
fucaoItens()
end
itemGrandeLanterna = function()
if clickLanterna \< 2 then
clickLanterna = 0
end
if clickLanterna \>= 2 then
clickLanterna = 0
lanternaGrande.alpha = 1
lanternaGrande:toFront()
end
end
if \_G.podeFucao-0 == 1 then
tLanterna = timer.performWithDelay( 500, itemGrandeLanterna, 1 )
end
end
end
displayImage8:addEventListener( "touch", clickLanternaInv )
end
elseif i == 1 and itemInSlot == 9 or i == 2 and itemInSlot == 9 or i == 3 and itemInSlot == 9 or i == 4 and itemInSlot == 9 or i == 4 and itemInSlot == 9 or i == 5 and itemInSlot == 9 then
imagem2 = items[9]
if \_G.pedecabraInvCreate-0 == 0 then
\_G.pedecabraInvCreate = 1
saveit.save()
displayImage9 = display.newImageRect( imagem2 .. ".png", 40, 48 )
displayImage9.xScale = 0.6
displayImage9.yScale = 0.6
displayImage9.alpha = 0
displayImage9.x = 451
invGroup:insert( displayImage9 )
if i == 1 then
displayImage9.y = 30
elseif i == 2 then
displayImage9.y = 95
elseif i == 3 then
displayImage9.y = 160
elseif i == 4 then
displayImage9.y = 225
elseif i == 5 then
displayImage9.y = 290
end
transition.to( displayImage9, { delay = 300, time = 500, alpha = 1 } )
clickPedecabraInv = function(e)
if e.phase == "ended" then
itemSelecionado = items[9]
if \_G.podeFucao-0 == 0 then
if item1Fucao == nil and item2Fucao ~= items[9] then
item1Fucao = items[9]
elseif item2Fucao == nil and item1Fucao ~= items[9] then
item2Fucao = items[9]
end
end
if \_G.podeFucao-0 == 1 then
borda.x = 451
if i == 1 then
borda.y = 30
elseif i == 2 then
borda.y = 95
elseif i == 3 then
borda.y = 160
elseif i == 4 then
borda.y = 225
elseif i == 5 then
borda.y = 290
end
borda.alpha = 1
borda:toFront()
elseif \_G.podeFucao-0 == 0 and item1Fucao == items[9] then
if borda then
borda.alpha = 0
end
bordaFucao.x = 451
if i == 1 then
bordaFucao.y = 30
elseif i == 2 then
bordaFucao.y = 95
elseif i == 3 then
bordaFucao.y = 160
elseif i == 4 then
bordaFucao.y = 225
elseif i == 5 then
bordaFucao.y = 290
end
bordaFucao.alpha = 1
bordaFucao:toFront()
elseif \_G.podeFucao-0 == 0 and item2Fucao == items[9] then
if borda then
borda.alpha = 0
end
bordaFucao2.x = 451
if i == 1 then
bordaFucao2.y = 30
elseif i == 2 then
bordaFucao2.y = 95
elseif i == 3 then
bordaFucao2.y = 160
elseif i == 4 then
bordaFucao2.y = 225
elseif i == 5 then
bordaFucao2.y = 290
end
bordaFucao2.alpha = 1
bordaFucao2:toFront()
end
if \_G.podeFucao-0 == 1 then
clickPedecabra = clickPedecabra + 1
end
fucaoItens = function()
--audio.play( erroFucao )
\_G.podeFucao = 1
saveit.save()
transition.to( bordaFucao, { time = 1000, alpha = 0 } )
transition.to( bordaFucao2, { time = 1000, alpha = 0 } )
item1Fucao = nil
item2Fucao = nil
end
if item1Fucao ~= nil and item2Fucao ~= nil then
fucaoItens()
end
itemGrandePedecabra = function()
if clickPedecabra \< 2 then
clickPedecabra = 0
end
if clickPedecabra \>= 2 then
clickPedecabra = 0
pedecabraGrande.alpha = 1
pedecabraGrande:toFront()
end
end
if \_G.podeFucao-0 == 1 then
tPedecabra = timer.performWithDelay( 500, itemGrandePedecabra, 1 )
end
end
end
displayImage9:addEventListener( "touch", clickPedecabraInv )
end
end -- mudar para elseif para add novos itens
--print(i,items[itemInSlot])
end
end
invGroup:toFront()
end
There’s alot of code that you will not use… like “fucaoItens”… maybe you will want to use my double click function that make a “zoom” of you item…for this works you need to put this:
-- Pau da Marreta
pauMarretaGrande = display.newImageRect( "pau\_grande.png", 480, 320 )
pauMarretaGrande.x = \_W/2
pauMarretaGrande.y = \_H/2
pauMarretaGrande.alpha = 0
outside of displayInventory
[import]uid: 23063 topic_id: 12352 reply_id: 50216[/import]