View previous topic :: View next topic |
Author |
Message |
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Fri Apr 07, 2017 6:15 pm Post subject: Data table extraction and use |
|
|
I'm attempting to use the table names for use elsewhere in the code.
Code: | trainer = {
Data = {
GF = {
[0] = "name1";
[1] = "name2";
[2] = "name3";
[3] = "nam4";
[4] = "name5";
[5] = "name6";
[6] = "name7";
[7] = "name8";
[8] = "No One";
};
};
};
al = getAddressList()
for y = 0, 8 do
Name[y] = trainer.data.GF
print(Name[y])
end |
The forum is giving me error messages, so all the names have been changed to get by the forum message
Sorry, but because xxxx is an online game you are not allowed to talk about it. If you bought it fuck you for supporting this kind of game; the game is FF8
not xxxx.
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Fri Apr 07, 2017 6:27 pm Post subject: |
|
|
I'm sorry, but you don't explain what it is you're trying to accomplish.
The "D" in data needs to be capital: Code: | Name[y] = trainer.Data.GF |
You can now use the multidimensional array called "Name" to retrieve the same data as trainer.Data.GF.
|
|
Back to top |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sat Apr 08, 2017 12:02 pm Post subject: |
|
|
Now I feel dumber than usual, but thanks. you asked what was the purpose.
The post was to understand why the little debug code wasn't working, and you pointed that out to me. Ultimately, I am attempting to do something not done by me.
The table records have the following structure:
name1
name1 Description(s)
name1 Abilities Description..--XXX, with XXX representing numbers from 10-250 several to each name throughout the table.
The final coding will:
Identify the correct records i.e. which namex
Ignore any records that don't contain xxx as part of the string.
Change the desired records value to xxx-1
EDIT: And quickly re into another question
Code: | al = getAddressList()
for y = 0, 0 do
for x = 0, addresslist_getCount(al) -1 do
whichGF = trainer.Data.GF[y]
if string.find(whichGF, memoryrecord_getDescription(addresslist_getMemoryRecord(al,x))) then
print(x .. " " .. whichGF .. " " .. memoryrecord_getDescription(addresslist_getMemoryRecord(al,x)))
end
end
end |
Now in this case there are 18 records that begin with Name1, I copied them into each description to ensure. But the out put is only 9 records and worse
the print statement only prints the part of the string (the part matching the string.find)
Quote: | The basic use of string.find is to search for a pattern inside a given string, called the subject string. The function returns the position where it found the pattern or nil if it could not find it. The simplest form of a pattern is a word, which matches only a copy of itself. For instance, the pattern 'hello' will search for the substring "hello" inside the subject string. When find finds its pattern, it returns two values: the index where the match begins and the index where the match ends. |
I looked through the table an Name1 exists by itself 9 times, so why weren't the other records that contain more string characters than Name1 included?
|
|
Back to top |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Apr 08, 2017 9:32 pm Post subject: |
|
|
You have the string.find() backwards.
string.find(string_to_search_through, pattern_to_find)
Code: | al = getAddressList()
for y = 0, 0 do
for x = 0, al.Count - 1 do
local whichRec = al.MemoryRecord[x]
local whichGF = trainer.Data.GF[y]
if string.find(whichRec.Description, whichGF) then
print(x .. " " .. whichGF .. " " .. whichRec.Description)
end
end
end |
|
|
Back to top |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sat Apr 08, 2017 10:08 pm Post subject: |
|
|
Zanzer wrote: | You have the string.find() backwards.
string.find(string_to_search_through, pattern_to_find)
Code: | al = getAddressList()
for y = 0, 0 do
for x = 0, al.Count - 1 do
local whichRec = al.MemoryRecord[x]
local whichGF = trainer.Data.GF[y]
if string.find(whichRec.Description, whichGF) then
print(x .. " " .. whichGF .. " " .. whichRec.Description)
end
end
end |
|
You are correct, as usual, but I get an error
if string.find(whichRec.Description, whichGF) then--bad argument #1 to 'find' (string expected, got nil). Now that doesn't make sense, it should be nil for most of the records and bypass the print statement.
I tested printed whichRec and got the table addresses, then tested whichRec.Description and printed nils for all
|
|
Back to top |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sun Apr 09, 2017 2:44 pm Post subject: |
|
|
Thanks to you Zanzer, for your hints and guidance. Here is the code that performs the desired action. Probably not the best coding and I could not make the whichRec.Value to work. So in the old coding style using the data table referenced in the OP. Code: | al = getAddressList()
for y = 0, 11 do
for x = 0, addresslist_getCount(al) -1 do
whichGF = trainer.Data.GF[y]
whichRec = memoryrecord_getDescription(addresslist_getMemoryRecord(al,x))
if string.find(whichRec, whichGF) then
whichVal3 = string.sub(whichRec, -3)
whichVal2 = string.sub(whichRec, -2)
if tonumber(whichVal3) then
if tonumber(whichVal3) > tonumber(memoryrecord_getValue(addresslist_getMemoryRecord(al,x))) then
memoryrecord_setValue(addresslist_getMemoryRecord(al,x), tonumber(whichVal3)-1)
end--if tonumber(whichVal3) > tonumber(memoryrecord_getValue(addresslist_getMemoryRecord(al,x))) then
elseif tonumber(whichVal2) then
if tonumber(whichVal2) > tonumber(memoryrecord_getValue(addresslist_getMemoryRecord(al,x))) then
memoryrecord_setValue(addresslist_getMemoryRecord(al,x), tonumber(whichVal2)-1)
end--if tonumber(whichVal2) > tonumber(memoryrecord_getValue(addresslist_getMemoryRecord(al,x))) then
end--if tonumber(whichVal3) then
end--if string.find(memoryrecord_getDescription(addresslist_getMemoryRecord(al,x)), whichGF) then
end--for x = 0, addresslist_getCount(al) -1 do
end--for y = 0, 0 do |
The code takes a bit of time to complete, as there are 2275 records times 11 loops.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Sun Apr 09, 2017 3:42 pm Post subject: |
|
|
off-topic, but just to let other people know who stumble upon this topic
Code: |
tonumber(memoryrecord_getValue(addresslist_getMemoryRecord(al,x)))
|
can be rewritten to
Code: |
tonumber(al[x].Value)
|
_________________
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 |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sun Apr 09, 2017 3:55 pm Post subject: |
|
|
If you read through the whole table, why didn't whichRec.Value result in anything but a nil?
But thanks for the tip, I struggle with the new method of record accessing/changing. I never know when and what circumstances allow the .xxxx can be used. I normally get an error message about illegal object or an indexing error.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Sun Apr 09, 2017 4:14 pm Post subject: |
|
|
your code doesn't show the use of whichRec.Value so can't really say, but perhaps it didn't return nil, but tonumber did ? (or whichRec didn't get initialized at all, e.g a case wrong somewhere)
tonumber will return nil if it can't parse the value. (e.g '??')
(if you mean your current code:
Code: |
whichRec = memoryrecord_getDescription(addresslist_getMemoryRecord(al,x))
|
then whichRec.Value will of course not function(return nil), as a Description is just a string, no memory record )
_________________
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 |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sun Apr 09, 2017 4:25 pm Post subject: |
|
|
Look at the code Zanzer presented 4 or 5 pots earlier. I copied the exact code and that resulted in nil values, I didn't realize they were nils until I tried to combine in a print statement and got an error message concerning nil values.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Sun Apr 09, 2017 4:49 pm Post subject: |
|
|
I tried zanzer's code
Code: |
trainer = {
Data = {
GF = {
[0] = "name1";
[1] = "name2";
[2] = "name3";
[3] = "nam4";
[4] = "name5";
[5] = "name6";
[6] = "name7";
[7] = "name8";
[8] = "No One";
};
};
};
al = getAddressList()
for y = 0, 8 do
for x = 0, al.Count - 1 do
local whichRec = al.MemoryRecord[x]
local whichGF = trainer.Data.GF[y]
if string.find(whichRec.Description, whichGF) then
print(x .. " " .. whichGF .. " " .. whichRec.Description .. " "..whichRec.Value)
end
end
end
|
and added two entries named 'name1' and 'name2' and they do give proper results
and it prints the values correctly as well. Remember though that tonumber('??') will return nil
_________________
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 |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sun Apr 09, 2017 5:01 pm Post subject: |
|
|
Copied your code and probably his, resulting in a nil.
Line 22 was the if string.find
Description: |
|
Filesize: |
38.31 KB |
Viewed: |
15212 Time(s) |
|
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Sun Apr 09, 2017 5:13 pm Post subject: |
|
|
try
Code: |
al = getAddressList()
for y = 0, 8 do
for x = 0, al.Count - 1 do
local whichRec = al.MemoryRecord[x]
local whichGF = trainer.Data.GF[y]
if (whichRec~=nil) and (whichRec.Description~=nil) then
if string.find(whichRec.Description, whichGF) then
print(x .. " " .. whichGF .. " " .. whichRec.Description .. " "..whichRec.Value)
end
else
if whichRec==nil then
print("whichRec=nil")
else
local cn=whichRec.ClassName
if cn~=nil then
print("whichRec="..whichRec.ClassName)
else
print("whichRec is fucked")
end
return whichRec, getmetatable(whichRec)
end
end
end
end
|
_________________
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 |
|
|
bknight2602 Grandmaster Cheater Reputation: 0
Joined: 08 Oct 2012 Posts: 577
|
Posted: Sun Apr 09, 2017 5:19 pm Post subject: |
|
|
I got a lot of whichRec=TMemoryRecord, so many that the print routine couldn't keep up, but finally finished.
Description: |
|
Filesize: |
43.87 KB |
Viewed: |
15199 Time(s) |
|
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
Posted: Sun Apr 09, 2017 5:25 pm Post subject: |
|
|
what ce version do you use ?
Do you have code with createNativeThread running in your ce in the background ?
do you use special characters in your descriptions ?
_________________
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 |
|
|
|