Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to make people move

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
eigocc
Newbie cheater
Reputation: 0

Joined: 22 Dec 2018
Posts: 15

PostPosted: Sat May 18, 2019 6:14 am    Post subject: How to make people move Reply with quote

Can't I set the position of the image in the image control? I want to know how to make people move, I don't know if the canvas can load the image.


1.png
 Description:
 Filesize:  10.9 KB
 Viewed:  1988 Time(s)

1.png


Back to top
View user's profile Send private message Send e-mail
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Sat May 18, 2019 6:19 am    Post subject: Reply with quote

you can load the image in a separate picture and then use canvas copyrect to change the image of the picture
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
eigocc
Newbie cheater
Reputation: 0

Joined: 22 Dec 2018
Posts: 15

PostPosted: Sat May 18, 2019 7:18 am    Post subject: Reply with quote

Can you give an example? I don't know much about it!
Back to top
View user's profile Send private message Send e-mail
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat May 18, 2019 10:48 am    Post subject: Reply with quote

If you don't want to use canvas, then following code is a sample I made in a primitive way to moving several png images like a sprite.

Code:
f = createForm()
f.setSize(500,250)

sonic = createImage(f)
sonic.setSize(60,60)
sonic.stretch = true
sonic.setPosition(10,70)

btn = createToggleBox(f)
btn.setSize(100,50)
btn.setPosition(10,180)
btn.caption = 'Start'

--------------------------------------------------------------
function hack1()
 if (checkbox_getState(btn) == 1) then
  t.enabled = true
  btn.caption = 'Stop'
 else
  t.enabled = false
  btn.caption = 'Start'
 end
end

t = {}
t[1] = 'frame_001.png'
t[2] = 'frame_002.png'
t[3] = 'frame_003.png'
t[4] = 'frame_004.png'

pics={}

for i=1,4 do  --- 4 is the total number of your pictures
  pics[i]=createPicture()
  pics[i].loadFromStream(findTableFile(t[i]).Stream)
end

pics.currentPicture=1

function t_tick()
 x,y = sonic.getPosition()
 x = x + 5 ------ delete this line if not want change position
 sonic.Picture=pics[pics.currentPicture]
 pics.currentPicture=(pics.currentPicture % 4)+1  -- carefull here
  if x >= f.width then
  t.enabled = false
  sonic.Picture.loadFromStream(findTableFile('frame_001.png').Stream)
  sonic.setPosition(10,50)
  btn.State = 0
  btn.caption = 'Start'
 else
  sonic.setPosition(x,y)
 end
end

t = createTimer()
t.interval = 100
t.enabled = false
t.onTimer = t_tick

function exit()
 closeCE()
 return caFree
end

f.show()
btn.onChange = hack1
f.onClose = exit



Download CT file (6 Kb) - copy paste URL link below to your web browser.

https://mega.nz/#!e5M0EYTB!MYPvjs05NeRsgkrHRqyzgs4PZXUiKW9a-_Dlmqfbq80

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Sat May 18, 2019 12:35 pm    Post subject: Reply with quote

The picture above is moving differently.
Here is a different Gif code from @Corroder and @FreeER.

Code:
----------------------------------------------- GIF
function createGIF(form, width, top, frames, doCenter)
    ---- ImageGIF Code Creator: FreeER.. Thanks .. and Thanks  Corroder ..
    -------------------------------------------------------
    local pics={}
    for _,frame in pairs(frames) do
      local pic
      if frame.ClassName == 'TMemoryStream' then
        pic = createPicture()
        pic.loadFromStream(frame)
      else -- first try to load as a tableFile then as a filepath
        local file = findTableFile(frame)
        if file then
          pic = createPicture()
          pic.loadFromStream(file.Stream)
        else
          local function file_exists(name)
             local f=io.open(name,"r")
             if f~=nil then io.close(f) return true else return false end
          end
          if file_exists(frame) then
            pic = createPicture()
            pic.loadFromFile(frame)
          end
        end
      end
      if pic then pics[#pics+1] = pic end
    end

    if #frames ~= 0 and #pics == 0 then return nil end

    pics.currentPicture = 1

    local mImage = createImage(form)
    mImage.width = '179'
    mImage.top = '22'
    mImage.height = '194'
    if doCenter then
      mImage.left = (form.width-mImage.width) / 2
    end

    local gif = {}
    gif.image = mImage
    gif.pics = pics
    gif.next = function()
      pics.currentPicture = (pics.currentPicture % #pics) + 1
      mImage.Picture = pics[pics.currentPicture]
    end

    gif.timer = createTimer(mImage)
    gif.timer.Interval = 800 / #gif.pics -- frames per second
    gif.timer.OnTimer = function(sender) gif.next() end
    return gif
end

local frameNameFormat = 'frame_%03d.png'
local t = {}
for i=1,13 do
  t[i] = findTableFile(frameNameFormat:format(i)).Stream
end
gif1 = createGIF(UDF1, UDF1.width, 10, t, true)
--[[
local t = {}
for i=8,9 do
  t[#t+1] = findTableFile(frameNameFormat:format(i)).Stream
end
gif2 = createGIF(UDF1, UDF1.width, 10, t, false)
]]
------------------------------------------------


And an example (.CT):

https://www.dosyaupload.com/auyM

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Sat May 18, 2019 1:12 pm    Post subject: This post has 1 review(s) Reply with quote

here's my example
Code:

int=getInternet()
img=int.getURL('https://forum.cheatengine.org/files/1_227.png')
ss=createStringStream(img)

offscreen=createPicture()
offscreen.loadFromStream(ss)

f=createForm()
f.borderstyle='bsSizeable'
img=createImage(f)
img.align='alClient'
img.stretch=true


f.show()

local imgwidth=offscreen.PNG.Width
local imgheight=offscreen.PNG.Height

local charwidth=imgwidth // 4
local charheight=imgheight // 4

img.Picture.Bitmap.Width=charwidth
img.Picture.Bitmap.Height=charheight

--print(string.format("charwidth=%d charheight=%x",charwidth,charheight))


local index=0

t=createTimer(nil)
t.Interval=250
t.OnTimer=function(tmr)
  --convert index to x,y coordinates
  local x=(index % 4)*charwidth
  local y=((index // 4) % 4)*charheight

  --print(string.format("x=%d y=%d",x,y))


  img.picture.Bitmap.Canvas.clear()


  img.picture.Bitmap.Canvas.copyRect(0,0,charwidth-1,charheight-1,offscreen.PNG.Canvas,x,y,x+charwidth,y+charheight)
  index=index+1
end
t.Enabled=true

f.OnDestroy=function(frm)
  t.destroy()
  f=nil
end



also in .Ct format with the image source as invisible on the form



example.CT
 Description:

Download
 Filename:  example.CT
 Filesize:  14.74 KB
 Downloaded:  264 Time(s)


_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
AylinCE
Grandmaster Cheater Supreme
Reputation: 30

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Sat May 18, 2019 3:29 pm    Post subject: Reply with quote

Now my brain has stopped! Very Happy
Your code: A complete picture, in squares
splits and reads.
That's magic! Smile
Excellent coding DB.
So awesome.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon May 20, 2019 9:23 pm    Post subject: Reply with quote

Another sample is here.

https://forum.cheatengine.org/viewtopic.php?p=5748936#5748936

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites