Page 10 of 25

Re: Javascript API documentation

Posted: 16 Feb 2012, 00:43
by cybersphinx
Made the buildbot generate the current javascript docs of master (which should cover 3.1 as well).
One page: http://buildbot.wz2100.net/files/javasc ... cript.html
Multi page table of contents: http://buildbot.wz2100.net/files/javasc ... index.html

Re: Javascript API documentation

Posted: 16 Feb 2012, 01:57
by aubergine
@cybersphinx - AWESOME WIN! Great work!

When referencing things like structures.txt, rules.js, scavfact.js, features.txt, is there any way they could be hyperlinked to github so we can view those online too? Would be much easier than having to trawl through base.wz and mp.wz looking for them (as I'm never quite sure where some of those files exist).

Re: Javascript API documentation

Posted: 16 Feb 2012, 22:57
by Per
Added:
* chat(target, message), for sending chat messages. chat may be ALL_PLAYERS or ALLIES or a specific player number
* orderDroid(droid, order), with new orders DORDER_STOP, DORDER_HOLD, DORDER_RTR, DORDER_RTB
* DORDER_FIRESUPPORT
* DORDER_REARM, and it may be used both with orderDroid() and orderDroidObj()
* enumGateways(), gives array of objects with x1, y1, x2, y2 properties
* .hasIndirect property for droids, if any weapons are indirect (eg artillery)

Fixed .armed and .range properties. The .group and .armed properties are now null instead of undefined if not applicable.

All of this is for 3.2 only at the moment.

Re: Javascript API documentation

Posted: 17 Feb 2012, 00:45
by NoQ
sending chat messages
All right, but we also need to receive chat messages! (:

Re: Javascript API documentation

Posted: 17 Feb 2012, 01:06
by aubergine
Woot! Great to see more stuff being added :D

enumGateways()? What are gateways?

Re: Javascript API documentation

Posted: 17 Feb 2012, 01:10
by NoQ
What are gateways?
Gateways are special invisible marks on the map that hint AIs to build hardpoints on them. They are painted by the map maker (of course, some map makers are lazy enough to paint them). Each gateway is a line segment of adjacent map tiles. Nexus AI fills the whole line with best hardpoints available, except two middle tiles (any two middle tiles in case gateway has odd length); i guess any AI should do the same. Picture.

Re: Javascript API documentation

Posted: 17 Feb 2012, 14:46
by NoQ
In order to build hardpoints on gateways, i'd like to be able to find out if a certain tile of a gateway is already occupied by a (friendly) structure. So that not to block things. Of course, i could make this check manually (cycle through all structures, guess its dimensions based on stattype and/or name, etc.), but it's a lot of pain.

That is, i'd like to have something like isBuildable(x,y) that will return true iff the tile (x,y) is passable (neither cliff nor water) and not occupied by any building or feature (tiles near a research center are considered to be occupied, but tiles near factory aren't).

Re: Javascript API documentation

Posted: 17 Feb 2012, 17:43
by aubergine
I'd like a whatsAt(x,y) function that returns:

* terrain type
* z-index
* continent
* any droids/structures/features at that point

Re: Javascript API documentation

Posted: 19 Feb 2012, 21:00
by Per
NoQ wrote:All right, but we also need to receive chat messages! (:
Right. Added eventChat(from, to, message) for receiving chat messages. I think it will handle network messages, as in the case of non-host players being allied to an AI and wanting to message it, but this has not been properly tested yet. (No, this is not trivial. The message code is FUBAR.)

Re: Javascript API documentation

Posted: 20 Feb 2012, 09:20
by NoQ
Excellent! Beacons is the thing i want the most now.

Also, in the latest git, whatever AI said is displayed as if the host said this (displayed as NoQ: ...) (it was a skirmish game) (eventChat also thinks that me == NoQ) (this wasn't there some time ago when eventChat wasn't present)

Re: Javascript API documentation

Posted: 20 Feb 2012, 13:26
by aubergine
Ability for AI to place beacons as well - that would be v. useful as it would allow AIs to indicate to allies locations on the map.

Re: Javascript API documentation

Posted: 28 Feb 2012, 22:46
by NoQ
I'd like to have DORDER_OBSERVE, so that i could use mobile sensors to pick targets for long-range artillery. Neither DORDER_ATTACK nor DORDER_SCOUT seem to do the job.

Re: Javascript API documentation

Posted: 29 Feb 2012, 02:48
by aubergine
Can't you just pass the numeric id of that order in to orderDroidObj?

Re: Javascript API documentation

Posted: 29 Feb 2012, 06:41
by NoQ
Didn't try yet; just though that to ask is better than to hack (:

Re: Javascript API documentation

Posted: 10 Mar 2012, 07:23
by NoQ
I think it's a good idea to 1. make this thread sticky and 2. separate wzscript discussions into a subforum (: