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 


Loaded code fails when activated.

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

Joined: 05 Sep 2020
Posts: 240

PostPosted: Sat Feb 27, 2021 4:08 pm    Post subject: Loaded code fails when activated. Reply with quote

Hello.
I have a sample code below.
It does not enable the line of code loaded from the remote server.
But it activates the line of code I have written by hand.
When I copied and pasted the remote server code line, it turned out to be like this;
Code:
 showMessage(   ello CEF   ) 


Is there any way to fix this?
Here is the code for you to try;

Code:
if formd1 then formd1.Destroy() end
formd1 = createForm()
formd1.Position=poDesktopCenter

local md1=createMemo(formd1)
md1.Width=formd1.Width md1.Height=formd1.Height - 35
md1.WordWrap=false md1.ScrollBars="ssAutoBoth"

local mdb1=createButton(formd1)
mdb1.Width=200 mdb1.Height=25 mdb1.Left=60 mdb1.Top=formd1.Height - 30
mdb1.caption="Execute Code"

function LoadCode1()
local http = getInternet()
local result = http.getURL("https://docs.google.com/document/d/1vL0INl0eD1MHcWHWeTlns04U8rAnotCtFEJKtgxW7q4/export?format=txt")--edit?usp=sharing")
if result then
md1.Lines.Text=result
end
end

LoadCode1()

mdb1.OnClick=function()
ss11=md1.Lines.Text
if ss11~="" then
aa11=load(ss11)
if aa11~=nil then
load(ss11)()
else
showMessage("Please write executable code")
end
else
showMessage("Please write a code in the box.")
end
end
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Sat Feb 27, 2021 9:35 pm    Post subject: This post has 1 review(s) Reply with quote

You need JSON lua to parsing the text from google docs.
In case google docs store plain text as RTF format.

https://gist.github.com/tylerneylon/59f4bcf316be525b30ab

That will work fine if use pastebin or others cloud storage.
example your code:

I changed:

Code:
...
result = http.getURL("https://pastebin.com/raw/9pzExSdc")
...


and

Code:
..
loadstring(ss11)()   --load(ss11)()
..

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
ByTransient
Expert Cheater
Reputation: 5

Joined: 05 Sep 2020
Posts: 240

PostPosted: Sat Feb 27, 2021 11:22 pm    Post subject: Reply with quote

This has been a bit complicated.
A different question; Is there any way to delete the first line of "result" or "memo"?
So; From the second line, printing "result" to "memo".

EDIT:
Yes I think I found the solution. Smile
I saw the error was in the first line.
Now I'll feed the first line (---) to delete it.

Code:
if formd1 then formd1.Destroy() end
formd1 = createForm()
formd1.Position=poDesktopCenter

local md1=createMemo(formd1)
md1.Width=formd1.Width md1.Height=formd1.Height - 35
md1.WordWrap=false md1.ScrollBars="ssAutoBoth"

local mdb1=createButton(formd1)
mdb1.Width=200 mdb1.Height=25 mdb1.Left=60 mdb1.Top=formd1.Height - 30
mdb1.caption="Execute Code"

function LoadCode1()
local http = getInternet()
local SL = createStringlist()
local result = http.getURL("https://docs.google.com/document/d/1vL0INl0eD1MHcWHWeTlns04U8rAnotCtFEJKtgxW7q4/export?format=txt")--edit?usp=sharing")
SL.text=result

if SL then
for x=1, strings_getCount(SL)-1 do
--print(SL[x])
md1.Lines.Add(SL[x])
end
end
SL.destroy();
end

LoadCode1()


mdb1.OnClick=function()
ss11=md1.Lines.Text
if ss11~="" then
aa11=loadstring(ss11)
if aa11~=nil then
loadstring(ss11)()
else
showMessage("Please write executable code")
end
else
showMessage("Please write a code in the box.")
end
end


Thanks for your time @Corroder.

NOTE: I am reviewing posts from you and @mgr.inz.Player.
I will continue to give +1 for every code that works for me. Smile (Y)
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