Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: New music for Galatia Academy (06/12/24)

Pages: 1 ... 639 640 [641] 642 643 ... 721

Author Topic: Misc modding questions that are too minor to warrant their own thread  (Read 1789850 times)

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24407
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9600 on: February 11, 2023, 03:52:37 PM »

Since you say it's fine in general and I don't store members that shouldn't be around (and I didn't notice any problems during playtesting), it should be fine. Thanks again!

Yeah, this sounds fine!

Edit: have another question - is it possible to emulate behaviour of refit screen's ship name text field in circumstances of large intel description? In other words, I want to save string of textfield each time it is modified - could use a normal "Save" button right next to it, but that's not ideal for my taste.

Hmm - you might be able to query its contents every frame in a plugin that runs when the game is paused. And that you add when the player is viewing the intel and remove when they're not.


Interesting it is possible to modify UI for skill selection screen? Both for Player and Officer, and if not, can I suggest it for new version? I'd like to have wider choice of skills for officer, so it less a random gamble, and to have option to make skills like they was in 091 or 06 versions of the game when they had multiple levels, 3 or 10 instead of just base skill and upgrading it to elite one.

I don't believe it supports multiple skill levels beyond making skills elite (which, under the hood, are "level 2" skills). You could give officers more skill choices by implementing your own version of OfficerLevelupPlugin, though.


Is there a way to override the Codex and F1 displays of ship stats to show an arbitrary string?

Specifically, I want to display a range of possible ship stats, and have some code that randomly sets values for each individual ship instance.

My fallback plan for handling my problem is to have all stats set to 10, but have the real stats instanced as soon as the battle begins. Mostly just a "looking nice" thing that I'd prefer not to.

I don't think there is, sorry!
Logged

Ontheheavens

  • Commander
  • ***
  • Posts: 139
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9601 on: February 12, 2023, 01:25:20 AM »

Hmm - you might be able to query its contents every frame in a plugin that runs when the game is paused. And that you add when the player is viewing the intel and remove when they're not.

Could you clarify which methods or listeners can be used to tell if certain intel item is currently being viewed, and possibly to report event of opening and closing description panel? There's
Code
reportPlayerClickedOn()
and
Code
notifyPlayerAboutToOpenIntelScreen()
, but I'm not sure if this is what I'm looking for.

Tried also to put relevant code into own
Code
advance()
of intel item (as it itself implements EveryFrameScript), but the method just doesn't get called even with
Code
runWhilePaused()
set to return true.

Edit: also facing that same challenge with "Show on map" functionality that Jaghaimo had:

Also, is it possible to tap into "Show on map" button (or recreate its functionality)? I'd like to add a custom button with a different SectorEntityToken to intel's one.
It's not currently possible, no. Best you could do is swap out what the getMapLocation() method on the intel returns...
That would be enough if there was a way to trigger the button click without actually clicking it... Oh. Oooooh. Swap token with desired one, use AWT keyboard to send S, swap back. Custom show location buttons here I come!

In the case of large, custom-panel-powered description this solution doesn't work out of the box, since the vanilla showOnMap button shouldn't be seen by player (looks ugly with its unmodifiable position), and therefore must be immediately cleaned-up by resetting returns of getMapLocation() back to null. The problem is, if I make the reset right from the execution of buttonPressConfirmed(), the map doesn't show up at all.

Perhaps this can be worked around by placing the reset code in advance() method and call that after map has been shown - if only I could capture that event, and if I could either get own intel's advance() working or have starting and closing conditions to satellite advance(). But, nonetheless: I think this calls for a proper showTokenOnMap() method in IntelInfoPlugin.

Edit 2: Figured out that for advance() to work intel should be added to sector as script; but that didn't help me to solve either problem. In advance(), getMapLocation() returns are reset back to null, map's showing fine, but pesky button still persists even after calling                 
Code
bufferedUI.updateUIForItem(this)
In any case, such a workaround is not satisfactory for me, since the button is visible for a few frames before map is actually opened. It's no biggie, my mod will have to do without such a feature, but these API constraints sure do not spark joy.

Edit 3: while working with campaign entities, noticed an OCD-unfriendly typo in Valhalla System - Valkyrie has a space before its name:

Code
			// Valkyrie jump
JumpPointAPI jumpPoint = Global.getFactory().createJumpPoint("valkyrie_jump", " Valkyrie Jump-point");

Edit 4: I want to emulate behaviour of skill buttons in Character tab. Speaking more broadly, I want buttons with arbitrary images/textures on them. And I want them in tooltip instances and large intel descriptions, not just in custom panels with work-from-scratch GL11. Is this realistic at all or am I out of luck?
« Last Edit: February 17, 2023, 09:25:05 AM by Ontheheavens »
Logged
   

Ruddygreat

  • Admiral
  • *****
  • Posts: 544
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9602 on: February 12, 2023, 01:42:05 PM »

is it intentional that there's one(?) frame at the end of a system's activation where unapply() hasn't yet been called but isOn() returns false?
I've been having some behaviour w/ a system script that hopefully could only be explained by that, though I can't really think of a way to conclusively prove it.
another candidate might be some wierd interaction between the order that advanceableListeners & system scripts are run in?

Ontheheavens

  • Commander
  • ***
  • Posts: 139
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9603 on: February 13, 2023, 01:15:49 AM »

double post, to remove
Logged
   

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9604 on: February 13, 2023, 05:26:09 PM »

Hi Alex, I am adding

Code
public static Map<String, Float> CSVReading = new HashMap<>();
in the ModPlugin where it reads some of the .csv that I cannot access from the API regularly.

My question is whether a hullmod importing this CSVReading in the ModPlugin might keep it around and not get garbage collected.

Code
import static data.hullmods.ModPlugin.CSVReading;

CSVReading.get(string);
in that type of manner.


--------
On a different note, I would like an explanation of how economyTier works because the various examples seem confusing to do and fiddling with the values doesn't seem to reproduce any meaningful differentiation on what the column does.

I'm also trying to accomplish where a modded commodity is able to satisfy a vanilla commodity's need. Like selling custom red metal into feeding metal's demands.


ctuncks

  • Commander
  • ***
  • Posts: 130
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9605 on: February 15, 2023, 12:00:41 AM »

Got a few questions.
Does
Code
weapon.getSpec().getMaxRange();
get the maximum range of a weapon as dictated by the weapon.csv? or does it get the current maximum range? (In the case something else has modified it)

While testing a few beam weapons (including clones) I noticed that vanilla beam weapons produce an ambient glow around the firing ship and near the target, if you clone the weapon it does not get this glow, the mod Lightshow can make this happen, but where does it happen in normal settings? It does not seem to be in the weapon.csv or individual weapon files.

On a similar note some of the vanilla beam weapons like the graviton beam have a differently proportioned core size than a clone of it with the same setting, how can you alter this?
Logged

Zsar

  • Captain
  • ****
  • Posts: 299
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9606 on: February 15, 2023, 03:00:10 AM »

Is there a non-invasive way to replace a SubmarketPlugin?

I am trying to cull the BlackMarketPlugin's very generous equipment selection a little, to make faction markets more attractive, but it would seem that I cannot replace it (no Submarket#setPlugin method, no SettingAPI#setPlugin).

How does Dependency Injection work here? The game does not seem to use any of the common frameworks?
(I presume that this is somehow possible - a "plugin" that cannot be plugged in is not much of a "plug-", nor much of an "-in".)
Logged

Zsar

  • Captain
  • ****
  • Posts: 299
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9607 on: February 15, 2023, 03:04:10 AM »

Code
public static Map<String, Float> CSVReading = new HashMap<>();
[...]

My question is whether a hullmod importing this CSVReading in the ModPlugin might keep it around and not get garbage collected.
Dunno if the game does anything funny with ClassLoaders, but generally, if data is declared "static", it will stick around until the application terminates. More to the point, the only way to get rid of it is to garbage collect the ClassLoader that loaded the class it's defined in.
(... Might have changed in more recent Java versions, I am not quite up to date, but should definitely still be the case in 7 and 8.)
« Last Edit: February 15, 2023, 03:18:43 AM by Zsar »
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3035
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9608 on: February 15, 2023, 04:20:47 AM »

Is there a non-invasive way to replace a SubmarketPlugin?

I am trying to cull the BlackMarketPlugin's very generous equipment selection a little, to make faction markets more attractive, but it would seem that I cannot replace it (no Submarket#setPlugin method, no SettingAPI#setPlugin).

How does Dependency Injection work here? The game does not seem to use any of the common frameworks?
(I presume that this is somehow possible - a "plugin" that cannot be plugged in is not much of a "plug-", nor much of an "-in".)

You can edit the submarket's contents with (I think) an EconomyUpdateListener, or you can replace the submarket's plugin, or you can use a custom black market submarket for your markets.
Logged

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9609 on: February 15, 2023, 11:10:01 AM »

Got a few questions.
Does
Code
weapon.getSpec().getMaxRange();
get the maximum range of a weapon as dictated by the weapon.csv? or does it get the current maximum range? (In the case something else has modified it)

...
Yes, the former.
it get the current maximum range? (In the case something else has modified it)
WeaponAPI.getRange() will return from this.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24407
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9610 on: February 17, 2023, 11:12:24 AM »

(Sorry about the delayed responses! I... kind of just forgot to check this.)


In the case of large, custom-panel-powered description this solution doesn't work out of the box, since the vanilla showOnMap button shouldn't be seen by player (looks ugly with its unmodifiable position), and therefore must be immediately cleaned-up by resetting returns of getMapLocation() back to null. The problem is, if I make the reset right from the execution of buttonPressConfirmed(), the map doesn't show up at all.

Could you clarify what extactly you're trying to do? I get a vague idea from what you wrote, but it's mostly about the problems you're having and not what you're trying to *do* so it's harder to interpret. E.G. I don't understand why "the map doesn't show up at all" is a problem since it sounds like that's what you want?

(That said, chances are it's probably not doable within the current API...)


Edit 3: while working with campaign entities, noticed an OCD-unfriendly typo in Valhalla System - Valkyrie has a space before its name:

Fixed, ty!

Edit 4: I want to emulate behaviour of skill buttons in Character tab. Speaking more broadly, I want buttons with arbitrary images/textures on them. And I want them in tooltip instances and large intel descriptions, not just in custom panels with work-from-scratch GL11. Is this realistic at all or am I out of luck?

I don't think - at least, no that I recall - that there are any methods in the API to create similar buttons. (You *could* implement your own, processing clicks etc in a custom UI element, though that's obviously a bunch of work and not something I'd really suggest.)

is it intentional that there's one(?) frame at the end of a system's activation where unapply() hasn't yet been called but isOn() returns false?
I've been having some behaviour w/ a system script that hopefully could only be explained by that, though I can't really think of a way to conclusively prove it.
another candidate might be some wierd interaction between the order that advanceableListeners & system scripts are run in?

Does the system have 0 "down" duration? Looking at the code, I think this may happen then, yeah - there'll be one frame where the effect level is 1, the state is it charging down, and unapply() will not have been called yet. I wouldn't call this intentional but it's not something I want to touch at this point - it could break something very subtle.



Hi Alex, I am adding

Code
public static Map<String, Float> CSVReading = new HashMap<>();
in the ModPlugin where it reads some of the .csv that I cannot access from the API regularly.

My question is whether a hullmod importing this CSVReading in the ModPlugin might keep it around and not get garbage collected.

Code
import static data.hullmods.ModPlugin.CSVReading;

CSVReading.get(string);
in that type of manner.

This is not a problem for several reasons.
1) The data is already referenced from a static variable so it won't be garbage collected regardless; its expected lifetime is the entire application session (unless you null out that pointer)
2) Hull mod scripts are singletons
3) You're not storing a reference to this data in those, anyway


--------
On a different note, I would like an explanation of how economyTier works because the various examples seem confusing to do and fiddling with the values doesn't seem to reproduce any meaningful differentiation on what the column does.

I'm also trying to accomplish where a modded commodity is able to satisfy a vanilla commodity's need. Like selling custom red metal into feeding metal's demands.

It affects the order in which the commodity demand calculation is run. If it's "wrong" it should still work out, just may take a few more iterations for the economy engine. Generally the lower on the chain the commodity the lower this value should be. E.G. ore -> metals -> heavy machinery, etc.


While testing a few beam weapons (including clones) I noticed that vanilla beam weapons produce an ambient glow around the firing ship and near the target, if you clone the weapon it does not get this glow, the mod Lightshow can make this happen, but where does it happen in normal settings? It does not seem to be in the weapon.csv or individual weapon files.

This sounds like a mod feature!

On a similar note some of the vanilla beam weapons like the graviton beam have a differently proportioned core size than a clone of it with the same setting, how can you alter this?

IIRC there's nothing special here, so copy-pasting the gravitonbeam weapon file with a different weapon ID should produce the same result. But if you want a differently proportioned core, you can provide a different beam texture. See hil.wpn for an example for how to provide a custom texture.


Is there a non-invasive way to replace a SubmarketPlugin?

I am trying to cull the BlackMarketPlugin's very generous equipment selection a little, to make faction markets more attractive, but it would seem that I cannot replace it (no Submarket#setPlugin method, no SettingAPI#setPlugin).

How does Dependency Injection work here? The game does not seem to use any of the common frameworks?
(I presume that this is somehow possible - a "plugin" that cannot be plugged in is not much of a "plug-", nor much of an "-in".)

You can specify the plugin in data/campaign/submarkets.csv.
Logged

Ontheheavens

  • Commander
  • ***
  • Posts: 139
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9611 on: February 17, 2023, 09:57:07 PM »

Could you clarify what extactly you're trying to do? I get a vague idea from what you wrote, but it's mostly about the problems you're having and not what you're trying to *do* so it's harder to interpret. E.G. I don't understand why "the map doesn't show up at all" is a problem since it sounds like that's what you want?

What I want to have is functionality of vanilla hardcoded "Show on map" button. And I want to have this functionality tied to an arbitrary button I can place anywhere in panel I want. See attached for the visual on what happens if I enable vanilla button.

(That said, chances are it's probably not doable within the current API...)

I'm pretty sure that's the case, yeah!

I don't think - at least, no that I recall - that there are any methods in the API to create similar buttons. (You *could* implement your own, processing clicks etc in a custom UI element, though that's obviously a bunch of work and not something I'd really suggest.)

Right, that's understandable. Given that the answer "this is not doable within the current API" is a fairly frequent outcome of my questions, I'd like to ask a bit more general question. Example would be best here. ButtonAPI has one implementor class which is "public class OoO0 extends Q implements oo, ButtonAPI, com.fs.starfarer.ui.e.oo" in my obfuscation variant. Among methods that do not exist in ButtonAPI implementing class has:

  • setSkipPlayingPressedSoundOnce(boolean)
  • setHighlightBounceDown(boolean)
  • setShowTooltipWhileInactive(boolean)
  • setRightClicksOkWhenDisabled(boolean)
  • setFlashBrightness(boolean)
  • setAddFlashToGlow(float)
  • setPerformActionWhenDisabled(boolean)

In recent patchnotes, you added
  • float getGlowBrightness();
  • void setGlowBrightness(float glowBrightness);
  • void setText(String text);
  • String getText();

My question is: what's stopping you from exposing the vast majority of simple getter/setter methods that are present in implementing classes but are not present in the API? ButtonAPI's being just an example, there are plenty of cases like this - had a comment on getTurretGunSpriteName(), where the method was right there in the class but it required indirect reflection to get to use it - said method being added by you in upcoming patch too.
« Last Edit: February 17, 2023, 10:32:24 PM by Ontheheavens »
Logged
   

Zsar

  • Captain
  • ****
  • Posts: 299
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9612 on: February 18, 2023, 03:14:04 AM »

My question is: what's stopping you from exposing the vast majority of simple getter/setter methods that are present in implementing classes but are not present in the API?
They might not work as expected. Many fields are read at one time into e.g. ScriptStore. If their setters were exposed, you could set there - to no effect. If their getters were exposed you might get the idea to change the value by reflection - to no effect. This would make the - largely undocumented - API much harder to use by adding "Red Herrings".

See e.g. L implements SubmarketSpecAPI : It has a getter #getScriptClass . But at game start, SpecStore passes the current data into ScriptStore. After this point, if we changed the script class of a Submarket, this would not have an effect, so it's better to hide the method than to expose it without comment.

Notes:
  • At ModPlugin#onApplicationLoad SpecStore has already read the ScriptClass and it throws a RuntimeException, if you try to replace existing entries, so the method is quite literally useless, even at the earliest possible time a mod might access it.
  • Even better, of course, would be to write proper JavaDoc onto it, because we might still sensibly use the getter for informational purposes, e.g. while debugging.

Looking at the first method you listed, OoO0#setSkipPlayingPressedSoundOnce , I cannot find any caller for the respective getter #isSkipPlayingPressedSoundOnce (discounting that IDEA is notoriously unreliable with finding those in libraries). So, if you could call this setter - what good would it do? It would be but clutter.
« Last Edit: February 18, 2023, 03:23:41 AM by Zsar »
Logged

Ontheheavens

  • Commander
  • ***
  • Posts: 139
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9613 on: February 18, 2023, 03:26:14 AM »

My question is: what's stopping you from exposing the vast majority of simple getter/setter methods that are present in implementing classes but are not present in the API?
They might not work as expected. Many fields are read at one time into e.g. ScriptStore. If their setters were exposed, you could set there - to no effect. If their getters were exposed you might get the idea to change the value by reflection - to no effect. This would make the - largely undocumented - API much harder to use by adding "Red Herrings".

See e.g. L implements SubmarketSpecAPI : It has a getter #getScriptClass . But at game start, SpecStore passes the current data into ScriptStore. After this point, if we changed the script class of a Submarket, this would not have an effect, so it's better to hide the method than to expose it without comment.

Notes:
  • SpecStore throws a RuntimeException, if you try to replace existing entries, so the method is quite literally useless after the first time it's been called.
  • Even better, of course, would be to write proper JavaDoc onto it, because we might still sensibly use the getter for informational purposes, e.g. while debugging.

Looking at the first method you listed, OoO0#setSkipPlayingPressedSoundOnce , I cannot find any caller for the respective getter #isSkipPlayingPressedSoundOnce (discounting that IDEA is notoriously unreliable with finding those in libraries). So, if you could call this setter - what good would it do? It would be but clutter.

I think you might be misunderstanding what my point essentially is. Let me put it this way:

There are tools and functionality that are present and usable through reflection in the original (obfuscated) code, which are not exposed in the API. Why they are not exposed?

There might be specific cases that have tricky ways about their workings and effects, yes. I'm not particular about those - it's understandable that some parts of code are intertwined to such a degree that exposure could take too much work or could have undesirable side effects and consequenses. Those are not what my question is about. At the same time, there are cases where there is nothing tricky about methods which one might want to use, except the fact that they are in the obfuscated code.

Looking at the first method you listed, OoO0#setSkipPlayingPressedSoundOnce , I cannot find any caller for the respective getter #isSkipPlayingPressedSoundOnce (discounting that IDEA is notoriously unreliable with finding those in libraries). So, if you could call this setter - what good would it do? It would be but clutter.

I don't think this fact has any significance at all. My IntelliJ cannot find any usages of any method in the class we are talking about - doesn't mean it doesn't get called. Not to mention that the very notion of "clutter" when it comes to modding API of Starsector sounds absolutely nonsensical to me. There was a time when I, being a novice modder, thought that half of PositionAPI is clutter. Now I think there are no useless methods in the API whatsoever - it's just you didn't found use for them yet.
« Last Edit: February 18, 2023, 03:47:49 AM by Ontheheavens »
Logged
   

Zsar

  • Captain
  • ****
  • Posts: 299
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9614 on: February 18, 2023, 03:36:08 AM »

Ah, fair! Well... I'd presume that those just fell under the bus and their exposure may be requested in the API request thread? At the end of the day, the decision what to include and what to exclude in an interface is a manual one and mistakes will happen.

Is there a non-invasive way to replace a SubmarketPlugin?

I am trying to cull the BlackMarketPlugin's very generous equipment selection a little, to make faction markets more attractive, but it would seem that I cannot replace it (no Submarket#setPlugin method, no SettingAPI#setPlugin).

How does Dependency Injection work here? The game does not seem to use any of the common frameworks?
(I presume that this is somehow possible - a "plugin" that cannot be plugged in is not much of a "plug-", nor much of an "-in".)

You can edit the submarket's contents with (I think) an EconomyUpdateListener, or you can replace the submarket's plugin, or you can use a custom black market submarket for your markets.
You can specify the plugin in data/campaign/submarkets.csv.
Sorry I have to bring this up again, cannot get it to work.

So, I have written a replacement for BlackMarketPlugin that extends it and overrides only #updateCargoPrePlayerInteraction .
I tried the following to get it into the game:

- replace the SubmarketSpecAPI with one containing my plugin instead of the original
Does not work, original has already been read into SpecStore and ScriptStore and they do not allow replacement.

- add a submarkets.csv like this:
Code
id,name,faction,desc,script,icon,order
black_market,,,,data.scripts.zsar.harsherequipmentrestrictions.HarsherBlackMarketPlugin,,
Does not work - csv rows are replaced, not merged. Because specs are registered before the ModPlugin can do anything, I cannot manually add merging code either. (Or can I?)

- make the fully qualified class name identical to that of the original, hoping for this part of the documentation:
Quote
Replace
The following file types are always replaced:
[...]
  • Scripts (.java)
Does not work, I cannot extend the original that way. (Or can I?)

So... yes, well. How do I make black markets use my replacement plugin?
« Last Edit: February 18, 2023, 07:20:45 AM by Zsar »
Logged
Pages: 1 ... 639 640 [641] 642 643 ... 721