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 


An example for the index: + and -

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Aylin
Master Cheater
Reputation: 5

Joined: 16 Feb 2017
Posts: 279

PostPosted: Sun Jan 27, 2019 2:57 pm    Post subject: An example for the index: + and - Reply with quote

I'm moving a picture step by step.
and a loop occurred.
But coming to the place I want will cause the code to multiply.
Can I get a sample with index + and index?
Thanks in advance.

Code:
index = 1 --Left=1
index = index + 1 --++Left=150
index = 1 --Left=150
index = index - 1 Left=1


Code:
function CETimer1Timer(sender)
if UDF1.CEImage1.Left==1 then
control_setVisible(UDF1.CEImage1, true)
UDF1.CEImage1.Left=8
  elseif UDF1.CEImage1.Left==8 then
UDF1.CEImage1.Left=16
 elseif UDF1.CEImage1.Left==16 then
UDF1.CEImage1.Left=24
 elseif UDF1.CEImage1.Left==24 then
UDF1.CEImage1.Left=32
 elseif UDF1.CEImage1.Left==32 then
UDF1.CEImage1.Left=40
 elseif UDF1.CEImage1.Left==40 then
UDF1.CEImage1.Left=48
 elseif UDF1.CEImage1.Left==48 then
UDF1.CEImage1.Left=56
 elseif UDF1.CEImage1.Left==56 then
UDF1.CEImage1.Left=64
 elseif UDF1.CEImage1.Left==64 then
UDF1.CEImage1.Left=1
end
end

_________________
Hi Hitler Make a Youtube Web for Trainer
https://forum.cheatengine.org/viewtopic.php?t=609146
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 MSN Messenger
FreeER
Grandmaster Cheater
Reputation: 36

Joined: 09 Aug 2013
Posts: 968

PostPosted: Sun Jan 27, 2019 4:43 pm    Post subject: Reply with quote

looks like you're just adding 8 until it's 64 so something like
Code:
if UDF1.CEImage1.Left == 1 then show it and stuff
elseif UDF1.CEImage1.Left < 64 then UDF1.CEImage1.Left = UDF1.CEImage1.Left + 8
else UDF1.CEImage1.Left = 1 end

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
Aylin
Master Cheater
Reputation: 5

Joined: 16 Feb 2017
Posts: 279

PostPosted: Sun Jan 27, 2019 6:53 pm    Post subject: Reply with quote

FreeER wrote:
looks like you're just adding 8 until it's 64 so something like
Code:
if UDF1.CEImage1.Left == 1 then show it and stuff
elseif UDF1.CEImage1.Left < 64 then UDF1.CEImage1.Left = UDF1.CEImage1.Left + 8
else UDF1.CEImage1.Left = 1 end



Code:
if UDF1.CEImage1.Left == 1 then show


After "show", it gives an error.

the following code is progressing, but it does not return.

Code:
function CETimer1Timer(sender)
if UDF1.CEImage1.Left==1 then
UDF1.CEImage1.Left = UDF1.CEImage1.Left + 4
elseif UDF1.CEImage1.Left < 150 then
UDF1.CEImage1.Left = UDF1.CEImage1.Left + 4
elseif UDF1.CEImage1.Left==150 then
UDF1.CEImage1.Left = UDF1.CEImage1.Left - 4
elseif UDF1.CEImage1.Left < 1 then
UDF1.CEImage1.Left = UDF1.CEImage1.Left - 4
end
end


Also, thanks for your reply.

_________________
Hi Hitler Make a Youtube Web for Trainer
https://forum.cheatengine.org/viewtopic.php?t=609146
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 MSN Messenger
Aylin
Master Cheater
Reputation: 5

Joined: 16 Feb 2017
Posts: 279

PostPosted: Mon Jan 28, 2019 6:46 am    Post subject: Reply with quote

An example with long codes .CT
@freeER, it was compiled with the codes you gave.

https://www.dosyaupload.com/epXD

Is there a way back and forth?

Left + 2

Left - 2

_________________
Hi Hitler Make a Youtube Web for Trainer
https://forum.cheatengine.org/viewtopic.php?t=609146
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 MSN Messenger
FreeER
Grandmaster Cheater
Reputation: 36

Joined: 09 Aug 2013
Posts: 968

PostPosted: Mon Jan 28, 2019 5:00 pm    Post subject: Reply with quote

If you want to change directions the easiest way is to store the "speed" in a variable eg.

Code:
speed = 2 -- initial setup

-- change dir when reaching limits by negating speed
if pos < left_limit or pos > right_limit then speed = -speed end
-- move
pos = pos + speed

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater
Reputation: 23

Joined: 10 Apr 2015
Posts: 760

PostPosted: Tue Jan 29, 2019 3:52 am    Post subject: This post has 1 review(s) Reply with quote

@FreeER : something like this ?

Code:
f = createForm()
f.Height = 300
f.Width = 300
f.BorderStyle = 'Single'
f.Cursor = -21

img = createImage(f)
img.Top = 10
img.Left = -100
img.Height = 300
img.Width = 300
img.Stretch = true
img.Picture.loadFromStream(findTableFile('horses.png').Stream)
img.Visible = true

Speed = 1
Direction = ''
ImageExpandLeft = 250
ImageBaseLeft = -100

function ImagePop()
 if Direction == 'out' then
  if img.left >= ImageExpandLeft then
     Timer.Enabled = false
  else
     img.left = img.Left + Speed
  end
 else  --- Direction == 'in'
  if img.left <= ImageBaseLeft then
     Timer.Enabled = false
  else
     img.Left = img.Left - Speed
  end
 end
end

function img2right()
 Direction = 'out'
 Timer.Enabled = true
end

function  img2left()
 Direction = 'in'
 Timer.Enabled = true
end

Timer = createTimer(f)  -- create in Form
Timer.Interval = 40  --- 1/1000 second
Timer.Enabled = false
Timer.OnTimer = ImagePop

f.Show()

img.onMouseEnter =  img2right
img.onClick =  img2left


For who want to try :
- Add a picture file to your ct table as a stream file. And change 'horses.png' with your picture filename.

_________________
Singapore Sling + Johnnie Walker + Some Peanuts....
Back to top
View user's profile Send private message
Aylin
Master Cheater
Reputation: 5

Joined: 16 Feb 2017
Posts: 279

PostPosted: Tue Jan 29, 2019 10:09 am    Post subject: Reply with quote

Thanks @Corroder done
You understood me. I needed a sample. Thanks.
I'm going to use this on the Trainer.
And in the video of use: I will specify the code owner.
Thanks again.

final with a small addition. Smile

Code:
Timer1 = createTimer(f)
Timer1.Interval = 5000
Timer1.Enabled = true
Timer1.OnTimer = Imgplay


img.Left = -200

if img.Left==-200 then
 Direction = 'out'
 Timer.Enabled = true end

function Imgplay()
Timer.Enabled = false
if Direction=='out' then
 Direction = 'in'
 Timer.Enabled = true
 else
Direction = 'out'
Timer.Enabled = true
end
end

f.Show()

_________________
Hi Hitler Make a Youtube Web for Trainer
https://forum.cheatengine.org/viewtopic.php?t=609146
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 MSN Messenger
Corroder
Grandmaster Cheater
Reputation: 23

Joined: 10 Apr 2015
Posts: 760

PostPosted: Tue Jan 29, 2019 10:16 am    Post subject: Reply with quote

Never mind @Aylin, try to grow it up... good luck Very Happy
_________________
Singapore Sling + Johnnie Walker + Some Peanuts....
Back to top
View user's profile Send private message
Aylin
Master Cheater
Reputation: 5

Joined: 16 Feb 2017
Posts: 279

PostPosted: Tue Jan 29, 2019 1:13 pm    Post subject: Reply with quote

Corroder wrote:
Never mind @Aylin, try to grow it up... good luck Very Happy


Wouldn't the adults have fun? Very Happy
After all: we will not save the world by cheating.
Entertainment should go on. Wink

_________________
Hi Hitler Make a Youtube Web for Trainer
https://forum.cheatengine.org/viewtopic.php?t=609146
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 MSN Messenger
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