| View previous topic :: View next topic |
| Author |
Message |
Ludwig Advanced Cheater
Reputation: 0
Joined: 10 Jan 2016 Posts: 68
|
Posted: Thu Mar 24, 2016 12:57 pm Post subject: Loading a function as a txt file from server |
|
|
hi guys...
This is what i got currently:
| Code: | function CreateTrainer()
local HackData = {};
function HackData:HacksData()
http = require("socket.http")
local m_hacks = http.request("http://myserver/hactable1.txt")
self.trainer.form.Caption = [[My Hacks]]
self.trainer.title.Caption = [[BattlePirates Hacks]]
self.hacktable = loadstring(m_hacks)()
|
which will load the whole hackatble that looks like:
| Code: | return {
{' hac1',[[ ]],[[Hack1 descr) ]],[[JUST A DESCRIPTION...NOT A ACTUAL HACK )]], 'false'},
{' hac2',[[ ]],[[Hack2 descr) ]],[[JUST A DESCRIPTION...NOT A ACTUAL HACK )]], 'false'},
} |
Now...what i want to do...
i got a Main_update function with subfunctions that i would also like to load in a similar manner as the hack table...:
| Code: | function Main_Update
function SuB1()
....
....
end
function SuB2()
....
....
end
function SuB3()
....
....
end
end |
How should i do to get
http = require("socket.http")
local m_hacks2 = http.request("http://myserver/hactable2.txt")
that would be all the sub functions into the Main_Update function from the txt file on server into m_hacks2
?
i tried something like this...:
| Code: | function database_Updt()
http = require("socket.http")
local http.request("http://myserver/hactable2.txt")
loadstring(m_hacks2)
end; |
but it doesnt seem to work...
i get an error:[string "function CreateTrainer()..."]:761: attempt to call a nil value"
my txt file on server side looks like:
| Code: | return {
function SuB1()
....
....
end
function SuB2()
....
....
end
function SuB3()
....
....
end
} | [/code]
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Thu Mar 24, 2016 3:35 pm Post subject: |
|
|
| Code: | local str = [[return {
SuB1 = function()
print("sub1")
end,
SuB2 = function()
print("sub2")
end,
SuB3 = function()
print("sub3")
end
}]]
local Main_Update = loadstring(str)()
Main_Update.SuB1() |
By the way, CE 6.5 has:
| Code: | local http = getInternet()
local response = http.getURL("www.google.com")
http.destroy() |
|
|
| Back to top |
|
 |
Ludwig Advanced Cheater
Reputation: 0
Joined: 10 Jan 2016 Posts: 68
|
Posted: Fri Mar 25, 2016 12:50 am Post subject: |
|
|
| Zanzer wrote: | | Code: | local str = [[return {
SuB1 = function()
print("sub1")
end,
SuB2 = function()
print("sub2")
end,
SuB3 = function()
print("sub3")
end
}]]
local Main_Update = loadstring(str)()
Main_Update.SuB1() |
By the way, CE 6.5 has:
| Code: | local http = getInternet()
local response = http.getURL("www.google.com")
http.destroy() |
|
thnx zanzer...got it last night from viewtopic.php?p=5602331...got mine fixed...just didnt get to posting yet...
i tried ce 6.5...got some bugs on some maths functions<think it was mod>...so i reverted back to 6.4...
|
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Mar 25, 2016 6:45 am Post subject: |
|
|
| Ludwig wrote: | | i tried ce 6.5...got some bugs on some maths functions<think it was mod>...so i reverted back to 6.4... |
Tell us which math function. There's always a possibility it can be fixed.
_________________
|
|
| Back to top |
|
 |
panraven Grandmaster Cheater
Reputation: 62
Joined: 01 Oct 2008 Posts: 959
|
Posted: Fri Mar 25, 2016 7:06 am Post subject: |
|
|
Likely the math.mod.
math.mod is deprecated in Lua 5.1 (ce 6.4) and remove in Lua 5.2 (so 5.3 and ce 6.5). It said the functionality is handled with math.fmod, should work the same if inputs are both integer . But the operator '%' will work as well.
For the favored function DEC_HEX2 , it can be replaced simply by string.format('%X',n).
They are not the same though, DEC_HEX2 does not handle negative number which may be a source of bug.
or with a bit more control on returned format:
| Code: | function Hex(n,withsign)
local fmt = string.format
if withsign then
return n<0 and fmt('-%02X',-n) or fmt('+%02X',n)
else
return fmt('%02X',n)
end
end
local xx = getAddress('cheatengine-x86_64.exe-----'..Hex(-9,true),true)
print(Hex(xx)) |
CE should properly handle the unary minus sign in address parsing.
_________________
- Retarded. |
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Fri Mar 25, 2016 7:20 am Post subject: |
|
|
@panraven, I'm using slightly different function:
| Code: | function tohexwithsign(a) return (a>=0 and '+' or '-')..string.format('%x',(a>0 and a or -a)) end
function tohex(a) return (a>=0 and '' or '-')..string.format('%x',(a>0 and a or -a)) end
|
_________________
|
|
| Back to top |
|
 |
panraven Grandmaster Cheater
Reputation: 62
Joined: 01 Oct 2008 Posts: 959
|
|
| Back to top |
|
 |
|