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: Simulator Enhancements (03/13/24)

Pages: 1 ... 397 398 [399] 400 401 ... 706

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5970 on: January 22, 2020, 09:27:48 AM »

A lot of things could be, yeah :) But, let me add that since we're talking about it, might save someone a bit of trouble later.
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7173
  • Harpoon Affectionado
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5971 on: January 22, 2020, 09:54:22 AM »

You mean in the campaign, right? When you're out of supplies etc? If so: regrettably (since I'm finding myself suddenly partial to cursed golden lobsters) I don't think so. You could have it show a custom interaction dialog on demand, though, and have <whatever> happen then, including damage to a ship and so on.

Custom dialogs it is then! Thanks! :)
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5972 on: January 22, 2020, 12:00:48 PM »

(Actually, come to think of it, handling it as a new intel item might work more smoothly in terms of player experience, so it doesn't interrupt what they were doing. On the other hand, if it's something major, then a dialog popping up means they definitely won't miss it... could go either way, really.)
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7173
  • Harpoon Affectionado
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5973 on: January 22, 2020, 02:22:16 PM »

(Actually, come to think of it, handling it as a new intel item might work more smoothly in terms of player experience, so it doesn't interrupt what they were doing. On the other hand, if it's something major, then a dialog popping up means they definitely won't miss it... could go either way, really.)

(Well it is things blowing up because of a cursed lobster statue, so I think I'm going to interrupt the player with humorous events. :p Who knew that your second in command could trip over a statue and fall out of a torpedo tube?!)

On a related note: Rules.csv and scripts called from Rules.csv has access to a set of MemoryAPI's as determined by the MemKeys (global, local, etc etc). These can be accessed from arbitrary scripts by calling the right getMemory (withoutUpdate?), right?

For example, Memkeys.Global's memoryAPI is the same as Global.getSector().getMemoryWithoutUpdate()?

Or is there a different way for non-dialog scripts to access those memoryAPIs?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5974 on: January 23, 2020, 02:42:31 PM »

That's exactly right, yeah.

Who knew that your second in command could trip over a statue and fall out of a torpedo tube?!)

:D
Logged

cloverstar

  • Ensign
  • *
  • Posts: 7
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5975 on: January 24, 2020, 05:51:17 AM »

Hi! I'm trying to create a new structure and I want to script something that happens with the structure every time the size of the market increases or when it gets shutdown. As far as I can tell, there's nothing in the BaseIndustry class that is specifically implemented to do this. Would the best way be to just override advance() and check to see if the market size has changed from an internally stored variable? How does advance() actually work and how is it called? If I do just check the current size against an instance variable, do I have to guard against data races? How do I script something to happen when it gets shutdown?

Thanks in advance! :)
« Last Edit: January 24, 2020, 08:08:40 AM by cloverstar »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5976 on: January 24, 2020, 10:05:49 AM »

Hi! I'm trying to create a new structure and I want to script something that happens with the structure every time the size of the market increases or when it gets shutdown. As far as I can tell, there's nothing in the BaseIndustry class that is specifically implemented to do this. Would the best way be to just override advance() and check to see if the market size has changed from an internally stored variable? How does advance() actually work and how is it called? If I do just check the current size against an instance variable, do I have to guard against data races? How do I script something to happen when it gets shutdown?

Thanks in advance! :)

For being shut down: the Industry.notifyBeingRemoved() method gets called when that happens. If you override it, make sure to call super.notifyBeingRemoved() if you're extending the BaseIndustry class since that does some things (such as making sure installed AI cores don't disappear without a trace).

For changing size, yeah, what you're thinking about with advance() sounds reasonable. No need to worry about data races or anything multithreaded, everything relevant to this happens in the same thread.

Hi and welcome to the forum, btw :)
Logged

cloverstar

  • Ensign
  • *
  • Posts: 7
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5977 on: January 24, 2020, 10:23:01 AM »

Thank you! I've been playing tons and I'm looking forward to giving some back.

Also, can you talk about the specifics on how advance() is used? I presume it's not simply advancing by a month if days are being passed in.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5978 on: January 24, 2020, 10:28:43 AM »

Generally an advance() method is called once per frame for the current location, and something like once per X frames in other locations, where X is 20-40 (I forget exactly what, and it's subject to being fine tuned).

The "float amount" parameter is the seconds elapsed during the previous frame, so assuming a stable 60 frames per second, it'd be something like 0.0166666 for the current location, and that times X for non-current locations.

To convert that to days, you'd do something like Global.getSector().getClock().convertToDays(amount).

Btw, there's javadoc here:
http://fractalsoftworks.com/forum/index.php?topic=7164.0

And if you haven't figured it out already, the api source is in starfarer.api.zip - especially handy if you're using an IDE, which would let you easily look at a fair bit of the code.
Logged

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5979 on: January 24, 2020, 12:22:37 PM »

Where can I get a list of dialogue API stuff like GetHisOrHer() and GetHimselfOrHerself().

My IDE doesn't let me retrieve this as easy and I end up having to look back at source materials, but I'm sure there is more than these two.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5980 on: January 24, 2020, 12:34:29 PM »

Hmm? Could you clarify about what context you're working in here? What class has these methods?
Logged

cloverstar

  • Ensign
  • *
  • Posts: 7
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5981 on: January 24, 2020, 12:56:11 PM »

Generally an advance() method is called once per frame for the current location, and something like once per X frames in other locations, where X is 20-40 (I forget exactly what, and it's subject to being fine tuned).
The "float amount" parameter is the seconds elapsed during the previous frame, so assuming a stable 60 frames per second, it'd be something like 0.0166666 for the current location, and that times X for non-current locations.
To convert that to days, you'd do something like Global.getSector().getClock().convertToDays(amount).
Btw, there's javadoc here:
http://fractalsoftworks.com/forum/index.php?topic=7164.0
And if you haven't figured it out already, the api source is in starfarer.api.zip - especially handy if you're using an IDE, which would let you easily look at a fair bit of the code.

Oh it's the number of seconds for industries? I saw it was days for CoreImmigrationPluginImpl and I just assumed it was days lol
Is there a way for me to trigger monthly scripts? I feel like doing something like checking to see if the market size changes every second is super silly and might unnecessarily bog down performance.

And yea I have seen the javadoc but unless I'm missing something, it only has prototypes right? No descriptions? I tried to look up how advance worked and there wasn't anything about it. I've just been digging through the api to understand the structure with notepadd++ since I'm too lazy to actually set up the environment on eclipse lmao

Also, I'd just like to say how much I appreciate you for participating in the modding community so much and for making a game that allows actual Java injection, first I've seen!
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5982 on: January 24, 2020, 01:05:10 PM »

Yeah, CoreImmigrationPluginImpl is like the one exception, IIRC because it's run by the economy which is just... different.

Is there a way for me to trigger monthly scripts? I feel like doing something like checking to see if the market size changes every second is super silly and might unnecessarily bog down performance.

See: IntervalUtil for something that allows you to effectively run things every <whatever period>. However, that'll actually require slightly *more* performance than just checking the size of a market against a saved integer, so I wouldn't recommend it for this. The performance cost of performing a trivial check like this is negligible.

And yea I have seen the javadoc but unless I'm missing something, it only has prototypes right? No descriptions? I tried to look up how advance worked and there wasn't anything about it. I've just been digging through the api to understand the structure with notepadd++ since I'm too lazy to actually set up the environment on eclipse lmao

Yeah, there's not a lot of comments there, but you can infer some stuff from the method names. I'd suggest setting up an environment - I totally get that it's a pain, but it'd save you time in the long run.

(For advance specifically, and anything related, if there's an "amount" parameter for time, it's seconds.)

Also, I'd just like to say how much I appreciate you for participating in the modding community so much and for making a game that allows actual Java injection, first I've seen!

Helps that the game is in Java, I suppose :)
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5983 on: January 24, 2020, 04:06:37 PM »

How can I add a message to the left side ticker where new quests, intel, etc appear? I want to add a message like "earned 10000 credits" or something, but it isn't associated with a quest.

I was eyeing this code from a quest:
Quote
TextPanelAPI text = dialog.getTextPanel();
AddRemoveCommodity.addCreditsGainText(loanAmount, text);
However I don't know where to get the TextPanelAPI from. There is no "dialog" where I want to activate it.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5984 on: January 24, 2020, 04:15:06 PM »

See: com.fs.starfarer.api.impl.campaign.intel.MessageIntel and how it's used.
Logged
Pages: 1 ... 397 398 [399] 400 401 ... 706