Jump to content
RealModScene
Plasma01

Help to make a .lua script

Recommended Posts

Hi!

I want to delete some files inside my hard disk by one click and a second later to move files from a USB device to a folder on my hard disk.
The goal of all this is to speed up a process that I do very often because it is necessary for me to develop mods of a game.

That is what i want:

                      Files.delete(FILE1inside HDD);
                      Files.delete(FILE2inside HDD);

wait 1second

                      Files.move(FILE1inside USB, to HDD Folder)
                      Files.move(FILE1inside USB, to HDD Folder)

Is that possible?

Thanks🙂

Share this post


Link to post
Share on other sites
1 hour ago, saywaking said:

Before mark the post as solved, how do I create it in lua and how do I run it?
sorry, I'm noob but this is the first script on the aurora dashboard, hope you will understand me 😃

Time ago i did that on Java, so how can i convert it in lua?

{
                  Path TOcestinoMAIN = Paths.get("Xbox360\\System\\Hdd1\\GTA San Andreas Biohazard\\data\\script\\main.scm");
                  Path TOcestinoSCRIPT = Paths.get("Xbox360\\System\\Hdd1\\GTA San Andreas Biohazard\\data\\script\\script.img"); 

                  Path TOmainDEL = Paths.get("Xbox360\\System\\Usb0\\main.scm");
                  Path TOscriptDEL = Paths.get("Xbox360\\System\\Usb0\\script.img"); 
                  //  |
                  //  V
                  Path CESTINOcartella = Paths.get("Xbox360\\System\\Hdd1\\GTA San Andreas Biohazard\\data\\script"); 

try {
                      Files.delete(TOcestinoMAIN);   
                      Files.delete(TOcestinoSCRIPT); 
//TimeUnit.SECONDS.sleep(1);
                      Files.move(TOmainDEL, CESTINOcartella.resolve(TOmainDEL.getFileName()));     
                      Files.move(TOscriptDEL, CESTINOcartella.resolve(TOscriptDEL.getFileName())); 

}
}

end

Thank you 🙂

Share this post


Link to post
Share on other sites

I was taught when I was doing C/C++ in college, that extra lines that can be removed should be removed, if removing them doesnt effect the end result. My point is that if you move a file over another file, it will overwrite the file, and no deletion is needed.

 

to make the process simple, try something along the lines of this(I have not tested this, as I am writing this code on the fly, and am not near my xbox.)

 

	scriptTitle = "Whatever you want to call it"
	scriptAuthor = "Your name here"
	scriptVersion = 1
	scriptDescription = "Describe your script here"
	scriptIcon = "icon.png";
	scriptPermissions = { "filesystem" }
	function main()
	local TOcestinoMAIN = "Xbox360\\System\\Hdd1\\GTA San Andreas Biohazard\\data\\script\\main.scm";
	local TOcestinoSCRIPT = "Xbox360\\System\\Hdd1\\GTA San Andreas Biohazard\\data\\script\\script.img";
	local TOmainDEL = "Xbox360\\System\\Usb0\\main.scm"
	local TOscriptDEL = "Xbox360\\System\\Usb0\\script.img"
	if FileSystem.FileExists(TOcestinoMAIN) then
	FileSystem.DeleteFile( TOcestinoMAIN );
	end
	if FileSystem.FileExists(TOcestinoSCRIPT) then
	FileSystem.DeleteFile( TOcestinoSCRIPT );
	end
	wait(1);
	if FileSystem.FileExists(TOmainDEL) then
	FileSystem.MoveFile(TOmainDEL .TOcestinoMAIN , 1 );
	end
	if FileSystem.FileExists(TOscriptDEL) then
	FileSystem.MoveFile(TOscriptDEL .TOcestinoSCRIPT  , 1 );
	end
	end
	

 

A little debugging, and maybe some tabbing for readablity(I dont think LUA is like python, where tab spacing matters, but it isnt a language I really use much) You could also cut down a decent amount of code, running the file exist if statements in a loop(maybe?) not sure there, as I cant test this, and dont really feel like doing the work for you. Most of this work was copy and paste, between the java you have above, and a the xbox unity github scripts. At the very least it is a starting point for you. The aurora debug app, is really helpful to debug scripts like this, and if you felt so inclined, I would suggest adding error checking for the file operations, and some sort of notifications, especially if you plan on releasing this as a script for others at some point. as it sits now, unless there is an issue with the code syntax, it wont show up in the log and it wont notify you if it succedes or fails. Wish you the best on this, and now I go back to the linux kernel code I have been working on for my nintendo switch. lol. I might have forgot a few semicolons at the end of some of the variable definitions. Easy enough to fix, but it wont let me change the code box now that it has been posted. Which is something I will look into later.

  • Thanks 1

Share this post


Link to post
Share on other sites
9 minutes ago, gavin_darkglider said:

I was taught when I was doing C/C++ in college, that extra lines that can be removed should be removed, if removing them doesnt effect the end result. My point is that if you move a file over another file, it will overwrite the file, and no deletion is needed.

 

to make the process simple, try something along the lines of this(I have not tested this, as I am writing this code on the fly, and am not near my xbox.)

 


	scriptTitle = "Whatever you want to call it"
	scriptAuthor = "Your name here"
	scriptVersion = 1
	scriptDescription = "Describe your script here"
	scriptIcon = "icon.png";
	scriptPermissions = { "filesystem" }
	function main()
	local TOcestinoMAIN = "Xbox360\\System\\Hdd1\\GTA San Andreas Biohazard\\data\\script\\main.scm";
	local TOcestinoSCRIPT = "Xbox360\\System\\Hdd1\\GTA San Andreas Biohazard\\data\\script\\script.img";
	local TOmainDEL = "Xbox360\\System\\Usb0\\main.scm"
	local TOscriptDEL = "Xbox360\\System\\Usb0\\script.img"
	if FileSystem.FileExists(TOcestinoMAIN) then
	FileSystem.DeleteFile( TOcestinoMAIN );
	end
	if FileSystem.FileExists(TOcestinoSCRIPT) then
	FileSystem.DeleteFile( TOcestinoSCRIPT );
	end
	wait(1);
	if FileSystem.FileExists(TOmainDEL) then
	FileSystem.MoveFile(TOmainDEL .TOcestinoMAIN , 1 );
	end
	if FileSystem.FileExists(TOscriptDEL) then
	FileSystem.MoveFile(TOscriptDEL .TOcestinoSCRIPT  , 1 );
	end
	end
	

 

A little debugging, and maybe some tabbing for readablity(I dont think LUA is like python, where tab spacing matters, but it isnt a language I really use much) You could also cut down a decent amount of code, running the file exist if statements in a loop(maybe?) not sure there, as I cant test this, and dont really feel like doing the work for you. Most of this work was copy and paste, between the java you have above, and a the xbox unity github scripts. At the very least it is a starting point for you. The aurora debug app, is really helpful to debug scripts like this, and if you felt so inclined, I would suggest adding error checking for the file operations, and some sort of notifications, especially if you plan on releasing this as a script for others at some point. as it sits now, unless there is an issue with the code syntax, it wont show up in the log and it wont notify you if it succedes or fails. Wish you the best on this, and now I go back to the linux kernel code I have been working on for my nintendo switch. lol. I might have forgot a few semicolons at the end of some of the variable definitions. Easy enough to fix, but it wont let me change the code box now that it has been posted. Which is something I will look into later.

Thank you so much, and yeah, I will not ask for more than I already did, because I understand it's my work :)
Very precise and synthetic, thank you!

Share this post


Link to post
Share on other sites

No problem man..... I am waiting on my compiler to finish..... 2 days and counting, and I think I probably have another 2 days easy, before it is done building what it is building, which puts my project at a stand still for now. That being said, I might be one of the only people that has a fully working kodi build for my nintendo switch. lol. Not really that impressive, but since I have to cross compile, or build stuff in an emulator, as I am building for the wrong archetecture to be able to take advantage of widevine(DRM library from google) it complicates the build a bit. lol. All that being said, it seems to work fairly well, as I can watch netflix, amazon prime, play emulators(as long as they dont require hardware acceleration(kodi retroplayer doesnt support this in mainline, though there has been some work there, that probably wont be merged until kodi 19, and kodi 18 is still in the RC phase.) lol. All that being said, it has been a fun project, and I think I might have found the answer to the USB problem in linux as well on the switch, but I am not going to go in to many details, until I can test the changes, and see if there are different results. I will say this though, after months of digging through code, I am fairly certain that when the XHCI driver was ported to Linux mainline, they changed the name of the power supply registers in the code, so the device map is not mapping power correctly for the tegra x10. That being said, I wont know for sure until I can test it, and it still wont be that helpful until I can either find a driver for the ROHM power delivery chip(Without no power to USB devices without dock), and also get the pericom USBC switch working properly(Needed to get docking station graphics to work.) The other big things in the dev process there is integrating Minerva TC into the kernel, and Switch Coreboot(Would be nice to have DRAM training), implementing Warmboot method, which is the key to getting sleep mode to work(Atmosphere and Hekate have code for this on github, but I am not exactly sure what is happening with it, as it is poorly documented, and I dont read memory addresses and patches.) lol. But if you can get coreboot to launch from the warmboot method in atmosphere, it should be possible to keep the signed lp0 code in ram, which should be the key to fixing that problem...... Wow that was more then I was planning on saying.

Share this post


Link to post
Share on other sites

Hi!

That is the last question :)

why is that line wrong? Probably beacuse of [function progressRoutine]... what should I put in it?

FileSystem.MoveFile( usbMAIN, xboxMAIN, 1, [function progressRoutine] );

Thanks 🙂

Share this post


Link to post
Share on other sites

anything that is in brackets like this [ ] in a function definition is optional. So, if you had a progress bar routine function, you could call it from here, and pass data to it to update the progress bar. It shouldnt be needed to copy/move a file. so try something more like this FileSystem.MoveFile( usbMAIN, xboxMAIN, 1);

Share this post


Link to post
Share on other sites

Hi again 😅

My mind is blowing up, have you idea why when I run the script from the xbox a error message popup "A script error has occured"

That is the code, is pretty clear, i don't understand what's the problem

	scriptTitle = "The Title"
	scriptAuthor = "Name"
	scriptVersion = 1
	scriptDescription = "Description"
	scriptIcon = "icon.png";
	scriptPermissions = { "filesystem" }

	function main()

	local xboxMAIN = "Hdd1:\\1GTA San Andreas Biohazard\\data\\script\\main.scm";
	local xboxSCRIPT = "Hdd1:\\1GTA San Andreas Biohazard\\data\\script\\script.img";
	local usbMAIN = "Usb0:\\main.scm"
	local usbSCRIPT = "Usb0:\\script.img"

	FileSystem.MoveFile( usbMAIN, xboxMAIN, 1 );
	FileSystem.MoveFile( usbSCRIPT, xboxSCRIPT, 1 );

	end

i did some tests, removing the overwriting boolean, using the FileSystem.CopyFile command, I also tried the folder instead of the file itself as the destination.

The FileSystem.Delete command works perfectly, also for USB, then the external disk (USB) is readable and writable...

Thank you again 😓

Share this post


Link to post
Share on other sites
18 minutes ago, Plasma01 said:

Hi again 😅

My mind is blowing up, have you idea why when I run the script from the xbox a error message popup "A script error has occured"

That is the code, is pretty clear, i don't understand what's the problem


	scriptTitle = "The Title"
	scriptAuthor = "Name"
	scriptVersion = 1
	scriptDescription = "Description"
	scriptIcon = "icon.png";
	scriptPermissions = { "filesystem" }

	function main()

	local xboxMAIN = "Hdd1:\\1GTA San Andreas Biohazard\\data\\script\\main.scm";
	local xboxSCRIPT = "Hdd1:\\1GTA San Andreas Biohazard\\data\\script\\script.img";
	local usbMAIN = "Usb0:\\main.scm"
	local usbSCRIPT = "Usb0:\\script.img"

	FileSystem.MoveFile( usbMAIN, xboxMAIN, 1 );
	FileSystem.MoveFile( usbSCRIPT, xboxSCRIPT, 1 );

	end

i did some tests, removing the overwriting boolean, using the FileSystem.CopyFile command, I also tried the folder instead of the file itself as the destination.

The FileSystem.Delete command works perfectly, also for USB, then the external disk (USB) is readable and writable...

Thank you again 😓

shouldn't it be single \ after everything else besides "Hdd1:\\"

ex. "Hdd1:\\1GTA San Andreas Biohazard\data\script\main.scm"

Share this post


Link to post
Share on other sites
10 minutes ago, felida said:

shouldn't it be single \ after everything else besides "Hdd1:\\"

ex. "Hdd1:\\1GTA San Andreas Biohazard\data\script\main.scm"

I just tried and it did not work.
Even I can not even start the script

Share this post


Link to post
Share on other sites
9 hours ago, Plasma01 said:

I just tried and it did not work.
Even I can not even start the script

Try doing it like this, there were a few missing simicolons, and I dont know about lua, but true might not equal 1, so we will just say true. I also added some formatting to make it prettier.

 

scriptTitle = "The Title"
scriptAuthor = "Name"
scriptVersion = 1
scriptDescription = "Description"
scriptIcon = "icon.png";
scriptPermissions = { "filesystem" }

function main()

	local xboxMAIN = "Hdd1:\\\\1GTA San Andreas Biohazard\\data\\script\\main.scm";
	local xboxSCRIPT = "Hdd1:\\\\1GTA San Andreas Biohazard\\data\\script\\script.img";
	local usbMAIN = "Usb0:\\\\main.scm";
	local usbSCRIPT = "Usb0:\\\\script.img";

	FileSystem.MoveFile( usbMAIN, xboxMAIN, true);
	FileSystem.MoveFile( usbSCRIPT, xboxSCRIPT, true );

end

 

Share this post


Link to post
Share on other sites
4 hours ago, felida said:

shouldn't it be single \ after everything else besides "Hdd1:\\"

ex. "Hdd1:\\1GTA San Andreas Biohazard\data\script\main.scm"

no, that will be needed for escaping/masking as it's Microsoft Filesystem with Backslashes "\"

Not sure, but maybe it should be something like "Hdd1:\\\\......\\...\\", because like said, it must be escaped, i never tried, do a test on that

as for the rest of the Code

also

  • use Debugger: https://www.realmodscene.com/index.php?/topic/7564-aurora-network-debugging/
  • check debug.log after crashes (there is one in the Aurora Directories)
  • maybe start with a "hello world" or just " bool FileSystem.FileExists(string path) with a print or a Message Box with the return Value, so you can see if the script works or the first path is really correct and working so you go step by step, instead of starting directly with file Operations.

PS: this thread should go to https://www.realmodscene.com/index.php?/forum/57-skin-development-and-lua-scripting/

It's not Aurora Support, tho.

I would write it down but i dont have my 360 currently, and too bad, we can't use the API on PC for Developing.

 

Share this post


Link to post
Share on other sites
4 hours ago, saywaking said:

no, that will be needed for escaping/masking as it's Microsoft Filesystem with Backslashes "\"

Not sure, but maybe it should be something like "Hdd1:\\\\......\\...\\", because like said, it must be escaped, i never tried, do a test on that

as for the rest of the Code

also

  • use Debugger: https://www.realmodscene.com/index.php?/topic/7564-aurora-network-debugging/
  • check debug.log after crashes (there is one in the Aurora Directories)
  • maybe start with a "hello world" or just " bool FileSystem.FileExists(string path) with a print or a Message Box with the return Value, so you can see if the script works or the first path is really correct and working so you go step by step, instead of starting directly with file Operations.

PS: this thread should go to https://www.realmodscene.com/index.php?/forum/57-skin-development-and-lua-scripting/

It's not Aurora Support, tho.

I would write it down but i dont have my 360 currently, and too bad, we can't use the API on PC for Developing.

 

I didnt even catch this thread was in the wrong section, that has been fixed. As for the escaping of the backslashes, after hdd1: and usb0: I totally missed as well. I didnt test any of the code I posted as an example as my xbox is in storage. lol. Been busy with my switch. lol.

Share this post


Link to post
Share on other sites

Hello, I want to make a script, where I can extract the games and the title ID, and that this is saved in a text file in the form of a list, but I don't know anything about programming, if you tell me where to start I would greatly appreciate it

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...