View previous topic :: View next topic |
Author |
Message |
tedomedo Advanced Cheater
Reputation: 0
Joined: 27 Jul 2008 Posts: 53
|
Posted: Fri Jul 14, 2017 12:28 pm Post subject: How to (select and) copy all values on the list? |
|
|
I saw that i can use lua script for selecting values but i don't know anything about this. Please, give me step-by-step instructions. I have CE 6.6.
Description: |
|
Filesize: |
11.06 KB |
Viewed: |
24589 Time(s) |

|
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 150
Joined: 06 Jul 2014 Posts: 4641
|
Posted: Fri Jul 14, 2017 1:00 pm Post subject: |
|
|
Code: | local al = getAddressList()
local vals = {}
for i=0, al.Count-1 do
vals[#vals+1] = al[i].Value
end
writeToClipboard(table.concat(vals,'\n')) |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
tedomedo Advanced Cheater
Reputation: 0
Joined: 27 Jul 2008 Posts: 53
|
Posted: Fri Jul 28, 2017 3:34 pm Post subject: |
|
|
Thanks for this.
Another wish about this: can values be copied automatically after any value's change?
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 150
Joined: 06 Jul 2014 Posts: 4641
|
Posted: Fri Jul 28, 2017 3:51 pm Post subject: |
|
|
If you still want it copied to the clipboard, you could put that code in a timer and have it run periodically.
Code: | t = createTimer()
t.Interval = 500
t.OnTimer = function(t)
-- code here
end |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
tedomedo Advanced Cheater
Reputation: 0
Joined: 27 Jul 2008 Posts: 53
|
Posted: Sat Jul 29, 2017 5:55 am Post subject: |
|
|
Thanks a lot. Now weird question: Is there a code to see sum of all values?
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 150
Joined: 06 Jul 2014 Posts: 4641
|
Posted: Sat Jul 29, 2017 9:29 am Post subject: |
|
|
Code: | local al = getAddressList()
local total = 0
for i=0, al.Count-1 do
total = total + (tonumber(al[i].Value) or 0)
end
print('total:',total) |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
tedomedo Advanced Cheater
Reputation: 0
Joined: 27 Jul 2008 Posts: 53
|
Posted: Sat Jul 29, 2017 5:13 pm Post subject: |
|
|
I bet i'm boring you, cause i have another noob question: how can i disable timer? I tried with interval 60000 but i can't copy something outside the game, when i paste, i get values from the game. I tried with timer_setEnabled(t, false) but i noob don't know where (between lines) should i place this command.
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 150
Joined: 06 Jul 2014 Posts: 4641
|
Posted: Sat Jul 29, 2017 5:36 pm Post subject: |
|
|
I don't know where you want to put it either. If you just want to execute it, paste it in the Lua engine window (Ctrl + Alt + Shift + L, or memory view -> tools -> Lua engine) and click on the "Execute" button.
Take note that if you execute the script that creates the timer more than once, you'll have multiple timers running in the background. If you don't want multiple timers, destroy the previous timer if it exists:
Code: | if t then t.destroy() end
t = createTimer()
... |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
tedomedo Advanced Cheater
Reputation: 0
Joined: 27 Jul 2008 Posts: 53
|
Posted: Sun Jul 30, 2017 3:06 am Post subject: |
|
|
I tried this:
Code: | if t then t.destroy() end
t = createTimer()
t.Interval = 1000
t.OnTimer = function(t)
local al = getAddressList()
local vals = {}
for i=0, al.Count-1 do
vals[#vals+1] = al[i].Value
end
writeToClipboard(table.concat(vals,'\n'))
end |
But i still can't copy and paste something else.
How can i destroy all timers in background and stop script instantly?
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 150
Joined: 06 Jul 2014 Posts: 4641
|
Posted: Sun Jul 30, 2017 8:39 am Post subject: |
|
|
Restart CE.
If you want a hotkey to enable / disable the timer, you can use this:
Code: | if hk then hk.destroy() end
hk = createHotkey(function() t.Enabled = not t.Enabled end, VK_CONTROL, VK_SHIFT, VK_C) |
Copy and paste this code after the timer code, and change the hotkeys to whatever you want (look in defines.lua in the main CE directory for VK_ keycodes).
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 221
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Tue Aug 01, 2017 10:28 am Post subject: |
|
|
@ParkourPenguin, do not forget to nil variables when destroying objects.
Code: | if hk then hk.destroy(); hk=nil end |
_________________
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 150
Joined: 06 Jul 2014 Posts: 4641
|
Posted: Tue Aug 01, 2017 10:47 am Post subject: |
|
|
A new userdata object is assigned just after the old one is destroyed. What more does assigning nil to the variable do?
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 221
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Wed Aug 02, 2017 7:20 am Post subject: |
|
|
It's a good habit to nil Lua variables which had lightuserdata or heavyuserdata, after calling destroy method.
Especially for global Lua variables.
_________________
|
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 150
Joined: 06 Jul 2014 Posts: 4641
|
Posted: Wed Aug 02, 2017 2:30 pm Post subject: |
|
|
It's as good of a habit as assigning null to deleted pointers. Unless something happens between the call to destroy and the assignment of the new userdata in my example, assigning nil seems to be little more than a formality.
I was more concerned with memory leak. If it's light userdata, it's not Lua's job to clean anything up, so assigning nil won't do anything. If it's full userdata, the reference count to the destroyed object is decremented when anything else is assigned to the variable- whether it's nil or new userdata doesn't matter. I can see several obvious problems if I didn't assign anything new to it, but assigning nil seems unnecessary in this case.
This isn't a significant and/or formal project- it's a short example script. As long as it doesn't fail in some way (e.g. memory leak), I don't mind ignoring formalities.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
rico3786 How do I cheat?
Reputation: 0
Joined: 10 Sep 2019 Posts: 1
|
Posted: Tue Sep 10, 2019 4:51 pm Post subject: Re: How to (select and) copy all values on the list? |
|
|
Code:
local al = getAddressList()
local vals = {}
for i=0, al.Count-1 do
vals[#vals+1] = al[i].Value
end
writeToClipboard(table.concat(vals,'\n'))
Hi guys, can i do this the opposite way? insert values from the top to the bottem from a txt, doc file or out of memory? Thank you!
|
|
Back to top |
|
 |
|