Jump to content

Why is Require considered unsafe?


Recommended Posts

Posted

I want to separate my script sources into a neatly packaged.. package so everything is easily readable.

When I use require "foo/bar.lua" I receive:

ERROR: server_main.lua:1: Unsafe function was called.

I'm just curious as to why I cannot use require for a server side script.

Posted

You can do the same with meta.xml. Require would let you load a file from an arbitrary path.

Posted
You can do the same with meta.xml. Require would let you load a file from an arbitrary path.

Wouldn't variable data be lost in the process, though? I mainly want to throw all of my variables / tables / arrays / what not in a secondary file and label it as an include.

Posted

You don't need to, global variables can be shared between script files in the same resource(but only on the same side: server-server and client-client)

Posted

Have a look how some of the standard resources are set up - many of them are split over a number of different files.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...