• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

Instance scripts? (1 Viewer)

Herly Quijano

Newcomer
Joined
Mar 19, 2021
Messages
70
Reaction score
7
I was working in CoreGames for a couple of months, and I'm curious about how it works, basically the scripts can be objects, also can be instanceable, all the same script with its variables and functions, just in different contexts, is like they work as "functions" instead of being the main code, is this only possible with Lua or is common with every programming language?, and is this normal? because I didn't worked with other games or programs.
 

stetre

Member
Rank: I
Joined
Jan 8, 2020
Messages
95
Reaction score
55
Location
Italy
Website
github.com
I'm not familiar with CoreGames but I can easily guess the presence of _ENV, here, and of a concurrency model. These are programming models where you have similar entities running concurrently, each in its dedicated context, and possibly with mechanism to synchronize and communicate with each other.

Is this only possible with Lua? No, of course: all common programming languages are Turing complete so they are equivalent in what you can do with them. The differences are in convenience, expressivity, performance, etc., but what you can do with one you can theoretically do with any other.

Is this normal? Well, yes. If you think about it, it's essentially what all multi-tasking operating systems do: they run several processes concurrently, each defined by an executable (the 'script'), and each in its own context. Similar concurrency models are also commonly implemented within applications, using facilities provided by most programming languages either via core constructs or via specific libraries. Threads, coroutines, etc, all fall in this category.

(As a matter of fact, I've developed a couple of libraries that could be used to implement such kinds of systems: MoonAgents, and MoonSC ).
 

stetre

Member
Rank: I
Joined
Jan 8, 2020
Messages
95
Reaction score
55
Location
Italy
Website
github.com
Concurrent programming is a very important topic, but also very interesting! You will surely encounter it often, since it comes up almost naturally in all sorts of situations. A related and partiallly overlapping topic is parallel programming, which is also very important (and interesting) and which you will also likely encounter often, if you don't have already.
 
Top