View previous topic :: View next topic |
Author |
Message |
h3x1c Master Cheater Reputation: 17
Joined: 27 Apr 2013 Posts: 306
|
Posted: Thu Feb 05, 2015 10:59 pm Post subject: How can I create an empty file in a directory via Lua? |
|
|
Hey, everyone! I'm just now getting around to creating my own trainers, so I'm a Lua noob for the time being. =) I've tried a couple of things so far with what I'm looking to do, but to no avail. Here's the basic gist of what I'm trying to do:
I have a game that simply looks for a file in the same directory that the game's .exe is in. If it sees the file, it unlocks certain functionality. So, game.exe looks for unlock_file.patch in the same directory. Luckily, unlock_file.patch is just an empty file; only the file name is searched for.
What I want to add into my trainer is the ability for a user to click a button and it will create unlock_file.patch in the game's Steam directory. Again, I'm a complete noob so far, so this is what I've tried based on Google searching:
Code: | function CEButton1Click(sender)
file=io.open("C:\Program Files (x86)\Steam\SteamApps\common\Game\unlock_file.patch", "w")
file:close()
end |
This game is also able to be purchased elsewhere, so people may even have it in a completely different directory. With that in mind, perhaps I should have the user browse for the directory game.exe is in, which I imagine I can do via SelectDirectoryDialogue. Anyway, I know that creating this empty file is probably very simple, but I just can't quite get it nailed down. Any help would be very greatly appreciated. Thanks!
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25296 Location: The netherlands
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sun Feb 08, 2015 12:14 pm Post subject: |
|
|
Code: |
function CEButton1Click(sender)
dialog=createSaveDialog()
dialog.Filename='unlock_file'
dialog.DefaultExt=".patch"
dialog.Filter="Unlock File (*.patch)|*.patch"
dialog.FilterIndex=1
dialog.Options = '[ofEnableSizing]'
if dialog.execute() then
file=io.open(dialog.Filename, "w")
file:close()
end
end |
_________________
|
|
Back to top |
|
|
h3x1c Master Cheater Reputation: 17
Joined: 27 Apr 2013 Posts: 306
|
Posted: Mon Feb 23, 2015 9:14 pm Post subject: |
|
|
Thank you, Dark Byte and mgr.inz.Player! I'll give those suggestions a try here soon with my next trainer. I appreciate your help!
|
|
Back to top |
|
|
|