1. Check out the Store if you're looking to Buy HL2RP or other schemas for your server. You can click Buy Schemas on the very top navigation bar to visit the store.
  2. Use the Plugin Center to easily subscribe to and auto-install Clockwork plugins to your server, or submit and share plugins you have developed.
  3. Having trouble setting up or developing with Clockwork? Check out the Wiki or post in the Support Forum for advice from fellow users.
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 Clockwork Customer Active Member

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

Previous Readers (Total: 0)