Author Topic: generator.AddItemToSpecifiedContainer() giving me an error  (Read 1676 times)

loudent

  • Full Member
  • ***
  • Posts: 141
    • View Profile
generator.AddItemToSpecifiedContainer() giving me an error
« on: April 19, 2015, 05:20:42 pm »
Hey All,

Once again I have a question regarding scripting. In this script I'm creating a container with:
        var id = generator.AddContainer(system_id, coords.x, coords.y, "crate_01", "droplist_prefab_cargo_01");

This successfully creates the container and it has an item from the droplist. Then I'm adding to the contents of the cointainer:
        generator.AddItemToSpecifiedC ontainer(id, "ore_glepsite", 100);

And am getting the following errors

Exception System.NullReferenceException: Object reference not set to an instance of an object.
   -------------------------stack-------------------------
   at rnA5O51oAmWki8OOWMc.aQgYqT15s xbFCsxqoXP.MKGC106AoI(String  , UInt16  , UInt32  )
   at AtomicTorch.SpaceRPG.Server.S cripting.GlobalScopes.ScopeGe nerator.AddItemToSpecifiedCon tainer(Int32 container_id, String item_type, Int32 quantity)
   at binder_for_AtomicTorch.SpaceR PG.Server.Scripting.GlobalSco pes.ScopeGenerator.AddItemToS pecifiedContainer(ScriptEngine , Object , Object[] )
   at Jurassic.Compiler.Binder.Call(ScriptEngine engine, Object thisObject, Object[] arguments)
   at Jurassic.Library.ClrFunction. CallLateBound(Object thisObject, Object[] arguments)
   at Jurassic.Library.FunctionInst ance.CallWithStackTrace(String path, String function, Int32 line, Object thisObject, Object[] argumentValues)
   at LDTOnShipDestroyedHandler(ScriptEngine , Scope , Object , FunctionInstance , Object[] )
   at Jurassic.Library.UserDefinedF unction.CallLateBound(Object thisObject, Object[] argumentValues)
   at Jurassic.ScriptEngine.CallGlo balFunction(String functionName, Object[] argumentValues)
   at nU9kl611aPOvHoTVi1k.VbN3XJ1PD hia7P4WrTi.fKNZ6qRgJm(String  , Object  )


Any ideas,
-Loudent

ai_enabled

  • AtomicTorch Founder
  • Hero Member
  • *****
  • Posts: 1317
    • View Profile
Re: generator.AddItemToSpecifiedContainer() giving me an error
« Reply #1 on: April 19, 2015, 09:15:37 pm »
Hello!
It seems the AddItemToSpecifiedContainer() cannot find the container by the specified ID (the error message will be improved in the next build).
What the result of generator.AddContainer() function call? If it zero, that means the container is not created.

loudent

  • Full Member
  • ***
  • Posts: 141
    • View Profile
Re: generator.AddItemToSpecifiedContainer() giving me an error
« Reply #2 on: April 19, 2015, 09:25:26 pm »
The return was a non-zero id.

I know the call to create the container was successful because I saw the container in the game. It's simply that it doesn't allow me to add anything to it.

although, perhaps that's the nature of those types of container. It spawns with  whatever is in there and that's it?

ai_enabled

  • AtomicTorch Founder
  • Hero Member
  • *****
  • Posts: 1317
    • View Profile
Re: generator.AddItemToSpecifiedContainer() giving me an error
« Reply #3 on: April 19, 2015, 09:56:33 pm »
No, you should be able to add items to the container.
That's strange. Could you provide me a script/mod please?

loudent

  • Full Member
  • ***
  • Posts: 141
    • View Profile
Re: generator.AddItemToSpecifiedContainer() giving me an error
« Reply #4 on: April 19, 2015, 10:44:13 pm »
Honestly there's not much more than what I posted here. the script exists mostly to test how to do it but you can find the whole thing at:

https://www.dropbox.com/s/bqsyfyigsqxvlpy/JetCargoOnDeath.zip?dl=0