Author Topic: Is there a IMCache.GetValue and IMCache.SetValue?  (Read 452 times)

ninekorn

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Is there a IMCache.GetValue and IMCache.SetValue?
« on: February 03, 2018, 06:13:03 am »
Hi,

In the CaculateShip.js there is a bunch of IMCache.AddValue like:

Code: [Select]
IMCache.AddValue("maneuvering_value", 1 + lerp * 0.1);
Can we also access and modify those values IN-Game with the .js scripts?  I am trying to get more control over the drones NPC basic "settings". I've tried

Code: [Select]
IMCache.GetValue("maneuvering_value");
IMCache.SetValue("maneuvering_value",10);

var allEffects = ship.GetAllEffects();
var defaults = ship.GetDefaultEffects();
var invCache = ship.GetEquipmentCache(SHIP_ID);
var skillCache = ship.GetSkillsCache(SHIP_ID);
var buffsCache = ship.GetBuffsCache(SHIP_ID);

But only the ship.GetAllEffects() works... As in it doesn't debug an empty array. When I tried to debug the others, I get "undefined". So modifying the equipment values or skill values IN-Game doesn't seem to work for me right now. Even http://wiki.atomictorch.com/VoidExpanse/scope-ship states that we can use SetEquipmentValue like:

Code: [Select]
ship.SetEquipmentCacheValue(SHIP_ID, "maneuvering_value", 10);
var invCache = ship.GetEquipmentCache(SHIP_ID);

But even that debugs me "undefined" so I am not sure what else to try. There doesn't seem to be a template as to how to get access to those values anywhere on the web and the wiki page.  I've searched all the other Big Mods contents with Notepad++ and no other Modders used those settings in their scripts either.

Thanks in advance for the help!
nine
« Last Edit: February 03, 2018, 06:24:05 am by ninekorn »

Lurler

  • AtomicTorch Founder
  • Hero Member
  • *****
  • Posts: 1087
    • View Profile
Re: Is there a IMCache.GetValue and IMCache.SetValue?
« Reply #1 on: February 04, 2018, 09:33:32 pm »
Just to make sure - did you add all required dependencies for all of those functions/classes?

ninekorn

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Is there a IMCache.GetValue and IMCache.SetValue?
« Reply #2 on: February 04, 2018, 10:35:57 pm »
yes I did. I put include(IMCache.js); right there at the top of the script!  ;D

did I miss anything?

nine

ai_enabled

  • AtomicTorch Founder
  • Hero Member
  • *****
  • Posts: 1041
    • View Profile
Re: Is there a IMCache.GetValue and IMCache.SetValue?
« Reply #3 on: February 05, 2018, 12:27:13 pm »
IMCache is done on purpose in such way to build the "ship stats cache".

The cache re-calculation is expensive should not happen too often (ideally it should happen only once for every NPC ship - on spawn or savegame reload).

Basically, it's the "stats" parameters of the ship which are populated with by the scripts (with AddValue and MulValue methods) and then combined with other caches (such as weapons/equipment cache) and finalized. You should never use it in any other cases. I'm not even sure if you can override/extend it and use in other scripts (I mean it could break the code from CalculateShip.js).

Alas, VE was made in a big rush years ago (with 99% of these scripts written by a member of the team who left even before the release) and now it's all legacy code and incomplete documentation...