Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  


Starsector 0.97a is out! (02/02/24); New blog post: Codex Overhaul (05/11/24)

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - cloverstar

Pages: [1]
It is a tree, but this construction looks wrong. getNode() returns an FDNode but takes a String as a parameter so you couldn't chain it like this.

getNode() is overloaded! There's one that takes in an FDNode and is actually the one you use in CoreScript

MonthlyReport report = SharedData.getData().getCurrentReport();

Thanks, it worked perfectly! Are the MonthlyReport and FDNode objects transient? Is it safe to retrieve them once for the industry and store it, or should I retrieve them every time I want to update the values? I noticed you did the latter.

Also, I followed your code to retrieve the node for a particular industry and created this monstrosity:
FDNode iNode = report.getNode(report.getNode(report.getNode(report.getNode(MonthlyReport.OUTPOSTS), market.getId()), "industries"), getId());
Is there any way to truncate or is it just a tree you have to traverse?

That should work fine, yeah. You don't need to reset anything - it's just a value, the code applying it to the monthly expenses looks at it and does whatever is appropriate. Unless I'm misunderstanding something about what you're asking...

I'm trying to have a structure keep a running monthly tab and then apply the debt at the end of the month. Basically, during the month, add x credits n times to the tab, both of which can vary month to month. Then, charge the player at the end of the month for the total and zero out the tab. I'm probably just going to have to detect when the month changes through advance() with more instance variables huh

What would be the best way to go about implementing a dynamic upkeep for a structure? I was thinking about calling applyIncomeAndUpkeep() and changing upkeep as I go but I'm not sure how to zero out the upkeep at the beginning of a new month. I've just been creating intel messages but it really clogs up your screen if you have multiple colonies lol

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:
And if you haven't figured it out already, the api source is in - 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!

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.

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! :)

Pages: [1]