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] 2

Author Topic: [Scripting/Questing] How make intel entry invisible + more  (Read 1766 times)

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
[Scripting/Questing] How make intel entry invisible + more
« on: November 15, 2019, 04:51:00 PM »

I'm currently in the middle of making a quest but I want to release a patch. However, I'm running into some issues and one of them is that when I add intel to Intel Manager, I don't know how to make it invisible. That is, it shows up immediately upon starting the game.

The quest is far from even functional, so I want to hide it in the meantime.

On the same topic, I *think* if I don't add the intel to intel manager, its state isn't saved when the player reloads the game? Maybe? I'm not too sure. On that note, I also have these lines when initializing the NPCs involved so I the rules in rules.csv can find them:

Code
this.rina.getMemoryWithoutUpdate().set("$mvt_isRina", true);

But do those get saved when the user loads the game later? Or do I need to keep setting them on game start?

And sorry if I'm going about the completely wrong way - I'm pretty much grasping in the dark with the quest system! :P
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23990
    • View Profile
Re: [Scripting/Questing] How make intel entry invisible + more
« Reply #1 on: November 15, 2019, 04:57:14 PM »

The memory stuff gets saved. Or, rather - values in memory expire after a number of days that the "expire" parameter is set to. The set() method you're calling doesn't take an expire parameter and it defaults to -1, which means "do not expire".

As far as making intel hidden - there's an isHidden() method you can override. You could also just not add the intel to the IntelManager until you want the player to see it.
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: [Scripting/Questing] How make intel entry invisible + more
« Reply #2 on: November 15, 2019, 05:13:12 PM »

The memory stuff gets saved. Or, rather - values in memory expire after a number of days that the "expire" parameter is set to. The set() method you're calling doesn't take an expire parameter and it defaults to -1, which means "do not expire".

As far as making intel hidden - there's an isHidden() method you can override. You could also just not add the intel to the IntelManager until you want the player to see it.
Thanks! I'm glad to know that those get saved

<rest of the message gone because I goofed up and can't remember what I wrote>
« Last Edit: November 15, 2019, 05:31:00 PM by creature »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23990
    • View Profile
Re: [Scripting/Questing] How make intel entry invisible + more
« Reply #3 on: November 15, 2019, 05:21:28 PM »

If you're getting a crash, the #1 most helpful thing to see is the stack trace from the log! The code is also handy to see but only as an adjunct to the stack trace, if that makes sense. The stack trace tells me (and you) where something went wrong, where the code, like, I'd need to carefully read all of it to see if anything might not be quite right, and that's waaaay more time consuming.
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: [Scripting/Questing] How make intel entry invisible + more
« Reply #4 on: November 15, 2019, 05:29:29 PM »

Oh God, instead of posting a reply, I edited my last message instead....  :o

The memory stuff gets saved. Or, rather - values in memory expire after a number of days that the "expire" parameter is set to. The set() method you're calling doesn't take an expire parameter and it defaults to -1, which means "do not expire".

As far as making intel hidden - there's an isHidden() method you can override. You could also just not add the intel to the IntelManager until you want the player to see it.

Ah, I'm sorry, I misspoke! I wasn't getting a crash, but the save would no longer work (but I still remain in the main menu). There is a log that it displays, though I couldn't really make sense of it. Something about security?

This was a test save, by the way, with minimal mods, fresh from creating a new game (and basically the save I was trying to load was the same save that the game automatically creates when making a character)
Spoiler

Code
---- Debugging information ----
cause-exception     : java.lang.SecurityException
cause-message       : File access and reflection are not allowed to scripts.
class               : org.apache.log4j.helpers.QuietWriter
required-type       : org.apache.log4j.helpers.QuietWriter
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
line number         : 89004
class[1]            : org.apache.log4j.ConsoleAppender
class[2]            : java.util.Vector
converter-type[1]   : com.thoughtworks.xstream.converters.collections.CollectionConverter
class[3]            : org.apache.log4j.helpers.AppenderAttachableImpl
class[4]            : org.apache.log4j.spi.RootLogger
class[5]            : org.apache.log4j.Logger
class[6]            : data.campaign.intel.events.MivitTheGreatIntel
class[7]            : java.util.LinkedHashMap
converter-type[2]   : com.thoughtworks.xstream.converters.collections.MapConverter
class[8]            : com.fs.starfarer.campaign.rules.Memory
class[9]            : com.fs.starfarer.rpg.Person
class[10]           : com.fs.starfarer.campaign.CommDirectoryEntry
class[11]           : java.util.ArrayList
class[12]           : com.fs.starfarer.campaign.CommDirectory
class[13]           : com.fs.starfarer.campaign.econ.Market
class[14]           : com.fs.starfarer.campaign.econ.reach.ReachEconomy
class[15]           : com.fs.starfarer.campaign.econ.reach.ReachEconomyStepper
class[16]           : com.fs.starfarer.campaign.econ.Economy
class[17]           : com.fs.starfarer.campaign.CampaignPlanet
class[18]           : com.fs.util.container.repo.ObjectRepository
class[19]           : com.fs.starfarer.campaign.StarSystem
class[20]           : com.fs.starfarer.campaign.StarSystem$UpdateFromHyperspaceLocation
class[21]           : com.fs.starfarer.campaign.BaseLocation$LocationToken
class[22]           : com.fs.starfarer.campaign.Hyperspace
class[23]           : com.fs.starfarer.campaign.CampaignEngine
converter-type[3]   : com.fs.starfarer.campaign.save.I
version             : not available
-------------------------------
com.thoughtworks.xstream.converters.ConversionException:
---- Debugging information ----
cause-exception     : java.lang.SecurityException
cause-message       : File access and reflection are not allowed to scripts.
class               : org.apache.log4j.helpers.QuietWriter
required-type       : org.apache.log4j.helpers.QuietWriter
converter-type      : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
line number         : 89004
class[1]            : org.apache.log4j.ConsoleAppender
class[2]            : java.util.Vector
converter-type[1]   : com.thoughtworks.xstream.converters.collections.CollectionConverter
class[3]            : org.apache.log4j.helpers.AppenderAttachableImpl
class[4]            : org.apache.log4j.spi.RootLogger
class[5]            : org.apache.log4j.Logger
class[6]            : data.campaign.intel.events.MivitTheGreatIntel
class[7]            : java.util.LinkedHashMap
converter-type[2]   : com.thoughtworks.xstream.converters.collections.MapConverter
class[8]            : com.fs.starfarer.campaign.rules.Memory
class[9]            : com.fs.starfarer.rpg.Person
class[10]           : com.fs.starfarer.campaign.CommDirectoryEntry
class[11]           : java.util.ArrayList
class[12]           : com.fs.starfarer.campaign.CommDirectory
class[13]           : com.fs.starfarer.campaign.econ.Market
class[14]           : com.fs.starfarer.campaign.econ.reach.ReachEconomy
class[15]           : com.fs.starfarer.campaign.econ.reach.ReachEconomyStepper
class[16]           : com.fs.starfarer.campaign.econ.Economy
class[17]           : com.fs.starfarer.campaign.CampaignPlanet
class[18]           : com.fs.util.container.repo.ObjectRepository
class[19]           : com.fs.starfarer.campaign.StarSystem
class[20]           : com.fs.starfarer.campaign.StarSystem$UpdateFromHyperspaceLocation
class[21]           : com.fs.starfarer.campaign.BaseLocation$LocationToken
class[22]           : com.fs.starfarer.campaign.Hyperspace
class[23]           : com.fs.starfarer.campaign.CampaignEngine
converter-type[3]   : com.fs.starfarer.campaign.save.I
version             : not available
-------------------------------
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:73)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:98)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:91)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:85)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:80)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:73)
at com.thoughtworks.xstream.converters.collections.MapConverter.putCurrentEntryIntoMap(MapConverter.java:110)
at com.thoughtworks.xstream.converters.collections.MapConverter.populateMap(MapConverter.java:98)
at com.thoughtworks.xstream.converters.collections.MapConverter.populateMap(MapConverter.java:92)
at com.thoughtworks.xstream.converters.collections.MapConverter.unmarshal(MapConverter.java:87)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:73)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:98)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:91)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:85)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:80)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:73)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:98)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:91)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:85)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:80)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:73)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:98)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:91)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:85)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:80)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:73)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.addCurrentElementToCollection(CollectionConverter.java:98)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:91)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.populateCollection(CollectionConverter.java:85)
at com.thoughtworks.xstream.converters.collections.CollectionConverter.unmarshal(CollectionConverter.java:80)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshallField(AbstractReflectionConverter.java:503)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:429)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:70)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1486)
at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1466)
at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1346)
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.campaign.save.CampaignGameManager.super(Unknown Source)
at com.fs.starfarer.title.TitleScreenState.menuItemSelected(Unknown Source)
at com.fs.starfarer.title.Object.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.newnew.buttonPressed(Unknown Source)
at com.fs.starfarer.ui.I.?00000(Unknown Source)
at com.fs.starfarer.ui.I.processInput(Unknown Source)
at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.SecurityException: File access and reflection are not allowed to scripts.
at com.fs.starfarer.loading.scripts.new.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:79)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)
at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)
at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)
at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:79)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)
at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:74)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)
at com.thoughtworks.xstream.mapper.SecurityMapper.realClass(SecurityMapper.java:71)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:125)
at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:47)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:424)
at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:281)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
... 207 more
[close]
« Last Edit: November 15, 2019, 05:44:30 PM by creature »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23990
    • View Profile
Re: [Scripting/Questing] How make intel entry invisible + more
« Reply #5 on: November 15, 2019, 05:32:17 PM »

Weeeeell, now I can't see the code :) But basically it looks like your code is using some method(s) that are not allowed by the Starsector script loader, for safety reasons.

"File access and reflection are not allowed to scripts." is the message that pops up when this is the case.
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: [Scripting/Questing] How make intel entry invisible + more
« Reply #6 on: November 15, 2019, 05:41:52 PM »

Weeeeell, now I can't see the code :) But basically it looks like your code is using some method(s) that are not allowed by the Starsector script loader, for safety reasons.

"File access and reflection are not allowed to scripts." is the message that pops up when this is the case.

I'm really sorry, I'm fairly scatterbrained right now, trying to finalize the patch while ironing out some bugs and trying to hide the traces of future stuff that shouldn't be seen yet...  :'(

Here is the code I deleted above:

This is from my Mod Plugin:
Spoiler
Code
	@Override
public void onNewGameAfterEconomyLoad() {

this.caparice =  Global.getSector().getEconomy().getMarket("yrxp_caparice");
if (this.caparice != null) {
this.caparice.setName("Heisel Trading Post");

this.aya = Global.getFactory().createPerson();
this.aya.setFaction("yrxp");
this.aya.setGender(Gender.FEMALE);
this.aya.setRankId(Ranks.FACTION_LEADER);
this.aya.setPostId(Ranks.POST_FACTION_LEADER);
this.aya.getName().setFirst("Ayame");
this.aya.getName().setLast("Ringelblume");
this.aya.setPortraitSprite(Global.getSettings().getSpriteName("characters", "ayame"));
this.aya.getStats().setSkillLevel(Skills.FLEET_LOGISTICS, 3);
this.aya.getStats().setSkillLevel(Skills.PLANETARY_OPERATIONS, 3);

this.caparice.setAdmin(this.aya);  /* sets the person as colony admin, you don't need this */
this.caparice.getCommDirectory().addPerson(this.aya, 0);
this.caparice.addPerson(this.aya);

this.rina = Global.getFactory().createPerson();
this.rina.setFaction("yrxp");
this.rina.setGender(Gender.FEMALE);
this.rina.setRankId(Ranks.POST_TRADER);
this.rina.setPostId(Ranks.POST_TRADER);
this.rina.getName().setFirst("Rina");
this.rina.getName().setLast("Ririncanshiina");
this.rina.setPortraitSprite(Global.getSettings().getSpriteName("characters", "rina"));

this.caparice.getCommDirectory().addPerson(this.rina, 1);
this.caparice.addPerson(this.rina);
this.rina.getMemoryWithoutUpdate().set("$mvt_isRina", true);

/* This is where I created the intel. I didn't add it to the Intel Manager so I could hide it from the HUD, but I'm now
* afraid that it might not be saved when the player loads the game.
*
* This is currently commented because I've narrowed it down as the cause of the not-loading-a-save-issue*/
// this.intel = new MivitTheGreatIntel(this.caparice.getPlanetEntity(), this.rina);
}
       
this.initializeEvents();
}

[close]
And because I've found (maybe) that removing the intel line also (seemingly) removed the loading issue, here is also the Intel - it's dirtily copied from the Red Planet quest Intel.
Spoiler
Code

package data.campaign.intel.events;

import java.awt.Color;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.PlanetAPI;
import com.fs.starfarer.api.campaign.RepLevel;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.TextPanelAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.impl.campaign.ids.Tags;
import com.fs.starfarer.api.impl.campaign.intel.BaseIntelPlugin;
import com.fs.starfarer.api.impl.campaign.rulecmd.AddRemoveCommodity;
import com.fs.starfarer.api.ui.SectorMapAPI;
import com.fs.starfarer.api.ui.TooltipMakerAPI;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.util.Misc.Token;

import org.apache.log4j.Logger;
public class MivitTheGreatIntel extends BaseIntelPlugin {
private Logger log = Global.getLogger(MivitTheGreatIntel.class);   
public static enum MVTStage {
TALK_TO_RINA,
GO_TO_PLANET,
DONE,
;
}

public static int FINISHED_XP = 20000;
public static int QUEST_STAGE_1_XP_REWARD = 200;

protected PlanetAPI planet;
protected PersonAPI rina;

protected MVTStage stage;
protected int pilotCredits;

public MivitTheGreatIntel(PlanetAPI planet, PersonAPI pilot) {
this.planet = planet;
this.rina = pilot;

Misc.makeImportant(pilot, "mvt");
MarketAPI market = planet.getMarket();
// market.addPerson(pilot);
// market.getCommDirectory().addPerson(pilot);

pilotCredits = 10000 + 1000 * Misc.random.nextInt(10);

pilot.getRelToPlayer().getRel();
pilot.getMemoryWithoutUpdate().set("$mvt_isPilot", true);
pilot.getMemoryWithoutUpdate().set("$mvt_eventRef", this);
// pilot.getMemoryWithoutUpdate().set("$mvt_credits", Misc.getDGSCredits(pilotCredits));

//Misc.makeImportant(planet, "saci");
//cache.getMemoryWithoutUpdate().set("$saic_eventRef", this);
//Global.getSector().addScript(this);

stage = MVTStage.TALK_TO_RINA;
}

@Override
protected void notifyEnded() {
super.notifyEnded();
Global.getSector().removeScript(this);

MarketAPI market = planet.getMarket();
market.removePerson(rina);
market.getCommDirectory().removePerson(rina);
Misc.makeUnimportant(planet, "mvt");
}



@Override
public boolean callEvent(String ruleId, InteractionDialogAPI dialog,
List<Token> params, Map<String, MemoryAPI> memoryMap) {
String action = params.get(0).getString(memoryMap);

CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet();
CargoAPI cargo = playerFleet.getCargo();
TextPanelAPI text = dialog.getTextPanel();
//MemoryAPI memory = planet.getMemoryWithoutUpdate();

MarketAPI market = planet.getMarket();

if (action.equals("prepare")) {

// pilot.getMemoryWithoutUpdate().set("$mvt_credits", Misc.getDGSCredits(pilotCredits), 0);
// pilot.getMemoryWithoutUpdate().set("$mvt_playerCredits", Misc.getDGSCredits(cargo.getCredits().get()), 0);
}
else if (action.equals("isGoodRelation")) {
log.info("Relation with Rina - " + rina.getRelToPlayer().getLevel());

return (rina.getRelToPlayer().getLevel() == RepLevel.FAVORABLE ||
rina.getRelToPlayer().getLevel() == RepLevel.FRIENDLY ||
rina.getRelToPlayer().getLevel() == RepLevel.WELCOMING ||
rina.getRelToPlayer().getLevel() == RepLevel.COOPERATIVE);
} else if (action.equals("finishMivitQuestline1")) {


Global.getSector().getIntelManager().addIntel(this, false, text);
Global.getSector().getPlayerPerson().getStats().addXP(QUEST_STAGE_1_XP_REWARD, dialog.getTextPanel());


// Misc.makeImportant(planet, "mvt");
stage = MVTStage.GO_TO_PLANET;
sendUpdate(MVTStage.GO_TO_PLANET, dialog.getTextPanel());
}

return true;
}

@Override
public void endAfterDelay() {
stage = MVTStage.DONE;
Misc.makeUnimportant(planet, "mvt");
super.endAfterDelay();
}

@Override
protected void notifyEnding() {
super.notifyEnding();
}


protected void addBulletPoints(TooltipMakerAPI info, ListInfoMode mode) {

Color h = Misc.getHighlightColor();
Color g = Misc.getGrayColor();
float pad = 3f;
float opad = 10f;

float initPad = pad;
if (mode == ListInfoMode.IN_DESC) initPad = opad;

Color tc = getBulletColorForMode(mode);

bullet(info);
boolean isUpdate = getListInfoParam() != null;

MarketAPI market = planet.getMarket();

if (stage == MVTStage.TALK_TO_RINA) {
info.addPara("Talk to the the Commodities Trader at %s", initPad, market.getFaction().getBaseUIColor(), market.getName());
} else if (stage == MVTStage.GO_TO_PLANET) {
info.addPara("Find Rina's friend.", initPad);
}

initPad = 0f;

unindent(info);
}


@Override
public void createIntelInfo(TooltipMakerAPI info, ListInfoMode mode) {
Color c = getTitleColor(mode);
info.setParaSmallInsignia();
info.addPara(getName(), c, 0f);
info.setParaFontDefault();
addBulletPoints(info, mode);

}

@Override
public void createSmallDescription(TooltipMakerAPI info, float width, float height) {
Color h = Misc.getHighlightColor();
Color g = Misc.getGrayColor();
Color tc = Misc.getTextColor();
float pad = 3f;
float opad = 10f;

if (stage == MVTStage.TALK_TO_RINA) {
info.addPara("You met the CEO of Ririncanshiina AG, who asked you to go on an errand. " +
"She looked to be hiding something from you, but the money was good and so you accepted her offer.", opad);
} else if (stage == MVTStage.GO_TO_PLANET) {
info.addPara("You've talked to the old spacer's pilot comrade and convinced " +
"them to divulge the location of the planet.", opad);
} else {
info.addPara("You've found the planet and uncovered its secret.", opad);
}

addBulletPoints(info, ListInfoMode.IN_DESC);

}

@Override
public String getIcon() {
return Global.getSettings().getSpriteName("intel", "red_planet");
}

@Override
public Set<String> getIntelTags(SectorMapAPI map) {
Set<String> tags = super.getIntelTags(map);
tags.add(Tags.INTEL_STORY);
tags.add(Tags.INTEL_EXPLORATION);
return tags;
}

@Override
public IntelSortTier getSortTier() {
return IntelSortTier.TIER_2;
}

public String getSortString() {
return "Black Lily";
}

public String getName() {
if (isEnded() || isEnding()) {
return "Red Planet - Completed";
}
return "The Black Lily";
}

@Override
public FactionAPI getFactionForUIColors() {
return super.getFactionForUIColors();
}

public String getSmallDescriptionTitle() {
return getName();
}

@Override
public SectorEntityToken getMapLocation(SectorMapAPI map) {
if (stage == MVTStage.TALK_TO_RINA) {
return planet.getMarket().getPrimaryEntity();
}
return planet;
}

@Override
public boolean shouldRemoveIntel() {
return super.shouldRemoveIntel();
}

@Override
public String getCommMessageSound() {
return getSoundMajorPosting();
}

}

[close]
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: [Scripting/Questing] How make intel entry invisible + more
« Reply #7 on: November 15, 2019, 05:46:29 PM »

Code
this.rina.getMemoryWithoutUpdate().set("$mvt_isRina", true);

Does this actually set the memory variable for you?? I am trying to do the same thing for the player and when I call this particular method it doesn't seem to function. It doesn't crash either, but the memory variable never shows up and can't be checked for in other scripts or rules.

Any help you can give would be amazing if it works for you. I gave up after a few days of trying to get it to work. I'll probably get back to it at some point.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23990
    • View Profile
Re: [Scripting/Questing] How make intel entry invisible + more
« Reply #8 on: November 15, 2019, 05:50:25 PM »

I'm not 100% sure but you've got this:
private Logger log = Global.getLogger(MivitTheGreatIntel.class);   

This should be static, otherwise the Logger object will end up in the savefile and that's really bad - who knows what else it might reference, it could be a real mess in there.

Code
this.rina.getMemoryWithoutUpdate().set("$mvt_isRina", true);

Does this actually set the memory variable for you?? I am trying to do the same thing for the player and when I call this particular method it doesn't seem to function. It doesn't crash either, but the memory variable never shows up and can't be checked for in other scripts or rules.

Any help you can give would be amazing if it works for you. I gave up after a few days of trying to get it to work. I'll probably get back to it at some point.

That should set the value in memory, yes. The core game does this in a ton of places, e.g. TutorialMissionIntel:

mainContact.getMemoryWithoutUpdate().set("$tut_mainContact", true);

That sort of thing, just used everywhere.
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: [Scripting/Questing] How make intel entry invisible + more
« Reply #9 on: November 15, 2019, 06:15:51 PM »

I'm not 100% sure but you've got this:
private Logger log = Global.getLogger(MivitTheGreatIntel.class);   

This should be static, otherwise the Logger object will end up in the savefile and that's really bad - who knows what else it might reference, it could be a real mess in there.

Ah! That might just have been it! I can't fiddle with it much more at the moment, but so long as it isn't crashing, then all well!

Again, thank you very much!
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: [Scripting/Questing] How make intel entry invisible + more
« Reply #10 on: November 15, 2019, 07:12:22 PM »

Ah, I forgot to ask - If, for example, a player starts a campaign where the Intel and stuff were *NOT* initialized (i.e. an old version).

How do I properly go about doing that?

I believe there's this:

Code
	public void onGameLoad(boolean newGame) {}

but can I safely do something like this?

Code
	@Override
public void onGameLoad(boolean newGame) {
this.intel = new MivitTheGreatIntel(this.caparice.getPlanetEntity(), this.rina);
}

And that line of code actually opens a few more questions - do these variables get saved in the plugin class? Such that after starting a new game (and this calling onNewGameAfterEconomyLoad() properly), when you load the game again and I call for these variables: this.intel, this.rina, this.caparice, etc. they'll all have values?

If not, how do I go about finding the intel and persons I initialized before? (Or those that weren't initialized if the player is coming from an older version)
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23990
    • View Profile
Re: [Scripting/Questing] How make intel entry invisible + more
« Reply #11 on: November 15, 2019, 07:51:05 PM »

Member variables in your ModPlugin should not refer to campaign data - well, they can, but you have to be *really* careful, and given what you're trying to do, you don't want to do it that way. There is only one ModPlugin instance, so this can't work - consider that over the course of a session, you might load multiple saved games. At best you'd end up with something that looks like it works but is a memory leak.

Basically: what ends up in the savefile is the entire object graph starting from the campaign engine, i.e. Global.getSector(). Your implementation of ModPlugin should not be part of that object graph (see: there only being one instance of it) and member variables in your ModPlugin implementation will not be in the savefile.

When you load a game, Global.getSector() gets replaced with the object graph from the savefile. The ModPlugin not being part of that, it won't be affected. Therefore if you have, say, a reference to intel there, it could easily refer to that intel *from another savegame*.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: [Scripting/Questing] How make intel entry invisible + more
« Reply #12 on: November 15, 2019, 09:16:54 PM »

That should set the value in memory, yes. The core game does this in a ton of places, e.g. TutorialMissionIntel:

mainContact.getMemoryWithoutUpdate().set("$tut_mainContact", true);

That sort of thing, just used everywhere.

Did you happen to see this feedback?

Spoiler
I set the isDone() return to false, but still no luck actually populating anything to memory. The RuntimeException does fire if I take away the memory check (like before) but if I comment that out and just leave the portion that is supposed to attach a variable to the player's memory it never shows up.

I even directly referenced TutorialMissionEvent and set the PersonAPI to protected like it is there.

Are there any examples I can reference where a memory variable is attached to the player rather than an entity PersonAPI?

I know it at least gets to this code:

Code

player = Global.getSector().getPlayerPerson();
        player.getMemoryWithoutUpdate().set("$PortraitsEnabled", false);


But that particular code doesn't seem to work while under EveryFrameScript.

I don't understand what I could be doing wrong. :( It seems rather straightforward on the surface.

Full script:
Code

package archeus.campaign.everyframescripts;

import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import com.fs.starfarer.api.util.Misc;
import archeus.rulecmd.SetPlayerPortraits;

import java.util.ArrayList;
import java.util.List;

public class CheckCommissionForPortraitLocks implements EveryFrameScript {
private IntervalUtil tracker = new IntervalUtil(0.05f, 0.1f);

    protected PersonAPI player;

public CheckCommissionForPortraitLocks() {
//player.getMemoryWithoutUpdate().is("$FactionOnlyPortraitsEnabled", true) &&
        player = Global.getSector().getPlayerPerson();
if (Misc.getCommissionFactionId() == null) {
resetPlayerPortraits();
}
}

public void advance(float amount) {
float days = Global.getSector().getClock().convertToDays(amount);
tracker.advance(days);
player = Global.getSector().getPlayerPerson();

//Global.getSector().getPlayerPerson().getMemoryWithoutUpdate().getBoolean("$player.FactionOnlyPortraitsEnabled")
if (tracker.intervalElapsed()) {
if (player.getMemoryWithoutUpdate().is("$FactionOnlyPortraitsEnabled", false) && Misc.getCommissionFactionId() == null) {
resetPlayerPortraits();
}
}
}

public void resetPlayerPortraits() {
        SetPlayerPortraits portraits = new SetPlayerPortraits();

List<Misc.Token> params = new ArrayList<Misc.Token>();
Misc.Token token = new Misc.Token("all", null);
params.add(0, token);
portraits.execute(null, null, params, null);

        player = Global.getSector().getPlayerPerson();
        player.getMemoryWithoutUpdate().set("$PortraitsEnabled", false);

        //throw new RuntimeException("Yep, it's running");
}

public boolean isDone() {
return false;
}

public boolean runWhilePaused() {
return false;
}
}


[close]

I understand you are very, very busy so no worries if so, but I've tried this very thing and it doesn't work for me. I wouldn't think that the player PersonAPI would be different from any other PersonAPI, but it seems to not work. I've used the exact same thing before for an entity-based PersonAPI and it seems to work fine.

Any chance the:

Code
    protected PersonAPI player;
    player = Global.getSector().getPlayerPerson();
    player.getMemoryWithoutUpdate().set("$PortraitsEnabled", false);

-wouldn't work to your knowledge? Sorry to be a pain, I just can't seem to find the issue. Is this a separate kind of memory than you would see under the "DumpMemory" option while in dev mode?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23990
    • View Profile
Re: [Scripting/Questing] How make intel entry invisible + more
« Reply #13 on: November 15, 2019, 09:40:05 PM »

(Made a note to take a look tomorrow!)
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: [Scripting/Questing] How make intel entry invisible + more
« Reply #14 on: November 15, 2019, 09:48:28 PM »

Thank you very much! Let me know if there is anything I can do to assist with more information. I would have isolated it out into a small mod if it was convenient, but that would require setting up an entirely new project for the jar to provide a control. I haven't messed with those settings on my (now outdated to boot) IntelliJ on my home PC in a while, and I'm worried about messing up my current project.

If that proves necessary I will attempt to do so on another machine if possible.
Logged
Pages: [1] 2