| Blockland Forums > Modification Help |
| exec all files? "exec("./*.cs");" |
| (1/2) > >> |
| tyler0:
Is it possible to does this? I want an easy way of exec-ing all my .cs files. |
| MegaScientifical:
--- Quote --- %file = findFirstFile("Add-Ons/Addon_name/*.cs"); while(strLen(%file) > 0) { exec(%file); %file = findNextFile("Add-Ons/Addon_name/*.cs"); } --- End quote --- I'm pretty sure there's a slightly shorter way, but this should work. |
| otto-san:
From my File I/O tutorial: --- Code: ---function loadClientAddons() { for(%i = findFirstFile("Add-Ons/*/client.cs"); %i !$= ""; %i = findNextFile("Add-Ons/*/client.cs")) { echo("Loading: "@strReplace(strReplace(%i, "/client.cs", ""), "Add-Ons/","")); exec(%i); } } function loadServerAddons() { for(%i = findFirstFile("Add-Ons/*/server.cs");%i!$="";%i=findNextFile("Add-Ons/*/server.cs")) { echo("Loading: "@strReplace(strReplace(%i, "/server.cs",""), "Add-Ons/", "")); exec(%i); } } --- End code --- |
| MegaScientifical:
--- Quote from: otto-san on June 07, 2011, 11:02:37 PM ---From my File I/O tutorial: -snip- --- End quote --- Ah, that's what I was thinking, but I didn't feel like opening the game to check what returns when there's no more files so I could get the check part. |
| tyler0:
--- Quote from: otto-san on June 07, 2011, 11:02:37 PM ---From my File I/O tutorial: --- Code: ---function loadClientAddons() { for(%i = findFirstFile("Add-Ons/*/client.cs"); %i !$= ""; %i = findNextFile("Add-Ons/*/client.cs")) { echo("Loading: "@strReplace(strReplace(%i, "/client.cs", ""), "Add-Ons/","")); exec(%i); } } function loadServerAddons() { for(%i = findFirstFile("Add-Ons/*/server.cs");%i!$="";%i=findNextFile("Add-Ons/*/server.cs")) { echo("Loading: "@strReplace(strReplace(%i, "/server.cs",""), "Add-Ons/", "")); exec(%i); } } --- End code --- --- End quote --- yea this could be helpful in the future. Thanks. --- Quote from: MegaScientifical on June 07, 2011, 10:14:59 PM ---I'm pretty sure there's a slightly shorter way, but this should work. --- End quote --- You gave me exactly what i needed. Thanks |
| Navigation |
| Message Index |
| Next page |