Screenplays

 

  Screenplay Reference Next (2)

 

This is my attempt to provide a basic tutorial for writing SWGEMU screenplays, whilst building a reference guide for available functions within the screenplays.

PLEASE NOTE THAT THIS IS ALL BEING WRITTEN FROM MY HEAD AND THAT NONE OF THE CODE HAS BEEN TESTED YET.  IT WILL BE, AND I WILL REMOVE THIS NOTICE WHEN IT HAS BEEN. 30-June-2019.

The basic screenplay guide will most likely have been taken from somebody else’s guidance, but the function references will be a new thing that I hope may others with contribute to.

Basic requirements for a screenplay:

  • optional : mobiles – custom NPC etc that appear in the screenplay.  Optional because generic ones can be used instead
  • conversations – the radial dialogues that occur with an NPC, terminal, basically any interaction with an object
  • screenplays – the script that interfaces with the code to store/read states, affect players and objects and make decisions

Locations :

Within the mobile/custom_contentconversations and screenplays/customer_content folders there are various files, objects.lua, serverobjects.lua and screenplays.lua.

To get started, let’s create the basic screenplay file for our test, within it’s own folder.  Create the folder myscreenplay under bin/scripts/screenplays/custom_content.

In this folder, create a shiny new file called myscreenplay.lua.

Enter some content, then save the file

 --reference the main object manager
local ObjectManager = require("managers.object.object_manager") 

myscreenplay = ScreenPlay:new {
  --declare local (read-only) variables that can be referenced by self.varname
  scriptName = "myscreenplay", 
  questString = "myscreenplay_convokey1" 
}

registerScreenPlay("myscreenplay", true)

function myscreenplay:start()
  print("My Screenplay has started " .. self.scriptName) 
end

Now edit the screenplays.lua file in the bin/scripts/screenplays/custom_content/myscreenplay folder and add 2 lines at the bottom. This ensures that your new screenplay file is included when the server starts.

-- testing
includeFile("custom_content/myscreenplay/myscreenplay.lua")

This is actually enough to run your first screenplay.
When the server starts, it will include your LUA file and run the myscreenplay:start() function, which will print the text My Screenplay has started myscreenplay to the console

 

  Screenplay Reference Next (2)