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 


Script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
robbinraa
How do I cheat?
Reputation: 0

Joined: 02 Dec 2018
Posts: 6

PostPosted: Sun Dec 02, 2018 5:49 am    Post subject: Script Reply with quote

Hello!
I need your help to write the mini-script.
I have an address 0019D2ED with byte type.
I need to decrease value by 2 when I press hotkey ` (lefter from 1 key).
I did it all and it works fine, but I need to add rule.
If value == 255 or value <= 2 then my hotkey do nothing with it (to let it pass new cycle from 255 to 2)
Otherwise game crashes if hotkey is pressed between 254 and 2.
Got the idea?
Thanks for your help!
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Dec 02, 2018 9:24 am    Post subject: Reply with quote

val = readBytes(0x19d2ed, 1)
if val == 255 or val <= 2 then return end
otherwise decrease val and write it back to memory

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
robbinraa
How do I cheat?
Reputation: 0

Joined: 02 Dec 2018
Posts: 6

PostPosted: Sun Dec 02, 2018 10:15 am    Post subject: Reply with quote

Thanks for your feedback but I have 0 exp in doing this.
Can you give me complete code? Thanks in advance.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Sun Dec 02, 2018 4:15 pm    Post subject: Reply with quote

Quote:
I did it all and it works fine, but I need to add rule.

just add the "rule" I gave to the code you already did.

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
robbinraa
How do I cheat?
Reputation: 0

Joined: 02 Dec 2018
Posts: 6

PostPosted: Sun Dec 02, 2018 5:18 pm    Post subject: Reply with quote

FreeER wrote:
Quote:
I did it all and it works fine, but I need to add rule.

just add the "rule" I gave to the code you already did.

But I have no code at all.
I just have table in my CE whith needed address and set hotkey for it to decrease the value when I press it.
Trying to execute just your string doesn't gives any result.

I am newbie in this theme at all.[img][/img]



&#1041;&#1077;&#1079; &#1085;&#1072;&#1079;&#1074;&#1072;&#1085;&#1080;&#1103;.jpeg
 Description:
 Filesize:  52.92 KB
 Viewed:  2594 Time(s)

&#1041;&#1077;&#1079; &#1085;&#1072;&#1079;&#1074;&#1072;&#1085;&#1080;&#1103;.jpeg


Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Dec 03, 2018 6:13 am    Post subject: Reply with quote

Ah, yeah, the GUI hotkey doesn't let you add conditions and afaik you can't have it run a lua script instead/before/after. you did post in lua scripting so I assumed you had done it in lua Smile

I just woke up but i think this would be correct.
Code:
local VK_BACK_QUOTE=192
createHotkey(function()
  print('hello')
  val = readBytes(0x19d2ed, 1)
  if val == 255 or val <= 2 then return end
  val = val - 2
  writeBytes(0x19d2ed, val)
end, VK_BACK_QUOTE)

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
robbinraa
How do I cheat?
Reputation: 0

Joined: 02 Dec 2018
Posts: 6

PostPosted: Mon Dec 03, 2018 4:11 pm    Post subject: Reply with quote

It works fine!
Thank you!
Can you help me with the option of restarting the lua script without closing CE?
When I change the line (for example to check if it works) "val = val - 2" to "val = val" and press Execute script - it still decreases the value.
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Mon Dec 03, 2018 5:36 pm    Post subject: Reply with quote

put it in an AA script with {$lua} at the top (so it parses lua code rather than assembly) and on enable do
some_global_hotkey_for_xxx = CreateHotkey ...

and on disable do some_global_hotkey_for_xxx.destroy()

you can move the local VK_BACK_QUOTE=192 in the function() or leave it outside or just replace VK_BACK_QUOTE with 192 and leave it out (good luck remembering what key 192 is though if you come back later and don't remember what you used lol)

_________________
https://github.com/FreeER/ has a few CE related repos
Back to top
View user's profile Send private message
robbinraa
How do I cheat?
Reputation: 0

Joined: 02 Dec 2018
Posts: 6

PostPosted: Mon Dec 03, 2018 5:37 pm    Post subject: Reply with quote

Did all my testing with closing / re opening CE Smile
I guess it will be my last question.
In CE hotkeys I could set MB 5 button (extra button on my mouse) but I can't find in google which is this button as VK_
Can you help with that too? Smile
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Tue Dec 04, 2018 12:51 am    Post subject: Reply with quote

easiest way is create a hotkey with just mb_5 , then copy the cheat entry and paste it into notepad.
then find the keycode in there

_________________
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
robbinraa
How do I cheat?
Reputation: 0

Joined: 02 Dec 2018
Posts: 6

PostPosted: Tue Dec 04, 2018 1:57 am    Post subject: Reply with quote

Dark Byte wrote:
easiest way is create a hotkey with just mb_5 , then copy the cheat entry and paste it into notepad.
then find the keycode in there

Did that you said and got that KEY is 6.
<Hotkeys>
<Hotkey>
<Action>Decrease Value</Action>
<Keys>
<Key>6</Key>
</Keys>
<Value>1</Value>
<ID>0</ID>
</Hotkey>
</Hotkeys>

local VK_MB_5=6 works fine
thanks Smile
Back to top
View user's profile Send private message
noobes
Advanced Cheater
Reputation: 0

Joined: 17 Dec 2018
Posts: 89

PostPosted: Fri Dec 28, 2018 12:42 pm    Post subject: Reply with quote

local VK_BACK_QUOTE=192
createHotkey(function()
print('hello')
val = readBytes(0x19d2ed, 1)
if val == 255 or val <= 2 then return end
val = val - 2
writeBytes(0x19d2ed, val)
end, VK_BACK_QUOTE)
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