Author Topic: Axem's Script & Lua SEXP Collection  (Read 11214 times)

0 Members and 1 Guest are viewing this topic.

Offline Axem

  • 211
Axem's Script & Lua SEXP Collection
I've finally put together some of my scripts and lua sexp creations for public consumption, so everyone can share in the wonderment of near effortless use of lua scripts!

I've put them all on GitHub, so you can download them from there, report issues, or create PRs if you want to fix my bad scripting. I'm only going to post in this thread about new scripts that get added, smaller updates will just be committed without much comment.

The README has a basic overview of what each script does. The Lua SEXP documentation gets into a bit more detail. There are sample missions in some of the folders were applicable.

https://github.com/AxemP/AxemFS2Scripts

In progress right now are:
Collection of miscellaneous Lua SEXPs Released!
Item Drop script as seen in JAD
Infinite Ship spawning system as seen in JAD
Turret Control script that allows fine control of turrets (a lua-fire-turret sexp will be included!)
« Last Edit: April 05, 2020, 11:05:19 am by Axem »

 

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: Axem's Script & Lua SEXP Collection
Awesome to see these in one easy to get place! Great for folks who want to use them and who want to learn from them (like me).

 

Offline Novachen

  • 29
  • The one and only capella supernova
    • Twitter
Re: Axem's Script & Lua SEXP Collection
Well, i think, that it is possible, that i will report issues sometimes  :D
Female FreeSpace 2 pilot since 1999.
Former Global moderator in the German FreeSpace Galaxy Forum.
Developer of NTP - A Multi-Language Translation Library Interface, which allows to play FreeSpace in YOUR Language.

Is one of my releases broken or not working? Please send a PM here, on Discord at @novachen or on Twitter @NovachenFS2, a public tweet or write a reply in my own release threads here on HLP, because these are the only threads i am still participating in.

 
Re: Axem's Script & Lua SEXP Collection
Would it be possible to extend the scripting to other authors as well? Axem made a lot of fine scripts, but there are others too. Most scripting examples on the wiki are broken AFAIK, and the scripting release board is too chaotic to be sure to get the latest (or even only a working) version. To show what I mean, I made that Ships DB from all FS related community-made ships, not only those from Esarai or Nyctaeus.  Single source seems more useful than many tiny.

  

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
That is actually an interesting idea. An HLP Community FS Script github would be a good place that all scripts could be in one place and... hopefully in rather well enough maintained state. Anyone could become a contributor and add their scripts to it too.

The only concern I'd have is the really old scripts that no longer work because of API changes or were in pretty rough shape to begin with and only the original author knew how it worked exactly...

 

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
Just added a new script, an Extended Loading Screen script!

Quote
This script will allow the modder to more finely customize mission loading screens. Added features include customizeable loading bars, randomized loading images, ability to automatically draw the mission's title, and random text (for tips or lore, as well as associated images). Care must be taken with the placement of the loading bar, random text and images, since they will not scale with the game's resolution (however, the background does have the ability to scale). This script only overrides missions that are inside the loading screen table. (A nightly after July 23, 2018 is needed to use this script)

The best part about this script is you can now use loading screens of any resolution, and they'll look great!




This is also the first script to use the brand new tbl parser now available to lua scripting, no more needing to use JSON for the config files now!

 
Re: Axem's Script & Lua SEXP Collection
I have a feature request on behalf of the INF team, which also goes as bug report: Using the In-mission jump script for capital ships is... troublesome. The warp-in part and damage application is fine; but while jumping out the ship (a corvette) reaches only 3 m/s, and during the part where it is supposed to be in subspace it produces a clearly visible warp in the distance. Could you do something about it?

 

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
The in mission jump script is only meant for fighters, not capital ships. Cap ships should use the techniques that I have here in my tutorial about in mission jumps.

Why doesn't the script work with capital ships? Because the script solves a problem that's more unique to fighters. The methods to do it with a capital ship are quite simple without any scripts. You tell the ship to warp out, copy the damage to the new unarrived ship, and cue the new ship to arrive. It's 3 small things and we're done.

What do I need to do for my wingmen or the player? I can't tell any of them to depart. For the player the mission would end, and for the wingmen; the wingman gauge is now going to be incorrect. (And the comm menu isn't going to work right if I cue in some fake Alpha wingmen) So I need to fake the warp. This means telling all ships to play dead for a bit and cut to 1/3 throttle (thats why the corvette is going so slow), figuring out where to place warp portals, stash the ships somewhere far for transit time, then make a new warp portal, place the ships at the portals*, and restore the AI. The script automates all of that because I was super tired of doing that.

* Actually the scripting system has a :warpin() function that basically makes the ship redo its warp in effect which is why capital ships would redo that part correctly. But there's no simple way to make them "fake depart". I mean I coooould, but I think the way the game could do it now is good enough.
« Last Edit: June 09, 2019, 05:22:17 pm by Axem »

 
Re: Axem's Script & Lua SEXP Collection
Well my understanding of LUA is near 0, but I know how to help myself with SEXPs, so here's a part of the solution I was thinking of (I did this when I actually ran into the fighter issue, with comm menu and wingmates being depicted as departed by the HUD):

   ( set-object-position
      "Alpha 2#Replacement"
      ( get-object-x "Alpha 2" )
      ( get-object-y "Alpha 2" )
      ( get-object-z "Alpha 2" )
   )
   ( set-object-position
      "Alpha 3#Replacement"
      ( get-object-x "Alpha 3" )
      ( get-object-y "Alpha 3" )
      ( get-object-z "Alpha 3" )
   )
   ( set-object-orientation
      "Alpha 2#Replacement"
      ( get-object-pitch "Alpha 2" )
      ( get-object-bank "Alpha 2" )
      ( get-object-heading "Alpha 2" )
   )
   ( set-object-orientation
      "Alpha 3#Replacement"
      ( get-object-pitch "Alpha 3" )
      ( get-object-bank "Alpha 3" )
      ( get-object-heading "Alpha 3" )
   )
   ( set-object-position
      "Alpha 2"
      70000
      70000
      70000
   )
   ( set-object-position
      "Alpha 3"
      70000
      70000
      70000
   )
   ( add-goal
      "Alpha 2#Replacement"
      ( ai-warp-out 89 )
   )
   ( add-goal
      "Alpha 3#Replacement"
      ( ai-warp-out 89 )
   )
   ( friendly-stealth-invisible
      "Alpha 2"
      "Alpha 3"
   )
   ( ship-stealthy "Alpha 2" "Alpha 3" )

3 things remain that are not included in this:
-the ship that jumps out as decoy has to be created first (like ship create, which would take the place of set-object-position and set-object-orientation)
-the decoy needs to receive proper speed (i.e. taking over the values of the actual ship) - this could be done via ship-maneuver.
-the visible warp could simply be fixed by sending the ship 1000km away. That's not a problem EXCEPT for the player ship, which then self destructs in such cases.

Also, this script has the advantage that you can easily define the position and vector where a ship is supposed to re-arrive through waypoints, something that is elseway only possible through using an invisible blip, having it face away from the target, and than spetting the ship#2's arrival parameters to "in front of", what is mildly said not user-friendly.

The way it works for fighters is fine for me, though.

 
Re: Axem's Script & Lua SEXP Collection
It's not like I wouldn't value the script as it is. Think about the way "it's so useful, I want more of that ;7 ". :) Sure I have my own ideas about it - like that one could add a "proper" event as cue for the ships' re-arrival (like you can with normal ships) instead of a fixed delay and specify "no arrival warp" as flag, so you could set up an event like "Stage 2 Start", on which all ships from Stage 1 re-appear. Some directly at the beginnig without warp, some arrive a couple moments later with warp; while in the meantime all ships that weren't present in Stage 1 arrive due to having this Event as arrival condition.

But that's all out of my formal INF request, and just my thoughts of what I think what could be a useful feature - but perhabs somebody reads and does actually make it reality. Who knows. :)

 

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
What you mention would be handy but out of scope for what the script was designed for, which is a very simple intersystem jump script system that just automates the tedious sexps I got tired of writing. What you want to do might be possible with scripts right now... maybe (with ugly hacks or other ugly things), but I think anything advanced like that would be best served by being implemented in the game itself.

 
Re: Axem's Script & Lua SEXP Collection
Well it was an attempt. :)

BTW, when do you upload the rest of your scripts to GitHub? Searching this board for scripts is a waste of time aside this single thread, with most of the other things just being broken or chaotical spread over several pages.

 

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: Axem's Script & Lua SEXP Collection
There was been a bit of brainstorming in collecting all the modern scripts, like Axem's, the ship-save script, and custom wingmen/mission rols script (shameless plug). It would definitely be nice to have a one-stop shop for them.

 
Re: Axem's Script & Lua SEXP Collection
Yeah, that was the idea, but nothing came out of it so far.

 

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: Axem's Script & Lua SEXP Collection
Yeah, in talking with ngld he said a Knossos mod might be most useful, because then the modders wouldn't even have to worry about manually updating the scripts, their mods would just require the script mod.

 
Re: Axem's Script & Lua SEXP Collection
Interesting take on it. Possibly just add them to the MVPs?

 

Offline wookieejedi

  • 29
  • Intensify Forward Firepower
Re: Axem's Script & Lua SEXP Collection
Probably best to have them as their own separate mod, as the mvps are visual based. Also if the scripts were in their own mod then that would ensure a much smaller file size, so it would be far quicker to upload changes and new scripts, also for total conversions that use the scripts may not need the mvps (like Fate of the Galaxy).

I just posed this question on the discord so we can continue discussion there.

Sorry to Axem  for getting off topic on his thread!
« Last Edit: June 10, 2019, 05:07:27 pm by wookieejedi »

 
Re: Axem's Script & Lua SEXP Collection
2 bug reports I have for this script:
-1: the script adds AI-Play-Dead for all ships using it but does not remove it at the end, which condemns all non-player ships using it to a live in eternal smugness;
-2: fighters jumping in appear outside the warphole when the waypoints (used for arrival and orientation) are placed along the Y-axis (that's a problem that already exists in the original script).

 

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
Okay so 1, I see you fixed in your other thread. Would it be okay to take your fix (the other other few ones you had) there and apply it? :)

2, I can reproduce it and I've discovered the issue. It's a tricky one to fix. Basically there's some weird physics or momentum stuff going on. If you reduce the warpout speed factor to 0, the problem goes away. I will have to think of the best way to fix this without overcomplicating everything. :blah:

 
Re: Axem's Script & Lua SEXP Collection
Okay so 1, I see you fixed in your other thread. Would it be okay to take your fix (the other other few ones you had) there and apply it? :)

All I did was adding
Code: [Select]
mn.runSEXP("( clear-goals !" .. name .. "! )")
mn.runSEXP("( ship-lat-maneuver !" .. name .. "! 1000 0 0 " .. IMJump.Speed * 100 .. "( true ) )")

at the bottom of the script (below the last "scripted SEXP" column). The second one was there because the arriving ships (at least, the corvette I tested it on) also continued to move at 10 m/s due to another ship-lat-maneuver at the begining of the script, where the movement lasted for 60 seconds. The rest is related to my custom edit, which turned out to be a mess but atleast works the way I intended.

1 tiny thing in terms of nitpicking: I can target the arriving fighter while it's still cloaked (about 1/3 second before it is decloaked). I don't know but this ship-stealthy flag behaves weird. :doubt: