Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 444 445 [446] 447 448 ... 709

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

Hiroyan495

  • Lieutenant
  • **
  • Posts: 61
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6675 on: July 20, 2020, 07:57:31 AM »

Thanks a lot!  8)
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24103
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6676 on: July 20, 2020, 11:40:12 AM »

What's the AI difference of ships which have shield or not?

Not very much - some minor differences, I think (I don't remember the details) but generally it's very similar. I think it might be more likely to vent in some circumstances.

If I set the radius of shield to 0 in the combat, would the ship's act like the ship without shield?

No, definitely not.

And how to render weapons below the ship?

I don't *think* that's possible, but someone please correct me if I'm wrong.

Basically, I think the approach would be to have a decorative weapon that looks like a portion of the hull render above the weapon.
Logged

Cabbs

  • Ensign
  • *
  • Posts: 24
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6677 on: July 21, 2020, 12:51:26 AM »

I know there was a lot of discussion about convo highlights in this thread previously, but I can't find the answer I need.

Currently putting two strings into an addPara line then highlighting them:

textPanel.addPara("There are "+nowcreds+" Credits remaining, and this will take "+nowdays+" days to complete.");
textPanel.highlightInLastPara(HIGHLIGHT_COLOR, nowcreds, nowdays);

And this of course works fine with hard-coded strings I type. 

But when I use a formatter to make the strings from a float, this fails: the first string is highlighted but has extra whitespace in front, while the second string never highlights.  I have tried using a different formatter for each string etc, the other addPara highlight methods, and LabelAPI.setHighlight too.

How is the hardcode string different from the string made by the formatter? I thought they would be identical at the end.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24103
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6678 on: July 21, 2020, 09:33:23 AM »

Hmm - it would help to see what you're doing in the case that doesn't work.

(In case it's relevant: highlights require whitespace or punctuation around them, so e.g. you couldn't highlight half of a word, or some such.)
Logged

Cabbs

  • Ensign
  • *
  • Posts: 24
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6679 on: July 21, 2020, 11:52:22 AM »

Hmm - it would help to see what you're doing in the case that doesn't work.

(In case it's relevant: highlights require whitespace or punctuation around them, so e.g. you couldn't highlight half of a word, or some such.)

Alrighty then, here we go.  I'm pulling some data to calculate time and credits remaining, then displaying it to the user. The issue is the same when I access it later and the numbers change.

In this example I have manually set the strings at the end, so this displays how I want:

Spoiler

Code
                            float daysleft = thismarket.getMemoryWithoutUpdate().getExpire("$recruit_prog");
                            float credsleft = data.credits*(daysleft/data.days);
                           
                            Formatter formattera = new Formatter();
                            formattera.format("%, d", (int)daysleft);
                            String fmt_days = formattera.toString();
                           
                            Formatter formatterb = new Formatter();
                            formatterb.format("%, d", (int)credsleft);
                            String fmt_creds = formatterb.toString();

                            textPanel.addPara("Float Daysleft: "+daysleft);
                            textPanel.addPara("Float Credsleft: "+credsleft);
                           
                            textPanel.addPara("String nowdays: "+fmt_days);
                            textPanel.addPara("String nowcreds: "+fmt_creds);
                           
                            // SET MANUALLY
                            fmt_days = "120";
                            fmt_creds = "50,000";

                            textPanel.addPara("There are "+fmt_creds+" Credits remaining, and this will take "+fmt_days+" days to complete.");
                            textPanel.highlightInLastPara(HIGHLIGHT_COLOR, fmt_creds, fmt_days);
                           
                            textPanel.addPara("There are %s Credits remaining, and this will take %s days to complete.", HIGHLIGHT_COLOR, fmt_creds, fmt_days);
                            float daysleft = thismarket.getMemoryWithoutUpdate().getExpire("$recruit_prog");
                            float credsleft = data.credits*(daysleft/data.days);
                           
                            Formatter formattera = new Formatter();
                            formattera.format("%, d", (int)daysleft);
                            String fmt_days = formattera.toString();
                           
                            Formatter formatterb = new Formatter();
                            formatterb.format("%, d", (int)credsleft);
                            String fmt_creds = formatterb.toString();

                            textPanel.addPara("Float Daysleft: "+daysleft);
                            textPanel.addPara("Float Credsleft: "+credsleft);
                           
                            textPanel.addPara("String nowdays: "+fmt_days);
                            textPanel.addPara("String nowcreds: "+fmt_creds);
                           
                            // SET MANUALLY
                            fmt_days = "120";
                            fmt_creds = "50,000";

                            textPanel.addPara("There are "+fmt_creds+" Credits remaining, and this will take "+fmt_days+" days to complete.");
                            textPanel.highlightInLastPara(HIGHLIGHT_COLOR, fmt_creds, fmt_days);
                           
                            textPanel.addPara("There are %s Credits remaining, and this will take %s days to complete.", HIGHLIGHT_COLOR, fmt_creds, fmt_days);



[close]

Aaaand here is it not working:

Spoiler

Code
                            float daysleft = thismarket.getMemoryWithoutUpdate().getExpire("$recruit_prog");
                            float credsleft = data.credits*(daysleft/data.days);
                           
                            Formatter formattera = new Formatter();
                            formattera.format("%, d", (int)daysleft);
                            String fmt_days = formattera.toString();
                           
                            Formatter formatterb = new Formatter();
                            formatterb.format("%, d", (int)credsleft);
                            String fmt_creds = formatterb.toString();

                            textPanel.addPara("Float Daysleft: "+daysleft);
                            textPanel.addPara("Float Credsleft: "+credsleft);
                           
                            textPanel.addPara("String nowdays: "+fmt_days);
                            textPanel.addPara("String nowcreds: "+fmt_creds);

                            textPanel.addPara("There are "+fmt_creds+" Credits remaining, and this will take "+fmt_days+" days to complete.");
                            textPanel.highlightInLastPara(HIGHLIGHT_COLOR, fmt_creds, fmt_days);
                           
                            textPanel.addPara("There are %s Credits remaining, and this will take %s days to complete.", HIGHLIGHT_COLOR, fmt_creds, fmt_days);

                            float daysleft = thismarket.getMemoryWithoutUpdate().getExpire("$recruit_prog");
                            float credsleft = data.credits*(daysleft/data.days);
                           
                            Formatter formattera = new Formatter();
                            formattera.format("%, d", (int)daysleft);
                            String fmt_days = formattera.toString();
                           
                            Formatter formatterb = new Formatter();
                            formatterb.format("%, d", (int)credsleft);
                            String fmt_creds = formatterb.toString();

                            textPanel.addPara("Float Daysleft: "+daysleft);
                            textPanel.addPara("Float Credsleft: "+credsleft);
                           
                            textPanel.addPara("String nowdays: "+fmt_days);
                            textPanel.addPara("String nowcreds: "+fmt_creds);

                            textPanel.addPara("There are "+fmt_creds+" Credits remaining, and this will take "+fmt_days+" days to complete.");
                            textPanel.highlightInLastPara(HIGHLIGHT_COLOR, fmt_creds, fmt_days);
                           
                            textPanel.addPara("There are %s Credits remaining, and this will take %s days to complete.", HIGHLIGHT_COLOR, fmt_creds, fmt_days);



[close]

Extra space on the left of the first highlight, and no second highlight.

EDIT: whoops had the second image as private. fixed now
« Last Edit: July 21, 2020, 12:21:44 PM by Cabbs »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24103
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6680 on: July 21, 2020, 12:14:24 PM »

Hmm - the second image link seems broken.

formattera.format("%, d", (int)daysleft);

This seems like the issue has to do with how you're using the formatter. I'm not familiar with how the format string for it works, but provided you're getting the same output as the "manual" entered strings, the result would have to be the same. So if it's not, then the output isn't either... what you were saying about an extra space showing up seems to confirm that, too.
Logged

Cabbs

  • Ensign
  • *
  • Posts: 24
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6681 on: July 21, 2020, 12:33:58 PM »

Hmm - the second image link seems broken.

formattera.format("%, d", (int)daysleft);

This seems like the issue has to do with how you're using the formatter. I'm not familiar with how the format string for it works, but provided you're getting the same output as the "manual" entered strings, the result would have to be the same. So if it's not, then the output isn't either... what you were saying about an extra space showing up seems to confirm that, too.

Right on the money! cheers

It looks like the space I left in the Format string ("%, d") was the problem.  It caused the space to appear on the first highlight, and also stopped the second highlight entirely because reasons (???????)

Simply removing that space solved the issue:
formattera.format("%,d", (int)daysleft);

with that sorted, working code now shortened:
Spoiler
                            float daysleft = thismarket.getMemoryWithoutUpdate().getExpire("$recruit_prog");
                            float credsleft = data.credits*(daysleft/data.days);

                            String fmt_days = String.format("%,d", (int)daysleft);
                            String fmt_creds = String.format("%,d", (int)credsleft);
                           
                            textPanel.addPara("There are %s Credits remaining, and this will take %s days to complete.", HIGHLIGHT_COLOR, fmt_creds, fmt_days);
                           
[close]

« Last Edit: July 21, 2020, 12:39:38 PM by Cabbs »
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 #6682 on: July 21, 2020, 12:46:00 PM »

Personally, I've had more success with using the LabelAPI returned from addParagraph() than I have with setting highlights during the addPara() just in general. It's been too long since I wrote that code to quite remember why though.

I think part of it is that I wanted to use an array of both highlights and highlight colors.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24103
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6683 on: July 21, 2020, 12:57:06 PM »

Nice, glad you got it working!
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4680
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6684 on: July 22, 2020, 06:34:48 AM »

How do I change the background of a campaign battle? Calling MissionDefinitionAPI.setBackgroundSpriteName() in the BattleCreationPlugin doesn't seem to do anything.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24103
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6685 on: July 22, 2020, 10:17:30 AM »

Hmm - vanilla uses this method and it seems to work. I just tried:

loader.setBackgroundSpriteName("graphics/ships/onslaught/onslaught_base.png");

in BattleCreationPluginImpl and it did it.
Logged

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6686 on: July 22, 2020, 01:03:07 PM »

Why I can't deactivate my special defense system(right-click system) on a ship with modules?
« Last Edit: July 22, 2020, 01:17:05 PM by Originem »
Logged
My mods


Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24103
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6687 on: July 22, 2020, 01:18:55 PM »

Can/did you try it on a ship without modules to see if that's actually the issue? It doesn't seem to me like the ship having modules would factor into the right-click system's operation.
Logged

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6688 on: July 22, 2020, 01:31:30 PM »

Can/did you try it on a ship without modules to see if that's actually the issue? It doesn't seem to me like the ship having modules would factor into the right-click system's operation.
Well I tried to give vanilla phasecloak to the ship with modules, and it can't be deactivated too until the flux is full.
It seems that if there are entities(ships or modules) above the ship, PHASE_CLOAK won't be deactivated by player(gameplay in vanilla)
Logged
My mods


Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24103
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6689 on: July 22, 2020, 01:35:57 PM »

Ah, yes, if it's a phase cloak, that'll be a problem. But if it's another type of right-click system, it would be fine.

A phase cloak isn't going to work with a ship with modules; among other things it's not going to phase the modules. But, yeah, it'll also be unable to unphase; let me change that on my end. If the modules were set to "fighter" it'd be able to unphase, btw, but that could be undesirable for other reasons...
Logged
Pages: 1 ... 444 445 [446] 447 448 ... 709