Jump to content

[Moding Documentation] A better documented API system


rater193

Recommended Posts

Oh wow, i realized that it all was already pretty well doccumented, however i will still post the exposed functions here, including the hidden ones! :P

 

 

Hello, i looked at the documentation, its great and everything, but doesnt show ALL the functions that players can use, for example, using the players inventory, or even a list of player functions(unless i looked over it lol)

I have however been able to expose the functions manually, but i still dont know what the arguments for the functions might be.

 

Regardless, i will post what i found here, in case anyone else wants to know :P

 

If anyone else needs me to expose some functions for a userdata object, let me know, and i will add it here.

 


Exposed functions


Player:

Description:

To get a player, just type Player(playerid) and that will return the userdata object.

 

Example usage:

local targetPlayer = Player(5)
local inventory = targetPlayer:getInventory()

btw i just read over what i typed, and didnt realize i typed targetPlayer:targetPlayer() fail >_< i feel stupid now :P anyways i updated the code sniplet to what it should have been targetPlayer:getInventory()

 

Functions:

 

 

canPayMoney

__call

setResources

payMoney

getTraits

receiveResource

resolveScriptPath

createStationStyle

payMoney

getShipType

hasStaticRelationsToFaction

removeScript

getStationStyleNames

getShipCargo

addMail

getShipCrew

hasScript

addColor

addScriptOnce

addScriptOnce__index

createShipStyle

getShipNames

canPayMoneyreceive

getShipStyle

knowsFaction

unregisterCallback

getMail

getValues

setValue

getColor

getShipPosition

payResource

__avoriontype

readMail

getLanguage

removeMail

sendChatMessage

getInventory

getShipPayment

updateMail

getValuesgetScripts

getShipPaymentTime

ownsShip

registerCallback

getShipPlan

clearMail

getHomeSectorCoordinates

receiveMoney

__newindex

getTrail

setTrait

getResources

__gc

canPayResource

invokeFunction

setStationRelationsToFaction

getShipStyleNames

getRelations

setHomeSectorCoordinates

getStationStyle


 

 

Player's inventory

Description:

get the players inventory by calling player:getInventory()

 

Functions:

 

 

amount

take

__avoriontype

setAmount

addclear

removeAll

remove

find

__index

getItemsByType

__gcsetEmpty

addAt

__newindex


 

 

Comment here for any userdata objects yo want exposed

Link to comment
Share on other sites

here another tip to add (its not that obvious):

 

if you call invokeServerFunction() or invokeClientFunction() you get an implicit global var called callingPlayer which holds the index of the player entity which called that function!

 

I also think it would be a good idea to collect all the "special" entity script functions called by the engine if they are declared (this Wiki page lists most of them I think, but that page is hard to find in the wiki...):

 

 

Link to comment
Share on other sites

btw i found out u can find the entities functions here

/Avorion/Documentation/Entity.html

Player functions and variables are available in Documentation/Player[Client].html and Documentation/Player[server].html. Yet you found some Functions I didn't know existed. I'm interested in such functions for the Entity-object :)

 

if you call invokeServerFunction() or invokeClientFunction() you get an implicit global var called callingPlayer which holds the index of the player entity which called that function!

Damn I always wanted to know where to get the "callingPlayer" Variable. This could be helpful.

Link to comment
Share on other sites

btw i found out u can find the entities functions here

/Avorion/Documentation/Entity.html

Player functions and variables are available in Documentation/Player[Client].html and Documentation/Player[server].html. Yet you found some Functions I didn't know existed. I'm interested in such functions for the Entity-object :)

 

also interesting is that the EntityDescriptor (/Avorion/Documentation/EntityDescriptor.html) is documented with seperate functions, dont really know why ... whats the actual difference between Entity and EntityDescriptor then? Anybody knows?

Link to comment
Share on other sites

Edit 1: Sector():spawn Station/Ship/ASteroids etc. expects an EntityDescriptor.

Sector():createEntity() expects an EntityDescriptor. You can build very customized Entities that way.

It can have Components  [enum ComponentType] (which you can't get from an spawned Entity!) Also some other properties which later become read only/ not readable at all might be set there.

 

Edit2: my move Asteroid mod uses this to create Asteroids.

Link to comment
Share on other sites

Edit 1: Sector():spawn Station/Ship/ASteroids etc. expects an EntityDescriptor.

Sector():createEntity() expects an EntityDescriptor. You can build very customized Entities that way.

It can have Components  [enum ComponentType] (which you can't get from an spawned Entity!) Also some other properties which later become read only/ not readable at all might be set there.

 

Edit2: my move Asteroid mod uses this to create Asteroids.

 

ty much, now I understand :) I think its viable to say its kind of a template for entities then...

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...