Forums » Community Projects

VO Lua Question/Answer Thread

«123»
Feb 23, 2009 darkgrey link
Hi, I'm working on a plugin but have run into a little issue.

When I receive the PLAYER_ENTERED_GAME event I call GetCharacterID() but it returns nil. I've tried a few ways to get the character ID in my event handler but to no avail.
I can get my Character's name in the event handler.

Has anybody had this issue and found a solution?

So far I've solved the problem by setting up a one second timer from my event handler which then does what I want to do. I think the character ID information gets initialised after the PLAYER_ENTERED_GAME event has been sent.
Feb 23, 2009 dragoncamand link
i'm looking for a plugin that is abit like proximity warning but insteed of sound it pop up a word on screen i'm deaf so sound don't do good for me so i just thought if some one could make a plugin like it...anyway thanks to who ever makes one my in-game name is DragonProfighter
Mar 23, 2009 darkgrey link
Does anybody know how to use the math3d.RotateGVector() routine?
I'm assuming the first argument is a gvector but I'm not sure what the other arguments are.

Edit: math3d.RotateGVector(qvector,quaternion)
Apr 27, 2009 newberry link
how do i unarchive it?
Apr 29, 2009 Gulain link
dragoncamand I read you post and made a quickie alert it is posted in my thread
http://www.vendetta-online.com/x/msgboard/9/21202#262422
May 18, 2009 akari no ryu link
Is there a lua API available for VO and if so, where is it located?
May 18, 2009 diqrtvpe link
May 21, 2009 darkgrey link
Hi,

I've set up a sourceforge project for the plugins I am working on. It can found at http://sourceforge.net/projects/voplugins/

If anybody wants somewhere to store their own plugins or would like to give me a hand with the ones I've been working on then please drop me an email to mark-vo at flat8.com with your sourceforge details and I'll add you to the poject.

My plugins are a work in progress and need a little bit of work. I'll not be able to work on them for a while as I have some family commitments I need to concentrate on.

I've been trying to put together a framework that plugins can use. Theres some (kinda broken) code to load and save settings, a HTTP client, start of a database (VODB), a semi-working autonav system, minor bot and navigation computer and few other bits and pieces. Oh, and a very simple CGI script that the VODB can use to send and receive data from.

Hopefully someone will find some of this useful.
May 21, 2009 mr_spuck link
Wow ..the autonav and miner things are interesting. Is there any way to test them? I couldn't get them to work.
autonav test threw an error, test2 dumped some coordinates and miner just seemed to target the same roid over and over.
May 22, 2009 darkgrey link
autonav is a bit tricky. It needs some data before it can do anything. You need to fly up to an object, such as a roid or launhc bay, and execute "/autonav scan". I think you need to be within 4 meters of an object before you do the scan. Fly around and perform a few scans on different objects. Once you have performed enough scans (at least 4 objects) execute "/autonav init". The more scans you do the better and you can scan after an init has been performed. you can execute "/autonav comp" for it to calulate some more data. "/autonav pos" should output your ships position". Target an object and execute "/autonav moveto" and the ship will try to fly to that object.

There is one big problem with autonav, its near impossible to gather accurate data which leads to really bad errors. I'm almost convinced it gets to its target by luck :-)

Miner needs autonav to be set up. It calls autonav to move to a roid it wants to mine.

The test2 command is there to test out the algorithms being used. They seem fine but rely on accurate data - the distance between roids.

I'd like to improve miner so that it would travel back to the station. At the moment I'm using the cargohold plugin to selectively dump the cargo - the autojet plugin performs the same thing.
May 22, 2009 mr_spuck link
Ah ok. I got autonav moveto to work, miner still doesn't do anything though.
May 23, 2009 darkgrey link
hmm, strange. Does miner target and move to a roid? I have my mining beams grouped to +Shoot3. Miner assumes that the mining equipment can be controlled via Shoot3.

Heres how I begin. Move close to an asteroid.

/cargodump throw Ore$
/cargodump on
/cargohold on
/miner start

Wait a bit. Miner should target a roid and then inform autonav to move to it.

It might be that you don't have enough autonav data. Miner could be targeting a roid but autonav doesn't have the roids coordinates.

Metana G-14 is probably a good place to begin testing. I might be able to give you the autonav data - drop me an email to mark-vo at flat8.com. I'm there as we speak, or rather my ship is. Feel free to keep the ore I jettison.

One last question. Did you install all of the plugins from subversion? There are some dependencies I might not have mentioned/remembered.

~/.vendetta/errors.log might have some useful messages in it.
May 23, 2009 mr_spuck link
I have __plugin, autonav and miner. Anything else needed?

I didn't notice that it uses the log. It gets into an endless loop of this after /miner start:

[PluginFramework] [debug] UserCommandHandler('miner', { 1='start' (string) } (table))
[Miner] Miner is active.
[PluginFramework] [debug] EventName=TARGET_SCANNED{ 1='Temperature: 10.0 K
' (string), 2=2 (number), 3=123 (number) } (table)
[PluginFramework] [debug] Sending Event=TARGET_SCANNED
[PluginFramework] [debug] EventName=TARGET_CHANGED{ } (table)
[PluginFramework] [debug] Sending Event=TARGET_CHANGED
[PluginFramework] [debug] EventName=TARGET_CHANGED{ } (table)
[PluginFramework] [debug] Sending Event=TARGET_CHANGED
...
[PluginFramework] [debug] Sending Event=TARGET_CHANGED
[PluginFramework] [debug] EventName=TARGET_SCANNED{ 1='Temperature: 10.0 K
' (string), 2=2 (number), 3=123 (number) } (table)
[PluginFramework] [debug] Sending Event=TARGET_SCANNED
[PluginFramework] [debug] EventName=TARGET_SCANNED{ 1='Temperature: 10.0 K
' (string), 2=2 (number), 3=123 (number) } (table)
[PluginFramework] [debug] Sending Event=TARGET_SCANNED
[PluginFramework] [debug] EventName=TARGET_SCANNED{ 1='Temperature: 10.0 K
' (string), 2=2 (number), 3=123 (number) } (table)
[PluginFramework] [debug] Sending Event=TARGET_SCANNED
[PluginFramework] [debug] EventName=TARGET_CHANGED{ } (table)
[PluginFramework] [debug] Sending Event=TARGET_CHANGED
...

I'm alos getting a couple of errors when __plugin is loaded on startup.. starting with this.

plugins/__plugin/main.lua:519: 'do' expected near 'ev'

Did you by any chance check in a broken version?
May 23, 2009 darkgrey link
ok. Fixed the first compile error. Looks like I didn't check in the latest version. I'm running with all of the plugins as some deal with saving and loading settings. You might get an error when you first start VO but for now you can ignore it (or fix it) - some bizarre issue with trying to read the ini file but getting garbage back.

The plugin loops around all of the objects getting what information it can. It shouldn't be endless but it will scan a lot of things. Not an endless loop, just a lot of events being triggered.

I'd probably need to have a look at the log file to get a better idea of what might be going wrong. Might be easier if we jump to email and post the results later.

The first thing to try might be to use all of the plugins except vodb_http_feed. Some of them export routines that others use.
May 23, 2009 darkgrey link
I have just tried out the plugins and wrote down what I did so you can hopefully reproduce the steps and get the miner plugin working.

I moved my old copy of the data files and checkout the plugins.
> mv .vendetta .vendetta_old
> svn co https://voplugins.svn.sourceforge.net/svnroot/voplugins/trunk .vendetta

Then I moved back over the important data files from .vendetta_old/ to .vendetta/
> mv .vendetta_k/drivers .vendetta/drivers
> mv .vendetta_k/manual .vendetta/manual
> mv .vendetta_k/manual.html .vendetta/manual.html
> mv .vendetta_k/media.rlb .vendetta/media.rlb
> mv .vendetta_k/update.rlb .vendetta/update.rlb
> mv .vendetta_k/vendetta .vendetta/vendetta
> mv .vendetta_k/vendetta.lfv .vendetta/vendetta.lfv
> mv .vendetta_k/wgaf.cfg .vendetta/wgaf.cfg
> mv .vendetta_k/config.ini .vendetta/config.ini

Start vendetta and enter game.

Scan a few objects. Move to within 3 meters of each object.
/autonav scan

The more objects you scan the better. The init autonav.
/autonav init
[AutoNav] Coordinates assigned to 4 points (2,212, 2,110, 2,42, 2,61)

Comput positions of some more objects.
/autonav comp
[AutoNav] 29 objects assigned positions

You can continue to 'scan' and 'comp' a few more objects. The more the better.

You can run
/autonav dump
to see a list of all the known/interested objects and positions if known or
/autonav dump 1
to see a list of objects that have known positions.

Once you have calculated points for enough objects (I have 39 known object positions) then you can start mining.

/cargodump throw Ore$
[CargoHold] Will Jettison: 'Ore$'
/cargodump on
[CargoHold] Jettison On
/cargohold on
[CargoHold] CargoHold Checking On
/miner start
[Miner] Miner is active.

Miner should target the nearest/coolest asteroid and ask autonav to moveto it.

When close enough miner will start mining. You should see a message (in the log) similar to
[Miner] [debug] Started mining asteroid '2,22' (10 K).

Autonav will indicate when it has reached position
[AutoNav] Target Reached (59.568439007424)

Miner will stop mining when the asteroid gets above 80K
[Miner] [debug] Stopped mining '2,22', too hot (80.9 K)
it will then target another asteroid.

You'll need to run
/miner stop
/autonav stop
if you want manual control of your ship back.
May 24, 2009 mr_spuck link
Ah, checking out everything worked. I just didn't feel like getting everything if I'm only interested in autonav.

About the ini reading issue, if you leave out the third argument ReadString returns goo. This works here: http://pastebin.com/m67e9d681
May 24, 2009 darkgrey link
ok. Thanks for the fix, I've checked it into the repository.
Jun 14, 2009 Rubin427 link
So, I downloaded the code and sat down to read it.

... then I was saw how much code there actually was, and I thought, "Okay, for now I'll settle for understanding autonav.SetShipThrust()."

Still, very informative.
Jun 16, 2009 darkgrey link
autonav.SetShipThrust() is used to make a ship travel in a specific direction. Its one thing to know where you are but to travel in the direction you want you also need to know the direction you are pointing in.

autonav.SetShipThrust() takes as its argument the direction you want to travel in. It then rotates this vector to compensate for the direction the ship is pointing in (this.rotate_vector). To work out the position are pointing in you work out where you are, then fly in one direction for a little while and then see where you got to. You can then try to calculate the difference between where you are and where you expected to be and then set this.rotate_vector so that future thrusts go in the direction you want.

One of the rules that autonav has is
1. If you are moving towards the target keep going (do not adjust your direction vector).

When trying to work out the ships orientation a random vector is chosen to travel along. The above rule applies when trying to do this. This is probably the only reason autonav works at the moment, i.e. choose a random vector and if that gets you closer to the target then keep going otherwise try another random vector.
Jun 17, 2009 Rubin427 link
I am really surprised there aren't functions to return your ship's (x,y,z) position and another that returns a normalized quaternion with your ship's rotation. So much so that I keep thinking that they must be there in the API somewhere, I just haven't found it.