Space Scriptors Unite!

I referenced the sample scripts in Empty Epsilon and got about what I can get out of them.

Not to complicated, but I don’t think they really cover the full set of commands.

Here is quick ref I made from mucking about last night:


Note : This reference is on the scripting side, and would otherwise confuse players (because things are different on that side)


Going from there I nabbed the source code and will start poking around in the C++ code, already looks like I can harvest some good bits. Those playing at home, download the source from git and find shipTemplateBasedObject.cpp.

2 Likes

You’re right - the sample scripts (and included script_reference.html in the game files) don’t cover everything.

If you want to find more of the script interface in the source, all the available functions are preceded by “REGISTER_SCRIPT_CLASS_FUNCTION” in the c++ source files.
e.g. REGISTER_SCRIPT_CLASS_FUNCTION(SpaceShip, getWeaponStorage);

The “Find in files” function of notepad++ has been a lifesaver.

I recognize you have way more experience at this than me, so forgive me if I’m telling you stuff you already know! :slight_smile:

1 Like

We about on the same page, digging in the files is where I left off last night.

I started a spreadsheet to start getting all the tools in one place - Open to editing by request - Stay tuned

Another tool you might like for the rooting-around-for-strings game is an app called Agent Ransack - I highly recommend.

And then they go and make it easy on us. The string @Dawsmart references also links to the file compile_script_docs.py, which makes a html format text dump of in-line documentation. If anything, this is a good starting point.

Output file attached.

script_docs.zip (8.0 KB)

1 Like

Good Afternoon Ben,

This looks great! Thanks for putting this together. I am going to send you the script I have been working on once I get home this afternoon. It is a very simple mission, where the players must shut down three warp gates. Perhaps you will have some suggestions/thoughts.

1 Like

I saw your request for help on the forums. When we get enough good content amassed, I am totally open to talking about posting this stuff to the larger community.

Cause Sharing is Caring

:wink:

2 Likes

Oh totally! I’d absolutely like to contribute to the bigger project if we can.

I meant to send this last night, however here is the mission I have been working on so far:

scenerio_99_Holy War.lua

I did a review / edit pass of Nathan’s script - All in all its good stuff, I made a few edits.

Nathan’s feedback is public in case anyone is following along and can benefit from my tips or has their own.

I have not run the script with my updates, so no telling what I broke. Script is attached. A good tool for comparing changes is WinMerge (http://winmerge.org/?lang=en). Very handy.

Great work Nathan, lets make more!

scenario_99_Holy War_BenEdit.zip (4.2 KB)


  • I did some re-formatting
  • This is just my OCD kicking in and part of the review
  • Most coders I know find mixing of tabs and spaces distasteful
    • Lua doesn’t care so much; but thinking forward, Python hates that stuff
    • My personal preference is spaces instead of tabs with 2 for an indent
      • Not gospel, and this is the type of topic to start a slew of criticism on myself

  • Some of the AI ships have same spawn coordinates
    • This is not necessarily fatal, but depending on game engine could cause problems (collision systems for example)
    • I moved the duplicates 100u apart
      • This could have broken them going through your warp gates though if that was your intent
      • Easy fix would have them blind-move to the war gate coordinates
        • Bonus to staggering them out and making them move to the gates would be the player can observe the behavior

  • The game-loop function update(delta) has a duplicate and empty function at the end
  • The second could overwrite the first, fouling your game logic
  • I commented out the second function

  • The game loop has checks and comm messages as feedback when baddie space stations are blowed up (this is good)
    • There isn’t anything preventing repeating hits on the comm message
    • Since the game loop is running 60 times a second, the loop could be triggering a comm message every pass - this looping behavior could cause overflows and instability
    • I added some simple logic to not check anymore when blowed up happens
      • On blowed up, no more checking and no more comms

  • In the game loop, the if-checks have returns - These are most likely benign and should not affect anything
    • I took them out though, to keep excess at bay
1 Like

This is excellent, thank you so much for taking a look at this! Also any improvements are very much welcome, especially with the checks made on the comms messages!

You were absolutely correct, I was having issues with duplicate messages being sent during play-testing. I will play-test your revision and check it out as well.

Most excellent.

The only comment I can add to checks right now, is to be mindful of the types of calculations being made to see if a condition happens.

  • A distance calculation (for example) takes some math and thus has a minor CPU cost. If a distance calculation is only to be made during a particular portion of the mission, you can use an integer or boolean to filter the checks down to only when needed
  • If [readyforthis] == false, then move on and don’t do all the other math
  • The tutorials use integers which is good form, their missions have a “phase 1”, “phase 2”, etc
    • They use “if phase == 2” to frame the kinds of calculations they make to that portion of the mission
  • The cost effectiveness per thing is probably minor, but in a larger scenario they add up - And its a good mental habit to get into

  • Boolean checks are cheap
  • Integer checks are cheap
  • String checks get a little more fancy and expensive
  • For spatial comparisons, a radius (distance) check is the cheapest

I am going to tinker around with some other stuff, tangentially related. When I can get some simple examples of timers and logging going, I will be most happy to share. Currently poking Fusion 360 with a stick to play with the models (and it may about time for me to break off my educational relationship with Maya).

Sometime in the near future we can meet and talk at a high level about what you want this mission to do. Then I can give you better advice. :slight_smile:

Very nice, I was trying to understand why they had the mission phases, now that makes a lot more sense! I tested your improved script during my lunch break and it seemed to work very well!

I am getting close to having a grip on modelling for Empty Epsilon.

In poking around with Fusion 360, I bumped into the much more affordable Maya LT. Only downside for me so far is the lack of .stl support, but that is more of a 3D printing thing (and fixable in my slicer).

Empty Epsilon deals in .obj files, and I can load and view them from the game source files.

1 Like

Yeah, buddy! Keep it goin!

Test model is mostly successful. I don’t think the game engine supports alpha (feh).

This is what it should look like…

Update Edit : Reply back from the developers, alpha (transparency) is not supported at this time. Alpha support would require depth sorting to the render engine, which is its own barrel of monkeys.

@Nathaniel_Roberts mentioned how he would like a timer mechanic in a mission that he is working on. I dug into it and here be the skinny.

Normally in Lua there is access to the command os.clock(), which returns the number of seconds the script has been running. As this is a derivative of Lua running in the Empty Epsilon game engine, things are a little different. Similar idea though.

Here is an example of how it works.


Inside of the init() function, we need to set up the basis for a clock by assigning a variable:
currentTime = 0

I am also going to define two variables for my timer:

timer1Total = 30
timer1Active = true

Only currentTime is required this early on. The timer settings can be defined later in the script, or there can be multiple timers, etc.


The game-loop function update(delta) has the parameter “delta”, which is defined by the deeper game engine. This delta is the time difference since the last pass of the game loop (30, maybe 60 times a second). This makes delta a very useful piece of information.

At the top of the game loop, you want to update the currentTime variable:
currentTime = currentTime + delta
Now you can use currentTime as a global game timer (in seconds since mission began).


I want an event to happen 30 seconds into the mission start. My timer logic looks like this:

if timer1Active and (currentTime > timer1Total) then
  timer1Active = false
  -- <<DO STUFF HERE>>
end

by using timer1Active and setting it to false on trigger, means that the events won’t trigger every loop past the 30 seconds mark (causing mayhem).

You can define a timer within update(delta), based on a previous event. This is probably the wiser approach since when the mission actually starts people aren’t fully logged in / set up / etc. These would be the types of commands you use here:

timer2Complete = currentTime + 30
timer2Active = true

then later on for the if-check:

if timer2Active and (currentTime > timer2Complete) then
  timer2Active = false
  -- <<DO MORE STUFF HERE>>
end

Hope this helps, enjoy!

1 Like

Good Evening Benjamin,

You have no idea how useful this is. I cant wait to give it a try!

Best Regards,

1 Like

Ok here is a successful timed trigger event.

– Establish current time
currentTime = currentTime + delta

-- Setup Timer 1
if not timer1Setup then
	timer1Total = currentTime + 15
	timer1Active = true
	timer1Setup = true
end

-- Trigger timed effect
if timer1Active and (currentTime > timer1Total) then
	timer1Active = false
	Space_Station = SpaceStation():setTemplate("Huge Station"):setFaction("Independent"):setCallSign("DS10"):setPosition(2938, -1645)
end
2 Likes

Before running the timed event, you will need to initiate your timer setup in the Init function:

timer1Setup = false

2 Likes