Recent Posts

Pages: 1 ... 8 9 [10]
91
Modding info / Re: Scripting API issue missing a function?
« Last post by ninekorn on July 20, 2017, 01:45:39 am »
Hey AI-Enable. If youre still working could I know how to access items from "itemsInCargo = items.GetItemsAndCargo(shop_container_id)". This gives me an array of objects. but nowhere i can find in the scripts how to go get the difference shop sections like "boosters" "devices" "hulls" etc. When I write a for loop to try and get them i get [object object] and when i do a double for loop to iterate through itemsInCargo[g] I get nothing. again. thats probably my lack of knowledge of javascript but still theres no explanation for that in the Scripting API unless I just didnt find it. You see Im creating this market Terminal where players will be able to access every shops in each system the moment they access that terminal. Right now I can select systems then stations then I get the "main" station container i guess then I thought I would get the different sections of the shops with that GetItemsAndCargo function. But it just returns "object object" all the time. Once I get those items I will incorporate buy/sell for the player to buy items from the other side of the galaxy. Im not there yet.

something like:
Code: [Select]
"itemsInCargo = items.GetItemsAndCargo(shop_container_id)".

for (i = 0; i < itemsInCargo.length; i++)
{
       console.Print(itemsInCargo[i]+ " " + " SHOPCONTAINERID");
}
then i dont know what?
92
Modding info / Re: Scripting API issue missing a function?
« Last post by ninekorn on July 19, 2017, 10:45:49 pm »
wow. it works. ive never used this type of iteration in c#. I didnt knew it even existed in javascript. thank you. I can now move on to getting the containers of the station.

Thanks again! your experience at coding shows. Ok i found the button for quoting scripts.
93
Modding info / Re: Scripting API issue missing a function?
« Last post by ai_enabled on July 19, 2017, 10:39:02 pm »
UPD. So it was parser which removed i in square brackets. Ok, next time use BB code for your code as I mentioned below.

Proper code:
Code: [Select]
// remove all system IDs from systemList which don't have any spacestations
for (var index = 0; index < systemList.length; index++)
{
     var systemId = systemList[index];
     var systemBases = game.GetSystemBases(systemId);
     if (systemBases.length == 0)
     {
         systemList.splice(index, 1);
         index--;
     }
}

(index-- is very important here: after splice it will point to the next element, but on the next iteration it will move even further - so you will skip next element in array after splicing it... index-- solves this)

BTW, please use the "code" BB tag when posting code snippets.
94
Modding info / Re: Scripting API issue missing a function?
« Last post by ninekorn on July 19, 2017, 10:04:39 pm »
 mmm. still not working. Ill keep searching for a solution.             

                systemList = generator.GetAllSystems();

      for (var i = 0; i< systemList.length;i++)
      {
         if (game.GetSystemBases(systemList) == !/\S/
         || game.GetSystemBases(systemList) == null
         || game.GetSystemBases(systemList) == " "
         || game.GetSystemBases(systemList) == ""
         || game.GetSystemBases(systemList) == undefined
         || game.GetSystemBases(systemList) == "undefined")
         {
            var indexToRemove0 = systemList.indexOf(systemList); ---- with dual closing brackets with i of course.
            systemList.splice(indexToRemove0,1);
         }

         var tempBasesArray = game.GetSystemBases(systemList); ---- with dual closing brackets with i of course.
         if (tempBasesArray.length === 0 || tempBasesArray.length == 0)
         {
            var indexToRemove0 = systemList.indexOf(tempBasesArray);
            systemList.splice(indexToRemove0,1);
         }
      }


EDIT: so weird. I must be doing something wrong because its still not working with this.

for (var i = 0; i< systemList.length;i++)
      {
         if (game.GetSystemBases(systemList) == !/\S/
         || game.GetSystemBases(systemList) == null
         || game.GetSystemBases(systemList) == " "
         || game.GetSystemBases(systemList) == ""
         || game.GetSystemBases(systemList) == undefined
         || game.GetSystemBases(systemList) == "undefined")
         {
            var indexToRemove0 = systemList.indexOf(systemList);---- with dual closing brackets with i of course.
            systemList.splice(indexToRemove0,1);
         }

         var tempBasesArray = game.GetSystemBases(systemList);---- with dual closing brackets with i of course.

         console.Print(tempBasesArray.length + " " + " stationListArray");

         if (tempBasesArray.length === 0 || tempBasesArray.length == 0)
         {
            if (tempBasesArray == systemList)    ---- with dual closing brackets with i of course.
            {
               var indexToRemove0 = systemList.indexOf(systemList);---- with dual closing brackets with i of course.
               systemList.splice(indexToRemove0,1);         
            }         
         }
         
      }
95
Modding info / Re: Scripting API issue missing a function?
« Last post by ninekorn on July 19, 2017, 09:48:03 pm »
 i had tried it in the past but it didnt work for some reasons. weird. Ill try it again. maybe i had done a typo or something. Thank you for pointing the solution out.
96
Modding info / Re: Scripting API issue missing a function?
« Last post by ai_enabled on July 19, 2017, 09:43:56 pm »
GetSystemBases() returns array.
In programming, if a method is expected to return an array, it must return an array even if it's empty. It could return null only in the case when it's explicitly mentioned about this in the method comment/description (but it's very rare and happens only if library highly optimized to reduce overhead as much as possible; usually it's cheap to return an empty array).

So it returns an empty array when there are no stations at the system. You need to simply check if the length of this array is zero.
97
Modding info / Re: Scripting API issue missing a function?
« Last post by ninekorn on July 19, 2017, 09:17:44 pm »
I've still got a problem trying to remove from the array all systems that have no stations. I know this is more related to Scripting knowlege but if you can help. It's for a new mod. So I have tried a lot of different functions and this one seems to almost be working but doesnt remove some systems that have no stations. I don't really understand why.

i could also put in game.GetSystemBases(systemList) != null && game.GetSystemBases(systemList) != undefined
it seems that the systems that have no stations are still logged as strings or something Inside the game.GetSystemBases function. its just weird. Im gonna keep trying some stuff but if anyones got any ideas I might be able to release this mod tonight. I gotta work hard though. Theres lots of stuff left to do in it.

                 for (var i = 0; i< systemList.length;i++)
      {
         if (game.GetSystemBases(systemList) == !/\S/)
         {
            var indexToRemove0 = systemList.indexOf(systemList);
            systemList.splice(indexToRemove0,1);
         }
      }

Edit: I tried
    game.GetSystemBases(systemList) == !/\S/
|| game.GetSystemBases(systemList) !=null
|| game.GetSystemBases(systemList) != " "
|| game.GetSystemBases(systemList) != "" 

but still got systems that are not beeing remove from the splice Method. Im still searching.

98
Modding info / Re: Scripting API issue missing a function?
« Last post by ninekorn on July 19, 2017, 02:13:10 am »
ok I will definitely look into it
99
Modding info / Re: Scripting API issue missing a function?
« Last post by ai_enabled on July 19, 2017, 02:08:55 am »
Sure, I'm glad to help.
There is a good example of this function:
Code: [Select]
core\data\topics\fanatics\fanatics_quest_reputation.js
Line 362: var shop_container_id = items.GetStationShopContainerId(stationId);
(then an item added to this container).
100
Modding info / Re: Scripting API issue missing a function?
« Last post by ninekorn on July 19, 2017, 02:07:04 am »
wow Notepad++ is powerful. I found itérations of items.GetStationShopContainer Id in the StarTrek mod files package. I will look into it! Thank you very much for this hint i know what tool to use now to search. I was typing ctrl+F Inside each script lol much needed upgrade ;D
Pages: 1 ... 8 9 [10]