1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

Check directory

Discussion in 'Development' started by Vortix, Jul 30, 2014.

  1. Vortix

    Vortix Moderator Staff Member Moderator Legend Clockwork Customer

    Is there a way to check if a directory exists? What I mean more specifically is if I were trying to make something run on the condition that the server has a specific plugin, is there a way to check if the server has this plugin/it's directory?
     
  2. duck

    duck Phant0m Legend

    You'd be better off using Clockwork.plugin:FindByID.
     
  3. Vortix

    Vortix Moderator Staff Member Moderator Legend Clockwork Customer

    Ah great, that's perfect thank you.

    EDIT: Is there a way I could go about changing one ENT: function of a plugin made entity using another plugin? What I'm wanting is that my Unit ID plugin which makes UID Cards that grant access to combine locks and doors could be used to open a Union Lock, however as this is by another author I cannot make it work directly with my plugin. Is this even possible?
     
  4. NightAngel

    NightAngel Fuck off Lev

    I'd think it's okay as long as you credit RJ for the original code.
     
  5. Vortix

    Vortix Moderator Staff Member Moderator Legend Clockwork Customer

    You're close, I could copy and paste the union lock code, as the lock determines the conditions for it to be opened, however I was hoping to find a way where I wouldn't have to do that. Not sure if it's possible.

    On the topic though, I actually need to be able to check directories now, as the idea of what I have is that if a .txt file with a certain name does not exist, then create a file, however if that txt does exist, I want to be able to rename it.
     
  6. duck

    duck Phant0m Legend

    Look into clockwork\framework\libraries\sv_file.lua
     
  7. Vortix

    Vortix Moderator Staff Member Moderator Legend Clockwork Customer

    Seems to be as simple as
    Code:
    file.Exists( string name, string path )
    Thanks.
     
  8. duck

    duck Phant0m Legend

    The Clockwork.file library is more extensive, as it allows you to write and delete outside of the data directory.

    With the normal file library, you are limited.
     
  9. Vortix

    Vortix Moderator Staff Member Moderator Legend Clockwork Customer

    Agreed. Unfortunately I've come up with another issue, using this command this time:
    Code:
    local ClockworkFileExists = file.Exists;
    function file.Exists(filePath, searchPath)
    	if (ClockworkFileExists(filePath, searchPath)) then
    		return true;
    	else
    		local files, folders = file.Find(filePath, searchPath);
    
    		if (#files > 0) then
    			return true;
    		end;
    	end;
    	
    	return false;
    end;
    The error I get is with the line
    Code:
    if (#files > 0) then
    It tells me: attempt to get length of local 'files' <a nil value>. What this makes me assume is that as the file does not exist it is sending an error at that rather than returning false. According to commenting this function was designed to fix the fact that file.Exists didn't work for lua. Any help?
     

Previous Readers (Total: 0)