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 


I have question. [Global Variables]

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Shahryar
Advanced Cheater
Reputation: 0

Joined: 11 Jun 2011
Posts: 85

PostPosted: Tue Apr 03, 2012 11:37 am    Post subject: I have question. [Global Variables] Reply with quote

Hello everyone.
I have question like always. Very Happy
How can I:
1. create or delete a folder with CE.
2. delete a file with CE.
3. use of global variables in CE. in AutoPlay Media Studio 8, we can use of the following variables:

_SystemFolder
The path to the user's Windows System folder (e.g. "C:\Windows\System" on non-NT systems, and "C:\Windows\System32" on NT based systems).

_TempFolder
The path to the user's Temp folder.

_WindowsFolder
The path to the user’s Windows folder (e.g. "C:\Windows").

_DesktopFolder
The path to the user's Desktop folder. On Windows NT/2000/XP/Vista or later, this is the path from the per-user profile.

_DesktopFolderCommon
The path to the user's Desktop folder. On Windows NT/2000/XP/Vista or later, this is the path from the All Users profile. On a non-Windows NT system, this will simply be the path to the user's Desktop folder (the same as _DesktopFolder).

_ProgramFilesFolder
The user's Program Files folder (typically, this is something like "C:\Program Files").

AutoPlay Media Studio 8 using of lua script. Is this variables available in CE?
Thanks for your advices. Wink
Back to top
View user's profile Send private message Send e-mail Visit poster's website
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Tue Apr 03, 2012 11:46 am    Post subject: Reply with quote

To delete a file, you can use 'os.remove'.
To create a file you can use 'io.open'.

As for the global variables those are exposed to Lua by the application itself. You wont have direct access to them with Cheat Engines Lua engine because it does not expose them itself.

You can access environment variables with 'os.getenv' though, such as:
Code:
local tempFolder = os.getenv( "temp" );
print( tempFolder );

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Shahryar
Advanced Cheater
Reputation: 0

Joined: 11 Jun 2011
Posts: 85

PostPosted: Tue Apr 03, 2012 11:56 am    Post subject: Reply with quote

Wiccaan:
Can you give me a sample of 'os.remove' and 'io.open'? I'll follow of your samples.
And How can I create or delete a folder? Thanks Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Tue Apr 03, 2012 12:22 pm    Post subject: Reply with quote

os.remove:
Code:
os.remove( "C:\\example_folder\\example_file.txt" )


io.open:
Code:
local f = io.open( "C:\\example_folder\\example_file.txt", "w" );
f:write( "Hello world!" );
f:close();


To delete a folder:
Code:
os.execute( [[ rd /s /q "C:\\example_folder" ]] );

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Shahryar
Advanced Cheater
Reputation: 0

Joined: 11 Jun 2011
Posts: 85

PostPosted: Tue Apr 03, 2012 12:31 pm    Post subject: Reply with quote

Thanks a lot Wiccaan. and one more question, How can I create a folder? Thanks. Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Tue Apr 03, 2012 12:54 pm    Post subject: Reply with quote

Code:
os.execute( [[ md "C:\\example_folder" ]] );

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Shahryar
Advanced Cheater
Reputation: 0

Joined: 11 Jun 2011
Posts: 85

PostPosted: Tue Apr 03, 2012 1:02 pm    Post subject: Reply with quote

sorry. I forgot. How can I find installed windows dir with CE? like 'C:\'
Back to top
View user's profile Send private message Send e-mail Visit poster's website
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Tue Apr 03, 2012 2:08 pm    Post subject: Reply with quote

Shahryar wrote:
sorry. I forgot. How can I find installed windows dir with CE? like 'C:\'


Like this:
Code:
local osDisk = os.getenv( "SystemDrive" );
print( osDisk );

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Shahryar
Advanced Cheater
Reputation: 0

Joined: 11 Jun 2011
Posts: 85

PostPosted: Tue Apr 03, 2012 7:59 pm    Post subject: Reply with quote

Hello again Wiccaan.
I have another question. How can I check a file by CE that exists or not?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Wed Apr 04, 2012 2:09 pm    Post subject: Reply with quote

You can test by trying to open the file like this:

Code:

function io.exist( fileName )
      local f = io.open( fileName );
      if ( f == nil ) then
         return false;
      end
      f:close();
      return true;
end

print( "C:\\example_folder\\example.txt status: " .. tostring( io.exist( "C:\\example_folder\\example.txt" ) ) );

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Shahryar
Advanced Cheater
Reputation: 0

Joined: 11 Jun 2011
Posts: 85

PostPosted: Mon Apr 09, 2012 8:01 am    Post subject: Reply with quote

Thanks a lot Wiccaan.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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