Jump to content

Turrets transfer script - some questions (EDIT: well, only one...)


Raion

Recommended Posts

Hi! As promised I'm trying to learn how to write scripts for Avorion, and for my first script, I'd like to create a way to transfer turrets between players (my girlfriend asked for this a lot, since in our game I have a military ship and she has a mining ship, and she can't find good mining turrets while I have LOADS of them and no way to transfer them :D, and now she is making my life a hell!!!)

 

To understand interaction between ships, I am studying the interaction scripts, especially the "transfercrewgoods.lua" and various others, but eventually, if I have problems, can I ask for advice? Thank you in advance!

 

EDIT: ok, first question! I understood how to interaction scripts work, essentially using the interactionPossible(PlayerIndex) function to refer to what you want to select to open the menu.

The thing is: how do I refer to another ship that I don't own? I found in the script "transfercrewgoods" this section of code:

function interactionPossible(playerIndex)

 

-- interaction with drones does not work

if Entity_IsDrone(getParentEntityIndex()) == 1 then

return 0

end

 

if Entity_IsDrone(ClientPlayer_GetCraftIndex()) == 1 then

return 0

end

 

-- interaction with own craft does not work

  if getParentEntityIndex() ~= ClientPlayer_GetCraftIndex() then

-- interaction with other crafts can only work on player's own crafts

if getParentFactionIndex() == playerIndex then

return 1

end

end

 

return 0

end

 

Essentially it excludes the drone, the controlled ship and every ship that is not owned by the player. I tried variuos solutions, I even tried to remove everything and just say to the script "ok, accept EVERYTHING", giving a simple "return 1" to the whole block, but when I try to select other ships, they don't seem to be interactable. Where am I doing wrong? I just need a simple suggestion, then I'll go by myself :)

 

Thank you for the support!

 

 

Link to comment
Share on other sites

  • Boxelware Team

The new script you're writing must be added to the ship that it's meant for. You can do so by calling the Entity_AddScript(...) function. The best location for this call would be in the shipyardjob.lua script, at the end of the onFinished() function, when the ship is created by the shipyard.

The other scripts you've seen are built-in and added by default by the game.

You should also check the turretmerchant.lua script to see how to give turrets to a player.

Link to comment
Share on other sites

  • Boxelware Team

By the way: Sending turrets via mail has top priority right now and will probably be in the next patch.

BUT: This might still take a while though and what you're doing is great practice to get to know the scripting, so you should definitely still keep going with your script while the patch isn't out yet.

Just to let you know!

Link to comment
Share on other sites

Don't worry, you deserve some holiday and if you answer to my questions I could be tempted to ask you everything (and this makes the principle of learning completely useless, right? :D)

 

However, I'm extending the functionality of my script to the basis of "trading with other players", may them be turrets os commodities or whatever, without using the mail system.

If you want to keep the realism, of the simulation, a good idea could be to use the mail system only for distant ships, and maybe it could be done this way:

 

when you send a mail, a small drone departs from the ship and begins his journey to reach the recipient of the messagge. In this way, using the mail system could be great roleplay, because someone could intercept the drone and destroy it, or it could take time to send physical objects from one point of the universe to the other (and not one single instant)!

 

However, I wish you good holidays and thank you for the help!

Link to comment
Share on other sites

Oh, and another thing: I am a noob programmer and videogame developer (I started learning it one year ago, beginning with java and c#) but I'm an experienced - more than 10 years - graphic designer and illustrator, so if you ever need some kind of graphic design for the game - for free of course - just ask!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...