Recent Posts

Pages: [1] 2 3 ... 10
1
General Discussions / Anyone using discord?
« Last post by Lurler on August 07, 2017, 09:35:18 pm »
Anyone is using discord on regular basis?
We are considering creating a server so we can join with you guys and have the possibility to talk in real time.
2
Ok, sent you the build with new scripting API methods.
3
Thank you so much! with this the drones will have a couple usefull functions Under their belt!

Im working on also fixing some stuff in the Galaxy Market Mod but for some reasons I can't find where the threading bug occurs. At least I seem to have fixed the quantities a player can buy and correct amount is transfered. I still need to test more though.

I also have a lag issue of 1-2 seconds when I first spawn my Drones. Im wondering if its just me using something i shouldnt in the code. I will investigate that.

I will check how to send a Google drive link tonight and ill then be able to send you the market mods consisting of 3 scripts for you guys at Atomic Torch to check it out before I release. I wont release it on steam workshop this week though.
4
Ok, I will send you a build with this new API method later.
5
yes exactly!
6
So, you need just an API method to get the crate containers nearby your ship - something like npc.GetAsteroidsByDistanceToN PC() but for crate containers?
7
Help section / I got a problem with finding containers that are near in script?!
« Last post by ninekorn on August 03, 2017, 07:24:06 pm »
Hi,

So im working on drone commands "utilities" like "go pickup containers that are near". But theres one big issue. Ive tried to find a function in the Scripting API that gives me access to all the objects tags in the system or all the objects in the system or all objects in scope but theres nothing like that in the Scripting API. So i've decided to search with Notepad++ all the scripts for any functions that started with "generator." and found generator.AreThereAnyObjects(sys_idNPC, direction.x, direction.y, 25, { except_ships: true}); and that turns out to give Boolean true or false. I thought at first it could be meaningless since i dont need booleans but more the ID of the Objects... So I went ahead and found out I just could do this function. It pretty much does the same as the original function but instead i limit the range to 1 unit and just use a ForLoop with 15 radius in +x -x +y -y to get me the exact position where there are objects. I thought that would solve my problem... Lol the thing is generator.AreThereAnyObjects() doesnt take into consideration containers... so im stuck.  It does give me the position of any other objects though except containers + even IF i had the containers position there doesnt seem to be a function that gives me the gameObjectID at coordx-coordy. so Id still be stuck. I can't get the containerID without the ObjectID and i cant get the ObjectID without a function to help me find those IDs. If generator.AreThereAnyObjects() would also consider containers and also returning the ID of the object it finds then bam we would have a function that does exactly ship.ScopeObjects that isnt in the Scripting API. helllpppp.

Code: [Select]
function goPickContainers()
{

var player_id = npc.GetTag(SHIP_ID, "ownerPlayerShipId");

var sys_idNPC = npc.GetCurrentSystemID(SHIP_ID);

var direction = ship.GetCoordinates(SHIP_ID);

for (var x = 0; x < 15; x++)
{
for (var y = 0; y < 15; y++)
{
var objectsID0 = generator.AreThereAnyObjects(sys_idNPC, direction.x+x, direction.y+y, 1, { except_ships: true});
var objectsID1 = generator.AreThereAnyObjects(sys_idNPC, direction.x-x, direction.y+y, 1, { except_ships: true});
var objectsID2 = generator.AreThereAnyObjects(sys_idNPC, direction.x+x, direction.y-y, 1, { except_ships: true});
var objectsID3 = generator.AreThereAnyObjects(sys_idNPC, direction.x-x, direction.y-y, 1, { except_ships: true});

if (objectsID0 == true)
{
npc.FaceCoord(SHIP_ID,direction.x+x,direction.y+y);
}
if (objectsID1 == true )
{
npc.FaceCoord(SHIP_ID,direction.x-x,direction.y+y);
}
if ( objectsID2 == true )
{
npc.FaceCoord(SHIP_ID,direction.x+x,direction.y-y);
}
if (objectsID3 == true)
{
npc.FaceCoord(SHIP_ID,direction.x-x,direction.y-y);
}
}
}
}



8
Help section / Re: Trying to set a global variable without using(storage);
« Last post by ai_enabled on August 03, 2017, 03:46:43 am »
Let me clarify how scripting works in VE.
All the JS files are loaded into isolated script engine instances. It means each script in the game (including topics) has independent global space. There are no shared global variables between script instances.
When you import another JS file into your JS file, its code is loaded separately into the same instance. But the global state is still not shared. So when you import another JS file, in fact, you're simply injecting its content into the importing JS file (it's totally different from C# "namespaces" concept, as you see). So that's why we also don't recommend importing huge JS files everywhere - only where you're really need.

Why is scripting in VE so limited? Because it was much easier for us to implement it this way. It allowed us to avoid many future problems. And we also using some global variables per-script/topic (from example, PLAYER_SHIP - when you're inside the topic script).

Another problem with global variables - we cannot serialize them easily and write into the savegame. So even if we had global variables (shared across all the scripts), it will be very easy to write bad code (which will prevent the game from properly saving the game state). So, we have storage scripting API instead. It's also very limited, but for the most cases, it was enough to get the things done.
9
Help section / Trying to set a global variable without using(storage);
« Last post by ninekorn on August 02, 2017, 09:12:47 pm »
Hi,

Ive got this question about creating a global variable in VoidExpanse javascript. Again, its something super easy in Unity3d but im not sure i get it in VoidExpanse. For example i created this script called globalArrays.js to store global variables.

Code: [Select]
var globalSwitchForMining = false;


var globalArrays =
{
miningSwitch: function (args)
    {
globalSwitchForMining = args;
console.Print(globalSwitchForMining + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    },

isMiningSwitchOn: function ()
    {
console.Print(globalSwitchForMining + "?????????????????????????????????????????????????????????");
return globalSwitchForMining;
    },
};


Then from another script I use this:
Code: [Select]
globalArrays.miningSwitch(true);

if (globalArrays.isMiningSwitchOn() == true)
{
  console.Print("YOU TURNED THE SWITCH ON");
}
else
{
console.Print(" THE SWITCH IS STILL OFF");
}

And in my last script to verify the global Variable i just use:
Code: [Select]
if (globalArrays.isMiningSwitchOn() == false)
{
console.Print("isMiningSwitchOn == false");
}


if (globalArrays.isMiningSwitchOn() == true)
{
console.Print(" WHERE AM I STUCK");
goMineSomeAsteroids();
canFollowPlayer = false;
}

and bam. Houston we've got a problem. the global variable is always false from the third script. If i cant create my own global variables then ill go back to use the using(storage) to set global variables.
10
Help section / Re: How to use ship.SetEquipmentCacheValue?
« Last post by ai_enabled on August 02, 2017, 12:04:54 am »
Well it's not that simple... CalculateShip.js itself subscribing to OnCalculateNpcLeveledCache event:
Code: [Select]
actions.Bind("OnCalculateNpcLeveledCache", "CalculateNpcLeveledCache");I think the easiest way for you will be to modify CalculateShip.js (yes, it's hacky way...).

Another way is to create a new script, also bind to "OnCalculateNpcLeveledCache" and have your custom callback method for it (just copy CalculateNpcLeveledCache code from CalculateShip.js and modify for your needs). But it will work properly only in the case if OnCalculateNpcLeveledCache first handled by CalculateShip.js and then by your script. We don't have any API to setup callbacks priority, so you can try it and see if your method called after CalculateShip.js.
Pages: [1] 2 3 ... 10