Run lua resources in the same environnement


It could be very nice to be able to keep _G in other resources.
For instance, on my server, everything is packed into a single resource. Being able to create “subresources” related to a “gamemode” resource could be very interesting. Current solution are what ESX does: an event to get the global ESX object or exports. It could make code much cleaner, facilitate contribution and probably better than copying all global variables from an environment.

Another example is EssentialMode. If you are using this “gamemode”, you need to use events/exports from another resource to grab data and use gamemode’s function. But being able to call a function/just being in the same environment directly is way faster than using event/exports and also cleaner you can play with OOD style. + restarting a resource actually kills one thing and not the entire gamemode

Not going to happen, not even “nice” or “interesting” at all and actually a complete pain to reason about/implement and complete fucking nonsense. Literally, all of your reasons make absolutely no sense and are definitely possible even with separate ScRTs.

like this - what? restarting a resource doesn’t “kill the entire game mode”, except if it’s a shared runtime it definitely would as you can’t selectively unload shit ._.

also lua isn’t the only language that exists so this idea of yours is even more dumbtarded

this is another nonsense reason, why do that in the first place even?

then profile for bottlenecks and optimize it to be fast enough?

no, no it definitely isn’t, it’d actually make the whole scripting runtime and resource system a complete mess when that’s one of the most well-architected systems of the game code

the fuck is “OOD style”? if you mean “OOP”, why would that not be possible now, or with the planned meta-refs system?

You already are.

Make a resource that contains a manifest with only “pichot_crappy_script ‘mew.lua’”. Listen for resource start/stop in another resource, and get metadata to see if it contains a “pichot crappy script”, and load() it as a chunk.

Look, you have subresources! So this feature request makes no sense as a request either as what you want already fucking exists with the exact same flaws (no inherent mission cleanup/GC of game objects, etc.) you would have if sharing a ScRT across multiple resources without internal marshaling.

The only request hidden in here is:

  • meta refs
  • runtime adding of resource metadata (e.g. file)
  • programmable mission cleanup scopes

all of which are already planned since ages but i keep forgetting about them

It is maybe not well explained.
I was basically trying to describe something that exists with garry’s mod scripting.

The idea is not to make ALL resources sharing the same environnement, but only those that need it. For example, if I’m making a casino script that require: inventory, money, player unique identifiers etc… Putting this script in gamemode_casino, this resource depends on gamemode and runs in the same environnement of gamemode, so you have access to all variables/functions. It is there easier than using exports/events, but it is also interesting because if you restart gamemode_casino, gamemode is not restarted and you keep all other variables/systems working properly.

I was thinking about it because I wanted to make a base gamemode, with basic features that could then evolve through other modules without requiring modifications of the gamemode.
Just look at it:
This is the “core” gamemode, but through other resources you can make modules that share the same environnement, which is in some way incorporated in the gamemode, not seperated

Don’t try to make this into another project’s design. That project does not even have multiple scripting languages nor a resource isolation system at all.

How? It’s literally the same amount of complexity for code.

And again how is that not possible with events/exports??? If you want to expose monkey patches, make an export to add a monkey patch. That’s again not “impossible” within the resource system…

… and the same goes for resources in CitizenFX however?! If you restart Y which depends on X, X is not restarted and works properly as well.

Are you confused with the complete lack of resilient modular design in ESX/vRP, perhaps?

vRP does this thru tunneling and proxying. You can easily call functions from another resources with proper tunneling. Makes things quick and easy.

My main concern was accessing to table and their functions

dependency ‘bleh’

not this again