0

I am creating 8 images using Cheat Engine Lua script and I want to add some pictures to the images from an array table.

the_famous = {
{photo = "AlbertEinstein.jpg", nickName = "einstein", actorName = "Albert Einstein", profession = "Physicist", creation = "Theory of relativity", nationality = "Germany", life = "14 March 1879 - 18 April 1955"},
{photo = "Mozart.jpg", nickName = "mozart", actorName = "Wolfgang Amadeus Mozart", profession = "Classical Music Composer", creation = "Symphony No.40", nationality = "Austria", life = "27 January 1756 – 5 December 1791"},
{photo = "Guevara.jpg", nickName = "guevara", actorName = "Ernesto 'Che' Guevara", profession = "Revolutionary", creation = "Cuban Revolution", nationality = "Cuba, Argentina ", life = "14 June 1928 - 9 October 1967"},
{photo = "BruceLee.jpg", nickName = "bruce lee", actorName = "Bruce Lee (Lee Jun Fan)", profession = "Martial Artist", creation = "Father of MMA", nationality = "Hongkong, America", life = "27 November 1940 - 20 July 1973"},
{photo = "Marilyn.jpg", nickName = "marilyn monroe", actorName = "Marilyn Monroe (Norma Jeane Mortenson)", profession = "Artist", creation = "The most famous sex symbol", nationality = "America", life = "1 June 1926 -  5 August 1962"}}

    function start()
     if #the_famous ~= 0 then
     the_famous.ItemIndex = 0
     local idx = the_famous.ItemIndex
     for i = 1, 8 do
         local idx = tableTemp.ItemIndex
         local img = string.format('image1'..i)  -- images name start with 'image11' till 'image18'
         local pic = the_famous[i].photo

         img.Picture.loadFromFile(path_to_images_stored..tostring(pic))
         img.Hint = the_famous[i].nickname

         idx = idx + 1
     end
     end
    end

But the function above doesn't work. How I can do it properly?

JoeFern
  • 117
  • 1
  • 8

1 Answers1

0

Solved

I have change my script:

local cleft = 20
local ctop = 20

function getCategory(sender)

 local cat = sender.Name

 if cat == 'btnFamous' then
    while #tableTemp ~= 0 do rawset(tableTemp, #tableTemp, nil) end
    tableTemp = {}
    for z=1, #the_famous do tableTemp[z] = the_famous[z] end
 else
   return nil
 end

 for i = 1, 24 do
     local newImg = createImage(mPanel)
     newImg.width = 90
     newImg.height = 90
     newImg.top = ctop
     newImg.left = cleft
     newImg.Stretch = true
     newImg.Picture.loadFromFile(famous_img..tostring(tableTemp[i].photo))
     newImg.showHint = true
     newImg.Hint = tostring(tableTemp[i].nickName)
     newImg.Name = 'pic00'..i
     cleft = cleft + 100

     if i == 8 or i == 16 then
        cleft = 20
        ctop = ctop + 100
     end

   newImg.OnMouseEnter = function()
   hglight.visible=true
   hglight.setPosition(newImg.Left-10, newImg.Top-10)
   end

   newImg.OnMouseLeave = function()
   hglight.visible=false
   hglight.setPosition(newImg.Left-10, newImg.Top-10)
   end

 end
end

All works properly

JoeFern
  • 117
  • 1
  • 8