-
Notifications
You must be signed in to change notification settings - Fork 0
Setting up the environment
In this first tutorial we will cover how to setup your scripting environment. Here we will call our script tutorial, rename all mentions accordingly.
At the root of the server directory you need a scripts folder that will contain everything related to scripting.
In the scripts directory create a directory called tutorial and a file called tutorial.lua note that it is required that the directory and the lua file share the same name. You should now have the following structure :
/SkyrimTogetherServer.exe
/scripts/
/scripts/tutorial.lua
/scripts/tutorial/
The file tutorial.lua is the main file, it will be executed entirely on the server after loading the rest of the script, see it as you entry point. Paste the following code in tutorial.lua
print("Hello World !")If you launch SkyrimTogetherServer.exe or SkyrimTogetherServer on Linux you should see the following :
[20:17:59] [info] Loading mod tutorial.lua...
[20:17:59] [info] [script:tutorial] Hello World !
This means that your script is setup correctly and you can move on with the rest of the tutorial.
These are the most important part of the scripting system. Replicated objects exist on the client and the server and will give you the ability to synchronize data and to send messages between the client and the server.
The server will only load replicated object definition inside a special folder. In our case that folder will be /scripts/tutorial/net_objects/. Note that these objects will only be accessible by your scripts other scripts do not have access to your data.
Let's create a file called dummy.lua in /scripts/tutorial/net_objects/ containing the following code
OBJECT.Properties = {
Message = { Replicates = true, Default = "Hello World !" }
}And back to tutorial.lua add the following code
myFirstObject = dummy.new()Now you can start the server and the game and after connecting to your server you should see
