Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 364 365 [366] 367 368 ... 711

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

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5475 on: October 24, 2019, 12:37:54 PM »

Question: Can a station module have modules of it's own?

Because I have a station who's core has 2 DefenseModules and 2 extnetions modules, and the Defense modules have 3 armor modules each - Defnse adn extension moduels appear, but not the armor modules
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5476 on: October 24, 2019, 12:47:43 PM »

Is there any reason why .getMassWithModules() wouldn't realize when the ship's modules died? I can't get the method to report a decrease in mass after losing a module, it only returns the original mass of the ship + all its modules, even if some or all modules are dead. Other module ships I've tested have working .getMassWithModules() results. I can't for the life of me figure out why.

EDIT: Some further testing, seems the return of .getMassWithModules() is dependent on whether or not the destroyed modules break apart or not. The number still isn't correct, but seems to subtract a greater amount of the dead module's mass from the total if the module has broken into more pieces. This finding is making me doubt whether it was actually working on other module ships too. Could the method itself be bugged?

EDIT2: If I had to guess, the method considers the heaviest piece of each dead module to be still attached to the mothership. So a module that doesn't break at all contributes its total mass, and one that breaks into, say, 8 pieces will contribute a little over 1/8 of its mass. At least that's what the numbers I'm getting suggest.

Ahh - looks like it's a bug, actually; getMassWithModules() counts all modules regardless of whether they've been destroyed or not. As you noted, when a module breaks into pieces, it'll only count the weight of the piece that's counted as the "original" ship. Fixed!

Not sure why/how that'd ever work for you in the first place, though, that's a bit confusing.

It's not in use by any hulls or variants, and by it's description it a more limited version of what the Ox gets.
I'm just wondering if it's functional-but-replaced, if it never worked, or if it has stopped working since it was phased out.

Ah, I see! It used to work at some point, but it's pretty processor-intensive and just in general overcomplicated code because it was trying to do something that was tricky to do right. I'm not sure if it would work now or if some things have changed that would make it not work.

Question: Can a station module have modules of it's own?

Because I have a station who's core has 2 DefenseModules and 2 extnetions modules, and the Defense modules have 3 armor modules each - Defnse adn extension moduels appear, but not the armor modules

Right - modules can't have their own modules, all modules have to be specified in the station itself.

Of note: if an armor module (i.e. with no weapons/OP/fighters) has a collision bounds overlap with another module, and the other module gets detached, then the armor module will also get detached. This is a way to simulate a hierarchy of sorts, and this is why vanilla armor module collision bounds have "spikes" in them that extend into the modules they protect.

Otherwise, you'd get a module detaching, its armor modules not detaching, and then it awkwardly trying to collide "through" the armor modules.
Logged

Sinosauropteryx

  • Captain
  • ****
  • Posts: 262
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5477 on: October 24, 2019, 01:03:50 PM »

Not sure why/how that'd ever work for you in the first place, though, that's a bit confusing.
I'm not sure what you mean exactly, but my initial testing on the Cathedral from Ship and Weapon Pack showed the ship getting lighter as modules were destroyed. It was never really working, just fractions of each module being removed from the total as they broke up. Setting all pieces to breakProb = 0 confirmed it was in fact not working. (The other ship I was testing was breakProb = 0 to begin with.) Glad this is known about and being fixed now :)
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5478 on: October 24, 2019, 01:15:35 PM »

Ah, I see - makes sense now.
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5479 on: October 24, 2019, 02:42:25 PM »

Hmm - probably missing an import statement? Classes from other packages need to be imported before they can be used.

Something like:
import com.thoughtworks.xstream.XStream;

At the beginning of your file.

When I added that line, it only added another error beside it saying

Code
The import com.thoughtworks.xstream.XStream cannot be resolved

I also noticed something when I tried to remove some imports to find out which one was causing it, and it turned out to be 'BaseModPlugin'. When I removed that one line, the error on the first line disappeared, although several errors appeared farther down into the file...

Oh, and the full error I got was actually:

Code
The type com.thoughtworks.xstream.XStream cannot be resolved. It is indirectly referenced from required .class files

But none of the code I have so far uses XStream.

Just in case it might be related, apart from the libraries the Eclipse tutorial said to include, I've also imported MagicLib, Lazy Lib and Graphics Lib.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5480 on: October 24, 2019, 03:20:55 PM »

Not really a question but not sure where else to post this. Thank you very much for the addition of custom data to the weapon tooltips that came with the .9 update! It took me a while to get to it but now that I am there it's very flexible!
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5481 on: October 24, 2019, 03:38:38 PM »

How does one get loose .java files to become .class files?
I believe Starsector has it's own compiler or something?
(Please tell me I don't have to wade through either not-dumbed-down-enough tutorials or the internet in search of Java SDK 7)

Edit: And while I'm here, will this loop do what I think/hope it will? (Namely, testing if every entry between 0 and YunruCurrentCount is true)
Code
			if ((for (int i = 0; i < YunruCurrentCount; i++)  {
YunruCount[i] == true})) {
YunruCanBuild = true;
break;
}

BringerofBabies

  • Lieutenant
  • **
  • Posts: 98
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5482 on: October 24, 2019, 04:50:30 PM »

How does one get loose .java files to become .class files?
I believe Starsector has it's own compiler or something?
(Please tell me I don't have to wade through either not-dumbed-down-enough tutorials or the internet in search of Java SDK 7)

Edit: And while I'm here, will this loop do what I think/hope it will? (Namely, testing if every entry between 0 and YunruCurrentCount is true)
Code
			if ((for (int i = 0; i < YunruCurrentCount; i++)  {
YunruCount[i] == true})) {
YunruCanBuild = true;
break;
}

Fairly certain, based on everyone else's comments, that Starsector does not have its own compiler. I haven't ever used Java, but unless it is radically different from everything else under the sun, for loops aren't expressions that output a value, so that loop wouldn't work inside the if test. I think you want something like
Code
			for (int i = 0; i < YunruCurrentCount; i++)  {
        if (YunruCount[i] != true) {
                                    break;
                                }
                                else if (i == YunruCurrentCount - 1) {
    YunruCanBuild = true;
}
}
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5483 on: October 24, 2019, 05:40:02 PM »

Spoiler
Hmm - probably missing an import statement? Classes from other packages need to be imported before they can be used.

Something like:
import com.thoughtworks.xstream.XStream;

At the beginning of your file.

When I added that line, it only added another error beside it saying

Code
The import com.thoughtworks.xstream.XStream cannot be resolved

I also noticed something when I tried to remove some imports to find out which one was causing it, and it turned out to be 'BaseModPlugin'. When I removed that one line, the error on the first line disappeared, although several errors appeared farther down into the file...

Oh, and the full error I got was actually:

Code
The type com.thoughtworks.xstream.XStream cannot be resolved. It is indirectly referenced from required .class files

But none of the code I have so far uses XStream.

Just in case it might be related, apart from the libraries the Eclipse tutorial said to include, I've also imported MagicLib, Lazy Lib and Graphics Lib.
[close]

Ahh, I'm sorry - this probably isn't the best thread for these kinds of questions, which likely entail a back-and-forth, and is not really about Starsector-specific things as such. Plus the thread moves kind of fast. I think you're more likely to get help by posting this in a separate thread; it'll be a lot easier.

(FWIW, these errors sound like some jars not having been added to your project's build path in whatever IDE you're using.)

Not really a question but not sure where else to post this. Thank you very much for the addition of custom data to the weapon tooltips that came with the .9 update! It took me a while to get to it but now that I am there it's very flexible!

Thank you!

How does one get loose .java files to become .class files?
I believe Starsector has it's own compiler or something?

Stuff under data/scripts and below that will be compiled on startup using the Janino 3rd party compiler. It's got some limitations and it's a bit slow.

(Please tell me I don't have to wade through either not-dumbed-down-enough tutorials or the internet in search of Java SDK 7)

I'd highly recommend that if you're at all serious about having code in your mods. It's better all-around, both as far as just using an IDE and as far as having more capabilities and having a shorter startup time when you run the game (since stuff will be pre-compiled by you into a jar.)
« Last Edit: October 24, 2019, 05:41:34 PM by Alex »
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5484 on: October 24, 2019, 06:02:52 PM »

Okay now I'm getting a weird error.
Code
Caused by: java.lang.ClassNotFoundException: Parsing compilation unit 'data.scripts.FarmingMult'
at org.codehaus.janino.JavaSourceIClassLoader.findIClass(JavaSourceIClassLoader.java:172)
at org.codehaus.janino.IClassLoader.loadIClass(IClassLoader.java:254)
at org.codehaus.janino.JavaSourceClassLoader.generateBytecodes(JavaSourceClassLoader.java:214)
at org.codehaus.janino.JavaSourceClassLoader.findClass(JavaSourceClassLoader.java:178)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Caused by: org.codehaus.commons.compiler.CompileException: Compilation unit 'data.scripts.FarmingMult' does not declare a class with the same name
Which'd be normal if not for the fact that thing starts
Code
public class FarmingMult extends BaseIndustry implements MarketImmigrationModifier {

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5485 on: October 24, 2019, 06:20:45 PM »

Missing package declaration maybe?

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5486 on: October 24, 2019, 06:25:54 PM »

Probably, I still have it at
package com.fs.starfarer.api.impl.campaign.econ.impl;
No idea what it should be for a loose script.

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5487 on: October 24, 2019, 06:41:01 PM »

In this case it should be:
Code: java
package data.scripts;
The package name corresponds to the file location.

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5488 on: October 24, 2019, 10:10:49 PM »


Ahh, I'm sorry - this probably isn't the best thread for these kinds of questions, which likely entail a back-and-forth, and is not really about Starsector-specific things as such. Plus the thread moves kind of fast. I think you're more likely to get help by posting this in a separate thread; it'll be a lot easier.

(FWIW, these errors sound like some jars not having been added to your project's build path in whatever IDE you're using.)

Okay, I'll do so. Thanks.
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5489 on: October 25, 2019, 03:07:15 AM »

In this case it should be:
Code: java
package data.scripts;
The package name corresponds to the file location.
Thanks, that worked.

EDIT: Okay, here's a confusing one:
Code
Caused by: org.codehaus.commons.compiler.CompileException: File 'data/scripts/FarmingMult.java', Line 91, Column 20: Assignment conversion not possible from type "java.lang.Object" to type "java.lang.String"

But line 91 is vanilla code:
Code
			String commodity = ResourceDepositsCondition.COMMODITY.get(mc.getId());
Pages: 1 ... 364 365 [366] 367 368 ... 711