Javascript API documentation

For AI and campaign script related discussions and questions

Re: Javascript API documentation

Postby aubergine » 19 Apr 2012, 20:48

@milo: If your mod is for Warzone 3.2+ then you can use the full range of functions in the API. However if it needs to work on 3.1 as well, there are several API features that won't be available - such as enumRange(), although I believe Per might have plans to port that to the 3.1 branch...?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
aubergine
Special

User avatar
 
Joined: 09 Oct 2010, 23:58

Re: Javascript API documentation

Postby Per » 19 Apr 2012, 21:34

milo christiansen wrote:@per OK that should work for round/square areas but what about rectangles? I still thing a enumArea(x, y, x2, y2, "playerfilter", "type filter", seen) would be best, then I can just write wrappers for specific uses.

Added enumArea(<x1, y1, x2, y2 | label>[, filter[, seen]]. (You can call it with x, y, x2, y2 replaced with an area label. This should work, but I have not been able to test this yet.)
Per
Warzone 2100 Team Member

 
Joined: 03 Aug 2006, 18:39

Re: Javascript API documentation

Postby NoQ » 23 Apr 2012, 17:07

Just noticed that i seriously miss two things:

NoQ
Hero

User avatar
 
Joined: 24 Dec 2009, 10:35
Location: /var/zone

Re: Javascript API documentation

Postby aubergine » 23 Apr 2012, 23:31

@NoQ: https://warzone.atlassian.net/wiki/page ... Id=4817005 <-- generic "removeObject()" function in 3.2 can remove anything from the map :)
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
aubergine
Special

User avatar
 
Joined: 09 Oct 2010, 23:58

Re: Javascript API documentation

Postby milo christiansen » 24 Apr 2012, 23:28

@per That should do fine :)
In general, if you see glowing, pulsating things in the game, you should click on them.
- Demigod Game Ganual
milo christiansen
Professional

User avatar
 
Joined: 02 Jun 2009, 20:23
Location: Perrinton Michigan

Re: Javascript API documentation

Postby NoQ » 04 Sep 2012, 16:39

Bump: somebody is asking for a JS function to make those flashy red lights, similar to what you see on LZ in campaign.

P.S. Per: i know you're there, looking to see you in chat a lot, cause i have a ton of questions :oops:
NoQ
Hero

User avatar
 
Joined: 24 Dec 2009, 10:35
Location: /var/zone

Re: Javascript API documentation

Postby Per » 04 Sep 2012, 22:46

@NoQ - I am pretty busy with other things at the moment. I try to read what is posted on the forum ... but that is it for now.
Per
Warzone 2100 Team Member

 
Joined: 03 Aug 2006, 18:39

Re: Javascript API documentation

Postby NoQ » 04 Sep 2012, 22:57

Ok nvm, sure it's ok.
Probably the most curious one is that we just accidentally found out that js groups are broken ... :oops:
NoQ
Hero

User avatar
 
Joined: 24 Dec 2009, 10:35
Location: /var/zone

Re: Javascript API documentation

Postby Andrie » 05 Sep 2012, 08:35

@Per
javascript.pdf wrote:A number of very good guides to JavaScript exist on the Internet.

I a wanted to PM you but I can't, so let me ask you here where can I get good guides please tell me.
"My IRC en multiplay naam is Andrie"

Groete Andrie
Andrie
Professional

User avatar
 
Joined: 20 Jun 2012, 13:11
Location: Suid Afrika

Re: Javascript API documentation

Postby NoQ » 06 Sep 2012, 15:06

NoQ wrote:somebody is asking for a JS function to make those flashy red lights, similar to what you see on LZ in campaign.

Nevermind.
NoQ
Hero

User avatar
 
Joined: 24 Dec 2009, 10:35
Location: /var/zone

Re: Javascript API documentation

Postby Per » 05 Nov 2012, 21:14

NoQ wrote:Just noticed that i seriously miss two things:


This should be covered by removeObject(object[, special effects?]), which sadly is 3.2 only.
Per
Warzone 2100 Team Member

 
Joined: 03 Aug 2006, 18:39

Re: Javascript API documentation

Postby Per » 05 Nov 2012, 21:16

Added new events (3.2 only):

eventGameLoaded() - An event that is run when game is loaded from a saved game. There is usually no need to use this event.

eventGameSaving() - An event that is run before game is saved. There is usually no need to use this event.

eventGameSaved() - An event that is run after game is saved. There is usually no need to use this event.
Per
Warzone 2100 Team Member

 
Joined: 03 Aug 2006, 18:39

Re: Javascript API documentation

Postby aubergine » 05 Nov 2012, 22:43

Yessssss!!!!!!!!! :D

For 3.1 branch, I was wondering if I created a global getter/setter property, when saving it should trigger the getter and thus I can backport the eventGameSaving() event to 3.1 branch? But how would I know what order it reads the global properties in... first defined first saved, or saved alphabetically? I assume it accesses them in the order they are defined, doing a for..in on the global object/scope? And I'm guessing that events & timers will be disabled during the save process, so I can queue a function call to eventGameSaved() to backport that event too? Hrm... Oooh, I've just thought of a better way to backport eventGameLoaded() as well... *back to coding*

EDIT: When getting variables to save, does the WZ engine differentiate between data and accessor properties? I'm hoping it doesn't? How does it work out which globals to save and which not to save (other than obvious things like constants and functions)?

EDIT #2: I've made a start on documenting the key environment sequences that occur within Warzone, from a JS scripter's perspective: https://warzone.atlassian.net/wiki/disp ... +Sequences
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
aubergine
Special

User avatar
 
Joined: 09 Oct 2010, 23:58

Re: Javascript API documentation

Postby Per » 16 Nov 2012, 15:31

Chat messages going between AIs and between humans and AIs, even if human is on a different computer than AI, should work now in master (3.2+).
Per
Warzone 2100 Team Member

 
Joined: 03 Aug 2006, 18:39

Re: Javascript API documentation

Postby NoQ » 16 Nov 2012, 16:45

:D :D :D
NullBot 2.0, for which chat support was planned as a improvement worth bumping first digit, is coming soon, i guess (:

(close #3199?)
NoQ
Hero

User avatar
 
Joined: 24 Dec 2009, 10:35
Location: /var/zone

PreviousNext

Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest