#(obviously :P) Now, I don't know how

1 messages ยท Page 1 of 1 (latest)

glacial sundial
#

the actual inserting stuff is as follows, it works like this for the non-vehicle storage

    {
        if(!storage)
        {
            Print("no storage");
            return;
        }
        
        
        if(!storageManager && !vehStorageManager)
        {
            Print("no manager");
            return;
        }
        
        if (!Replication.IsServer())
            return;
    
        if(amountAdded < amountToAdd)
        {
            
            if(storageManager)
            {
                for(int x = 0; x < amountToAdd ; x++)
                {
                    
                    ZEL_TierData spawn = chosenItem();
                
                    ResourceName m_Resource = "{E8F00BF730225B00}Prefabs/Weapons/Grenades/Grenade_M67.et";
                    //spawn.m_sPrefab;
                    Print(m_Resource);
    
                    
                    amountAdded ++;
                    Print(amountAdded);
                    Print(storageManager.TrySpawnPrefabToStorage(m_Resource));
                    Print("Inserting to storage");
                    
                    
                    bool result = storageManager.TrySpawnPrefabToStorage(m_Resource);
                    PrintString(m_Resource + " stored?:" + result);
                    
                }
            }
#

the function runs in EOnInit

scarlet forum
#

storageManager =//= Vech storageManager

glacial sundial
#

sorry, that's a bit of old code I didn't update yet..

#

storageManager = ScriptedInventoryStorageManagerComponent.Cast(owner.FindComponent(ScriptedInventoryStorageManagerComponent));

#

this returns whatever the storage manager type is on the entity, so is universal.

I have a print on init that shows it found the vehicle manager:
ScriptedInventoryStorageManagerComponent storageManager = SCR_VehicleInventoryStorageManagerComponent<0x0000023B484F2C30>

scarlet forum
#

Except thats not how it works ๐Ÿ˜›

glacial sundial
#

well I was told it does, as ScriptedInventoryStorageManagerComponent is the parent class of the other managers ๐Ÿ˜…

the same code also didn't work when I exclusively found the veh manager

scarlet forum
#

Parent yes, but child has new stuff - hence childs

glacial sundial
#

but it finds the vehicle storage component ๐Ÿค”

scarlet forum
#

Swap it out, or cast it down. Minimize your potential for errors.

#

Finding it sure, but I dunno if it "acts" like it - it should act like the parent

#

Children casted to the parent, just has "less features" and runs the parents code, but retain the size and contents, just it become 'unaccessable'.

glacial sundial
#

will revert my code back, i changed to that to avoid bloating with checking for if it's vehicle or standard

scarlet forum
#

Yea, you'll have to do a "Does this cast work?" - I'm a vech. elseif "Does this one work?" - I'm everything else

glacial sundial
#

yeah I had it casting first to inv storage manager, then if that wasn't found cast to veh inv manager

scarlet forum
#

Fixed now?

glacial sundial
#

still tweaking, will let you know

scarlet forum
#

rgr. Meth is bad ๐Ÿ˜›

glacial sundial
#

nope still nothing blobdoggoshruggoogly

#

refactored code:

    {
        if(!storage)
        {
            Print("no storage");
            return;
        }
        
        
        if(storageManager == null && vehStorageManager == null)
        {
            Print("no manager");
            return;
        }
        
        if (!Replication.IsServer())
            return;
    
        if(amountAdded < amountToAdd)
        {
                
            if(vehStorageManager != null)
            {
                for(int x = 0; x < amountToAdd ; x++)
                {
                
                ZEL_TierData spawn = chosenItem();
                
                    ResourceName m_Resource = "{E8F00BF730225B00}Prefabs/Weapons/Grenades/Grenade_M67.et";
                    //spawn.m_sPrefab;
                    Print(m_Resource);
    
                    
                    amountAdded ++;
                    Print(amountAdded);
                    Print(vehStorageManager.TrySpawnPrefabToStorage(m_Resource));
                    Print("Inserting to vehicle");
                            
                    bool result = vehStorageManager.TrySpawnPrefabToStorage(m_Resource);
                    PrintString(m_Resource + " stored?:" + result);

                }
            }

        }
    }```
scarlet forum
#

Just FYI this would inject twice.

glacial sundial
#

i have no idea why your veh storage works and mine doesn't, code wise they seem pretty much the same apart from I'm doing it on the owner, maybe too quickly?

oh how come?

scarlet forum
#

But that aside, this code is being run and comes back true?

#

vehStorageManager.TrySpawnPrefabToStorage(m_Resource) is a action, and you have it in a print

glacial sundial
#

ah gotcha, didn't realise print would actually run it

scarlet forum
#

I mean, how does it get the value then? ๐Ÿ˜›

glacial sundial
#

well yeah I just didn't think it actioned it fully, assume it would jut "fake" it for debug or something :p but yeah it returns true looking at the prints

  SCRIPT       : int amountAdded = 1
  SCRIPT       : 1
  SCRIPT       : Inserting to vehicle
  SCRIPT       : string s =    '{E8F00BF730225B00}Prefabs/Weapons/Grenades/Grenade_M67.et stored?:true'``
scarlet forum
#

vehStorageManager is the correct one and casted like mine?

glacial sundial
#

should be, that's run on init via:

        Print(storageManager);
        
        if(storageManager == null)
        {
            vehStorageManager = SCR_VehicleInventoryStorageManagerComponent.Cast(owner.FindComponent(SCR_VehicleInventoryStorageManagerComponent));
            Print(vehStorageManager);
        }```
#

the prints suggest it works:
SCRIPT : SCR_InventoryStorageManagerComponent storageManager = NULL SCRIPT : SCR_VehicleInventoryStorageManagerComponent vehStorageManager = SCR_VehicleInventoryStorageManagerComponent<0x0000023A616DB470>

scarlet forum
#

and owner must be a vech, or it would fail so thats all good. aside from that ifstatement logic, but this is scratch code, so we will overlook it ๐Ÿ˜›

#

And owner is getting set via oninit you said, of what the comp?

glacial sundial
#

is it worth adding a short delay to the insertToStorage() function? It's called at the end of EOnInit but could it still be too slow?

Yeah it's on a custom comp on the vehicle entity itself

and you meaning because I used == null instead of !storagemanager? ๐Ÿ‘€

scarlet forum
#

Na the if statement if not container, just assumes vech, which can also fail

glacial sundial
#

ahh I guess, but I only intend for this comp to be used with either/or of those so shouldn't

scarlet forum
#

The delay wouldn't matter, if comps wouldn't exist it would fail

#

So an attached comp should grab the proper owner, and this "add" code is being triggered right at start?

glacial sundial
#

yep, comp is attached to a vehicle (or object in the other case) that isn't spawned, then on that vehicle being spawned it runs the "add" stuff

#

it works completely fine just not on a vehicle for some reason

scarlet forum
#

Maybe try a delay. Maybe it lies, and says everything is fine, but its to early. Doubtful, but I can't see off hand what the issue is. The code is 2 lines, and it is succeeding.

#

when you hit tab and look at the trunk, nothing there?

glacial sundial
#

nope nothing there

#

trying with a delay now

scarlet forum
#

and its a non custom vech, aside from your comp?

glacial sundial
#

yup, just the basic ural + cargo open aside from my comp + changes to the inventory capacity stuff and removing a faction affiliation component

#

it was the delay

#

added a 50ms call later and grenades are there

scarlet forum
#

Its likely the faction comp. I just deleted it and it broke my code.

#

Things rely on things and when debugging, same things need to say same, beause its the changes/differences is why it doesn't work ๐Ÿ˜›

#

but at least the delay is a work around I guess ๐Ÿ˜›

glacial sundial
#

well that's weird then, because adding the delay worked for me rather than inserting during the oninit...

scarlet forum
#

I'll see if I can do the same

glacial sundial
#

why would inv need a faction comp? It doesn't for boxes, seems like an odd requirement for vehicles

but yeah the delay has worked for me for whatever reason

scarlet forum
#

Well you could walk thought the code, but VechManager is not UniManager - its not same code, the same reason your parent problem

glacial sundial
#

rather annoying how simple a thing that was in the end, I've spent so long trying to figure out why it didn't work. I'm 90% sure i tried with a faction comp before and it was the same outcome but maybe I'm mistaken

it also doesn't make sense why the delay would work if it needed a faction comp blobdoggoshruggoogly

scarlet forum
#

Weird. Mine is totally broken now ๐Ÿ˜› - so maybe its not that. Could be the "breaking of the prefab" but shouldn't be

#

Just tested it. So breaking the prefab breaks the system. Very odd, must have some underlying attachment code.

#

The delay made no impact on pre-break, and no weapons showed post delay break.

#

I'll double check faction, just for learning.

#

Neat. So without the faction + delay it works. I suspect your problem is you broke the prefab to remove the faction and this has a "feature" that makes the default code unhappy

#

So just to wrap this up, it looks like it's the breaking of the prefab. The delay didn't make any difference on my end. But of course I can't test two perfectly, because I have to break the prefab to get rid of the faction. I changed it to another class, disabled it and set it to none - and that still passed.

Anyways. These are the worst kind of features. At least we figured it out eventually and you can move on and do what you got to do.

glacial sundial
#

yeah sounds like a lot of random fuckery that makes no real indication as to what broke or why delay fixed it ๐Ÿ˜‚ just enfusion things I guess (or a bug in the system), thanks for taking the time to troubleshoot though and i guess something to keep in mind in future haha

scarlet forum
#

As the old adage goes. Embrace the suck ๐Ÿ˜‚

warm vault
#
ScriptedInventoryStorageManagerComponent  InvManComp = ScriptedInventoryStorageManagerComponent.Cast(owner.FindComponent(ScriptedInventoryStorageManagerComponent));
#

Find component gets the component of that type, regardless of what is is further down the hierarchy

#

FindComponent(ScriptedInventoryStorageManagerComponent)

#

will return a SCR_VehicleInventoryStorageManagerComponent or a SCR_InventoryStorageManagerComponent

#

depending on what youi're callin it on