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!

Lua

Discussion in 'Programming' started by Maxyii, Aug 16, 2017.

  1. Maxyii

    Maxyii Clockwork Customer

    How to access variables on lua from a different directory?

    e.g:

    plugin
    stuff
    my_file.lua​
    morestuff
    the_file_i_want_to_access.lua

    How would I use a
    include("");
    to access "the_file_i_want_to_access.lua" from "my_file.lua"



    ????? help



     
  2. duck

    duck Phant0m Legend

    Create the variable as a global one. That is, don't put "local" before it. Then you will be able to access it just like any other variable.
     
  3. Maxyii

    Maxyii Clockwork Customer

    Okay I'll try that thank you.


    It's still printing the error in the console:
    Couldn't include file 'cl_data' (File not found) (@gamemodes/cwhl2rp/plugins/betterviewdata/plugin/entities/entities/cw_terminal/init.lua (line 7))

    any ideas?



    I want to access a lua file and varaible from:
    (@gamemodes/cwhl2rp/plugins/betterviewdata/plugin/entities/entities/cw_terminal/init.lua (line 7))
    here

    and the lua i'm running is in:
    (@gamemodes/cwhl2rp/plugins/betterviewdata/plugin/entities/entities/cw_terminal/init.lua (line 7))
    here
     
    Last edited: Aug 17, 2017
  4. vexus

    vexus ej rockwell's worst nightmare Staff Member Manager Legend Clockwork Customer

    Code:
    package.path = package.path ..";../../../../?.lua";
    require("file");
    
     

Previous Readers (Total: 0)