Javascript API documentation
-
aubergine
- Professional

- Posts: 3462
- Joined: 10 Oct 2010, 00:58
Re: Javascript API documentation
I previously grumbled about the game objects being static snapshots of game data - with the work I'm doing on my Vault script, I've gained a new understanding and appreciation for why the decision was made to have game objects copy game data rather than expose it live to scripts.
So, just wanted to take back my earlier comments and say 'well done!' on an erudite decision with regards to the game objects exposed via JS API.
So, just wanted to take back my earlier comments and say 'well done!' on an erudite decision with regards to the game objects exposed via JS API.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
-
NoQ
- Special

- Posts: 6226
- Joined: 24 Dec 2009, 11:35
- Location: /var/zone
Re: Javascript API documentation
I wasn't really reading much last week ... did i miss anything?
I'm still looking for a way of making AI 1. chat and drop and receive beacons, 2. make use of gateways drawn on the map, and 3. know where his units are currently going (expose .orderx and .ordery properties?) ... also, challenge trouble not fixed yet in v3.1beta1 (:
I'm still looking for a way of making AI 1. chat and drop and receive beacons, 2. make use of gateways drawn on the map, and 3. know where his units are currently going (expose .orderx and .ordery properties?) ... also, challenge trouble not fixed yet in v3.1beta1 (:
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
-
NoQ
- Special

- Posts: 6226
- Joined: 24 Dec 2009, 11:35
- Location: /var/zone
Re: Javascript API documentation
By the way, how exactly do we produce cyborg engineers? didn't work, says
Code: Select all
buildDroid(struct, "Truck", "Cyb-Bod-ComEng", "CyborgLegs", "", DROID_CONSTRUCT, "CyborgSpade");Code: Select all
[js_buildDroid] Invalid template Truck for factory A0CyborgFactoryMaps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
-
aubergine
- Professional

- Posts: 3462
- Joined: 10 Oct 2010, 00:58
Re: Javascript API documentation
No idea, but watching this will cheer you up: https://www.destroyallsoftware.com/talks/wat
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
-
Emdek
- Regular

- Posts: 1329
- Joined: 24 Jan 2010, 13:14
- Location: Poland
Re: Javascript API documentation
aubergine, funny, but if you think about those examples, at least some of them are logical. 
Also there are far "worse" examples, more similar to languages like one here, censored by forum...
Also there are far "worse" examples, more similar to languages like one here, censored by forum...
Nadszedł już czas, najwyższy czas, nienawiść zniszczyć w sobie.
The time has come, the high time, to destroy hatred in oneself.
Beware! Mad Qt Evangelist.
The time has come, the high time, to destroy hatred in oneself.
Beware! Mad Qt Evangelist.
-
Per
- Warzone 2100 Team Member

- Posts: 3780
- Joined: 03 Aug 2006, 19:39
Re: Javascript API documentation
That should work. Can you open a bug ticket for it?NoQ wrote:By the way, how exactly do we produce cyborg engineers?didn't work, saysCode: Select all
buildDroid(struct, "Truck", "Cyb-Bod-ComEng", "CyborgLegs", "", DROID_CONSTRUCT, "CyborgSpade");Code: Select all
[js_buildDroid] Invalid template Truck for factory A0CyborgFactory
-
NoQ
- Special

- Posts: 6226
- Joined: 24 Dec 2009, 11:35
- Location: /var/zone
Re: Javascript API documentation
Done: #3133 (:
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
-
NoQ
- Special

- Posts: 6226
- Joined: 24 Dec 2009, 11:35
- Location: /var/zone
Re: Javascript API documentation
What are the return values of functions like orderDroidBuild or buildDroid?
Cause i just noticed that i intuitively rely on them to return true if the order was successful and false if it's impossible to comply, which sometimes seems to be wrong (?)
Cause i just noticed that i intuitively rely on them to return true if the order was successful and false if it's impossible to comply, which sometimes seems to be wrong (?)
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
-
aubergine
- Professional

- Posts: 3462
- Joined: 10 Oct 2010, 00:58
Re: Javascript API documentation
I'd also like to better understand the return values of the various functions. I was trying to work out what they'd be from the .cpp files, but I don't know C++ well enough to work out what's going on.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
-
Per
- Warzone 2100 Team Member

- Posts: 3780
- Joined: 03 Aug 2006, 19:39
Re: Javascript API documentation
I'm currently a bit too busy with apartment renovation to do much with the source, and my dev box is down, but in general, if you look in the c++ source, anything that has 'return QScriptValue();' returns nothing, and anything with 'return QScriptValue(true);' or 'return QScriptValue(false);' returns a boolean result value.
If you find such things missing in the documentation, I'd be happy to take patches to improve it.
If you find such things missing in the documentation, I'd be happy to take patches to improve it.
-
aubergine
- Professional

- Posts: 3462
- Joined: 10 Oct 2010, 00:58
Re: Javascript API documentation
Ah, cool - it was the QScriptValue() that I wasn't sure about and your post above explains how that works so I can work out the rest.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
-- https://warzone.atlassian.net/wiki/display/GO
-
Emdek
- Regular

- Posts: 1329
- Joined: 24 Jan 2010, 13:14
- Location: Poland
Re: Javascript API documentation
Information on what script returns (especially if those are objects / arrays) is "must have" in documentation (only other useful things are examples, but those should wait for completion of current scripting redo phase - initial porting to JS). 
Nadszedł już czas, najwyższy czas, nienawiść zniszczyć w sobie.
The time has come, the high time, to destroy hatred in oneself.
Beware! Mad Qt Evangelist.
The time has come, the high time, to destroy hatred in oneself.
Beware! Mad Qt Evangelist.
-
Goth Zagog-Thou
- Regular

- Posts: 1582
- Joined: 06 Jan 2007, 08:08
- Location: Delta Base
Re: Javascript API documentation
Looks like the time has come to convert Cam 4 to the new scripting engine. 
Are there any unimplemented functions that might hinder this process yet?
Are there any unimplemented functions that might hinder this process yet?
-
Emdek
- Regular

- Posts: 1329
- Joined: 24 Jan 2010, 13:14
- Location: Poland
Re: Javascript API documentation
AFAIK campaign related functions are not done yet.
Nadszedł już czas, najwyższy czas, nienawiść zniszczyć w sobie.
The time has come, the high time, to destroy hatred in oneself.
Beware! Mad Qt Evangelist.
The time has come, the high time, to destroy hatred in oneself.
Beware! Mad Qt Evangelist.
-
Per
- Warzone 2100 Team Member

- Posts: 3780
- Joined: 03 Aug 2006, 19:39
Re: Javascript API documentation
Many campaign related functions have been ported already, but few of them tested - at all. If you want to help out, testing these functions would be of good help to getting the campaign side of things moving along. Then of course there are many campaign functions that are not yet ported, such as no function yet for adding a message, playing a video, etc..