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

0 Members and 1 Guest are viewing this topic.

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
Dunno what's up with that early targeting. I can't reproduce it and the script says it should be unstealthed when its warping in. For a third of a second I don't think it's worth it too much to dive into since it doesn't look like anything super obvious.

So I've committed some new lua sexps as well as updates to a few other scripts.

New:
Misc Functions: A variety of misc lua sexps that can aid a FREDder to do some neat stuff. Like forcing a target for the player, getting the player's target, reversing waypoints and other fun stuff.
Scroll Write: Add cheesy one character at a time subtitle reveals, complete with sound effects!
Waypoint Assist: A system to help guide the player through waypoints with a pointer object. FREDder can keep track of which waypoint the player is at or if waypoints are completed.

Updated:
Cloak: Forcing the cloak now works properly
In Mission Jump: For the AI, play dead orders now cleared after jumping, the ship-maneuver lasts shorter, which in conjunction with a now 2 second minimum transit time, allows the AI ship to slow down to zero before jumping back in without any odd orientation errors when the ship is pointing up on the y-axis. The player is not bound by these restrictions. (I hope this solves your issues with fighters jumping, Nightmare!)
Loading Screen: Added a scale zoom option so backgrounds will be intelligently scaled for the resolution being used. Intelligently scaled means no stretching or skewed aspect ratio. Portions of the background may be clipped to fit.
Prompt Box: When using repeating events, stuff can get screwed up because the last answer to a reference is always kept. So 'lua-clear-prompt' was added to clear the reference can be cleared.

 
Re: Axem's Script & Lua SEXP Collection
Quote
In Mission Jump: For the AI, play dead orders now cleared after jumping, the ship-maneuver lasts shorter, which in conjunction with a now 2 second minimum transit time, allows the AI ship to slow down to zero before jumping back in without any odd orientation errors when the ship is pointing up on the y-axis. The player is not bound by these restrictions. (I hope this solves your issues with fighters jumping, Nightmare!)

That works now, thanks! :nod:
However... there are some things that work (different):
-most importantly, when I have a ship jumping out with the player following a couple seconds later into subspace, the game now throws out a debug warning:
Code: [Select]
LUA ERROR: [string "imjump-sct.tbm - On Game Init"]:81: attempt to index local 'entry' (a nil value)

------------------------------------------------------------------
ADE Debug:
------------------------------------------------------------------
------------------------------------------------------------------


------------------------------------------------------------------

stack traceback:
[C]: ?
[string "imjump-sct.tbm - On Game Init"]:81: in function 'Monitor'
[string "imjump-sct.tbm - On Frame"]:265: in main chunk
------------------------------------------------------------------

------------------------------------------------------------------

Aside the debug warning, it does not seem to have any other negative side effects. I compared it with the old script; the error only occurs with the new version. To make sure it isn't the result of some other broken script in my mod I tested it with WoD - it worked fine with the original, but again errors with the new one.

-Probably a minor thing: since the player won't move anymore inside of the subspace tunnel, the warp just forms in front of the player without moving towards it.
-Just an idea: maybe run the set-motion-debris-override SEXP when the player is inside the tunnel?


Regarding the Scroll Write script: it's a super neat thing, but could you add some documentation (and a sample) for showing the fiction files with lua-scroll-write-file? In my cluelessness I tried to feed it with the next best fiction file I had and it crashed immediatly... :(

 

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
Kay, I think I fixed the issues.

Not sure why that entry is nil error started popping up. It might have to do with how the player and AIs now will be forced to do things a little differently. I just did a simple check to see if the entry is valid or not. 99% of the time that solves the issue, but if it looks like something weird is happening let me know. I also made the player continue on the ship-maneuver thing for longer so you should hit the warp portal.

The scroll write file thing I also fixed (and added an example mission and fiction file). There is no special syntax or format. Just any text file will work. I hadn't actually tested it recently. I wrote the script over a year ago and it worked then, but since then the file handling with lua has gotten stricter and the script did not keep up. My bad on that one. :blah: (I did test it so it's all good now!)

 
Re: Axem's Script & Lua SEXP Collection
Beautiful work you did there! :) :yes:

 

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
Posted some updates, bug fixes for some, and some new stuff.

There's a "GetClosest' script which will find you the closest ship from a given team from a given origin. That ship is put into a sexp string variable. Use that for mines or something.

Misc-functions got an update with some stuff that BtA was using. If you want a quick way to make stuff untargetable or lock keys for cutscenes, check that out. There's also some other misc BtA scripts that I just added a LuaSEXP passthrough basically.

I also made a new version of the turret hotkey script. It's pretty much a straight rewrite of the one that MadProf made in 2011. There are now better ways to call it and better hooks to make things reliable. But it's still very low key. tcrayford's Critical Subsystem Script is much more flashy and neato so really, use that one. :cool:

The next big script I'm slowly working on is an update to the save-load script. I never used it because it seemed like a giant pain, and I preferred to be softer with checkpoints, not really wanting to doom the player to 4% hull left after a checkpoint if they are that unlucky. Then mjn showed me what his missions look like with it and I was like "there must be a better way".

The plan for the script is you call "lua-save-state" and it saves everything. You call "lua-load-state" and it loads the saved data to what it can that is present. Ships that aren't present will get their data preloaded where possible, so all the FREDder will need to do is make sure they arrive and everything is taken care of. There will be some flags and options if you just want to load only position, orientation and whatnot.

 

Offline Bryan See

  • Has anyone really been far as decided to use even go want to do look more like?
  • 210
  • Trying to redeem, but under Tiger Parents
    • Skype
    • Steam
    • Twitter
Re: Axem's Script & Lua SEXP Collection
Axem, I've got a new problem. When I test most of your scripts with the latest MediaVPs (4.X), it seems that the createParticle index/field from mv_exp-sct.tbm is a non-existent and nil value.

Code: [Select]
Could not find index 'createParticle' in type 'Testing'

------------------------------------------------------------------
ADE Debug:
------------------------------------------------------------------
------------------------------------------------------------------


------------------------------------------------------------------

stack traceback:
[C]: ?
[string "mv_exp-sct.tbm - On Mission Start"]:849: in function 'do_small_explosion_effects'
[string "mv_exp-sct.tbm - On Mission Start"]:880: in function 'maybe_draw_explosion_effects'
[string "mv_exp-sct.tbm - On Mission Start"]:912: in function 'process_explosion_effects'
[string "mv_exp-sct.tbm - On Frame"]:946: in main chunk
------------------------------------------------------------------

1: Userdata [Testing]
2: String [createParticle]
------------------------------------------------------------------

Code: [Select]
LUA ERROR: [string "mv_exp-sct.tbm - On Mission Start"]:849: attempt to call field 'createParticle' (a nil value)

------------------------------------------------------------------
ADE Debug:
------------------------------------------------------------------
------------------------------------------------------------------


------------------------------------------------------------------

stack traceback:
[C]: in function 'createParticle'
[string "mv_exp-sct.tbm - On Mission Start"]:849: in function 'do_small_explosion_effects'
[string "mv_exp-sct.tbm - On Mission Start"]:880: in function 'maybe_draw_explosion_effects'
[string "mv_exp-sct.tbm - On Mission Start"]:912: in function 'process_explosion_effects'
[string "mv_exp-sct.tbm - On Frame"]:946: in main chunk
------------------------------------------------------------------

------------------------------------------------------------------

Did you test all of your scripts with the latest FSO build (i.e. FSO version 19.0.0 or a latest nightly build) and the latest MediaVPs?

EDIT: Have you make sure all scripts make full use of libRocket/HD UI? Base scripts included.
Bryan See - My FreeSpace Wiki User Page (Talk, Contributions)

Full Projects:
Shattered Stars

Campaigns:
Lost in the Mist - Cyrene vs. Psamtik
FreeSpace: Reunited

Ships:
GTS Hygeia, GTT Argo, SC Raguel

Tools:
FSO TC/Game template

I've been under attack by Tiger Parents like Jennifer Pan...

 

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
mv_exp-sct.tbm is not part of my script pack, it's just for the mediavps. None of my scripts in this github repo use ts.createParticle either.

You do have a valid issue though, just with the mediavps and the ts.createParticle scripting function. The ts.createParticle function is obsolete if your FSO target version is too high, you should be using the gr.createParticle function. So the fix is either to set the target version to something that works, or replace all instances of ts.createParticle with gr.createParticle in the affected scripting files.

I don't test with every update, but scripting API changes are pretty rare (this being one of those rare occasions) and usually I'll hear about changes early on to try and avoid this.

These scripts also don't such libRocket at all so there's no chance of them breaking that.
« Last Edit: February 23, 2020, 09:28:32 am by Axem »

 

Offline Bryan See

  • Has anyone really been far as decided to use even go want to do look more like?
  • 210
  • Trying to redeem, but under Tiger Parents
    • Skype
    • Steam
    • Twitter
Re: Axem's Script & Lua SEXP Collection
I think the problem lies with the game_settings.tbl $Target Version: parameter when specified +Major: 19. FSO got a versioning number scheme recently.
Bryan See - My FreeSpace Wiki User Page (Talk, Contributions)

Full Projects:
Shattered Stars

Campaigns:
Lost in the Mist - Cyrene vs. Psamtik
FreeSpace: Reunited

Ships:
GTS Hygeia, GTT Argo, SC Raguel

Tools:
FSO TC/Game template

I've been under attack by Tiger Parents like Jennifer Pan...

 

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
Yes, major version should be less than 19 or switch to the proper function.

Code: [Select]
particle createParticle(vector Position, vector Velocity, number Lifetime, number Radius, enumeration Type, [number Tracer length=-1, boolean Reverse=false, texture Texture=Nil, object Attached Object=Nil])
    Creates a particle. Use PARTICLE_* enumerations for type.Reverse reverse animation, if one is specifiedAttached object specifies object that Position will be (and always be) relative to.
    Deprecated starting with version 19.0.0: Not available in the testing library anymore. Use gr.createPersistentParticle instead.
    Returns: Handle to the created particle

 

Offline Bryan See

  • Has anyone really been far as decided to use even go want to do look more like?
  • 210
  • Trying to redeem, but under Tiger Parents
    • Skype
    • Steam
    • Twitter
Re: Axem's Script & Lua SEXP Collection
Yes, major version should be less than 19 or switch to the proper function.

Code: [Select]
particle createParticle(vector Position, vector Velocity, number Lifetime, number Radius, enumeration Type, [number Tracer length=-1, boolean Reverse=false, texture Texture=Nil, object Attached Object=Nil])
    Creates a particle. Use PARTICLE_* enumerations for type.Reverse reverse animation, if one is specifiedAttached object specifies object that Position will be (and always be) relative to.
    Deprecated starting with version 19.0.0: Not available in the testing library anymore. Use gr.createPersistentParticle instead.
    Returns: Handle to the created particle

Thanks, Axem. But I got one problem with yours. The proBox.

Code: [Select]
LUA ERROR: [string "proBox-sct.tbm - On Game Init"]:166: attempt to index field 'PromptData' (a nil value)

------------------------------------------------------------------
ADE Debug:
------------------------------------------------------------------
------------------------------------------------------------------


------------------------------------------------------------------

stack traceback:
[C]: ?
[string "proBox-sct.tbm - On Game Init"]:166: in function 'ResetRef'
[string "proBox-sct.tbm - On Game Init"]:170: in function <[string "proBox-sct.tbm - On Game Init"]:170>
------------------------------------------------------------------

------------------------------------------------------------------
Bryan See - My FreeSpace Wiki User Page (Talk, Contributions)

Full Projects:
Shattered Stars

Campaigns:
Lost in the Mist - Cyrene vs. Psamtik
FreeSpace: Reunited

Ships:
GTS Hygeia, GTT Argo, SC Raguel

Tools:
FSO TC/Game template

I've been under attack by Tiger Parents like Jennifer Pan...

 

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
Okay, I've just committed a fix. Please see if that fixes your issue.

 

Offline Bryan See

  • Has anyone really been far as decided to use even go want to do look more like?
  • 210
  • Trying to redeem, but under Tiger Parents
    • Skype
    • Steam
    • Twitter
Re: Axem's Script & Lua SEXP Collection
Okay, I've just committed a fix. Please see if that fixes your issue.
It works for me. Thanks, Axem! :)
Bryan See - My FreeSpace Wiki User Page (Talk, Contributions)

Full Projects:
Shattered Stars

Campaigns:
Lost in the Mist - Cyrene vs. Psamtik
FreeSpace: Reunited

Ships:
GTS Hygeia, GTT Argo, SC Raguel

Tools:
FSO TC/Game template

I've been under attack by Tiger Parents like Jennifer Pan...

 

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
Hello! I am working on the new save/load script. It's working out pretty great so far.

New features include this one sexp to save everything and one sexp to load everything!


That is 99.999% literally it. It figures out what to save, and then it can apply it to the ships in a new playthrough, even ones that have not arrived yet! The only other extra work is needing to cue the unarrived ships to arrive, but I help and make them set their arrival info to have no warp in so you just need to tie their arrival to the same event as when you are loading the save data. I'll get into other neat features later, but first...

I've got some important questions for the FREDders who will be using this: What are your expectations for things that the script will save?

So stuff that gets saved now is stuff like position, orientation, health and shields, weapons, ammo, and general status (was it present during the save, destroyed? departed? arrived?).

Do you need AI orders? Turret lock status? Afterburner/weapon energy amounts? Stealth/hidden from sensor status? Any other alter-status-flag stuff? Player throttle position? ETS settings?

And how well do you need it to work with wings with waves? Like, perfect perfect or "kinda close enough". Single wave wings work fine right now, but when you get to the second or third set of waves... it get's a bit complicated and possibly inaccurate (like Beta 4 that died on the second wave might show up alive, something like that).

 

Offline Bryan See

  • Has anyone really been far as decided to use even go want to do look more like?
  • 210
  • Trying to redeem, but under Tiger Parents
    • Skype
    • Steam
    • Twitter
Re: Axem's Script & Lua SEXP Collection
I've got some important questions for the FREDders who will be using this: What are your expectations for things that the script will save?

So stuff that gets saved now is stuff like position, orientation, health and shields, weapons, ammo, and general status (was it present during the save, destroyed? departed? arrived?).

Do you need AI orders? Turret lock status? Afterburner/weapon energy amounts? Stealth/hidden from sensor status? Any other alter-status-flag stuff? Player throttle position? ETS settings?

And how well do you need it to work with wings with waves?
To me, the expectations for things that the script will save is high.

All will be present.

I need AI orders, turret lock status, scanned status, afterburner/weapon energy amounts, stealth/hidden from sensor status and any other alter-status-flag stuff, as well as player/AI throttle position and ETS settings.

I need to work with wings with waves in a modular and flexible way.

When it's finished, you need to update that article on the wiki to reflect this.
Bryan See - My FreeSpace Wiki User Page (Talk, Contributions)

Full Projects:
Shattered Stars

Campaigns:
Lost in the Mist - Cyrene vs. Psamtik
FreeSpace: Reunited

Ships:
GTS Hygeia, GTT Argo, SC Raguel

Tools:
FSO TC/Game template

I've been under attack by Tiger Parents like Jennifer Pan...

 

Offline Darius

  • 211
Re: Axem's Script & Lua SEXP Collection
Hitting some LUA errors and trying to troubleshoot.

Code: [Select]
HitpointsLeft: Argument 2 is an invalid type 'nil'; number expected

------------------------------------------------------------------
ADE Debug:
------------------------------------------------------------------
------------------------------------------------------------------


------------------------------------------------------------------

stack traceback:
[C]: ?
[C]: ?
[string "saveload2-sct.tbm - On Game Init"]:301: in function 'ApplyData'
[string "saveload2-sct.tbm - On Game Init"]:247: in function 'LoadAll'
[string "saveload2-sct.tbm - On Game Init"]:575: in function <[string "saveload2-sct.tbm - On Game Init"]:575>
------------------------------------------------------------------

1: Userdata [subsystem]
2: NIL
------------------------------------------------------------------

Got some ships that are set to enter a couple seconds after loading the checkpoint that were there during the actual checkpoint save. Is this causing issues with the script not being able to find them?

 

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
So I did put the new SaveLoad script up on the github for Beta Testing. I would not use it for production right now, there's missing features and a few bugs right now. Basically it's out there so you can get a sense of how it works and report any structural issues.

I have added a new version of AxMessage, my scripted message hud gauge. This is version 1.3, and the big change here is multi-resolution settings. Before you could turn it on or off with the MinVertRes setting in the config file. That is now gone. Now you can specify a variety of minimum resolutions with different graphical settings, and the script will select the best one to fit your current screen. Things like different fonts, different message box graphics, and it'll even let you scale the message box. It's not dynamic scaling, but it does let you use a single message box, and then you just need to figure out the right fonts and offsets.

So because of all of that, the config file is quite a bit rekajiggered, and is not backwards compatible. You'll need to move some stuff around, just look through the sample file and you'll get a sense what goes where.

And lastly, the Infinite Ship Spawning script from JAD is up there. It's all accessible with LuaSEXPs, so if you're looking to make some wild arcade nonsense, it's even easier to have tons of fighters. There's some new features, like customizable arrival effects, and a way to make groups arrive at once (sort of like wings).

 

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
The SaveLoadX script is close to production ready now. It can save flags and AI orders now (though in a pretty hacky fashion until better code support gets added). You can also now exclude ships from being saved as well as grab ship data from another external save file. So if you want to take it for a campaign you're working on and try it out, go right ahead. Please let me know of any bug reports. There's some helpful print statements in the debug log if you're running on a debug build, so please attach that and the save file generated if you run into errors.

Also, right now the script is set up to work outside of the normal campaign mode. On final release that will be turned off.

The line that governs this is
Code: [Select]
self.WorksOutOfCampaign = true
Its line 13 in saveload2-sct.tbm.

  

Offline Axem

  • 211
Re: Axem's Script & Lua SEXP Collection
I've added some new scripts. Mostly stuff as seen in JAD: Countdown, Item Drop, Health Bars. (and all of which UndyingNephalim is going to be using in Star Fox: Event Horizon!)

Also I added the speedlines script as seen in my most viewed youtube video ever: