Javascript API documentation
-
aubergine
- Professional

- Posts: 3462
- Joined: 10 Oct 2010, 00:58
Re: Javascript API documentation
@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
-- https://warzone.atlassian.net/wiki/display/GO
-
Per
- Warzone 2100 Team Member

- Posts: 3780
- Joined: 03 Aug 2006, 19:39
Re: Javascript API documentation
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.)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.
-
NoQ
- Special

- Posts: 6226
- Joined: 24 Dec 2009, 11:35
- Location: /var/zone
Re: Javascript API documentation
Just noticed that i seriously miss two things:
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
@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
-- https://warzone.atlassian.net/wiki/display/GO
-
milo christiansen
- Regular

- Posts: 749
- Joined: 02 Jun 2009, 21:23
- Location: Perrinton Michigan
Re: Javascript API documentation
@per That should do fine 
In general, if you see glowing, pulsating things in the game, you should click on them.
- Demigod Game Ganual
- Demigod Game Ganual
-
NoQ
- Special

- Posts: 6226
- Joined: 24 Dec 2009, 11:35
- Location: /var/zone
Re: Javascript API documentation
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
P.S. Per: i know you're there, looking to see you in chat a lot, cause i have a ton of questions
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
-
Per
- Warzone 2100 Team Member

- Posts: 3780
- Joined: 03 Aug 2006, 19:39
Re: Javascript API documentation
@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.
-
NoQ
- Special

- Posts: 6226
- Joined: 24 Dec 2009, 11:35
- Location: /var/zone
Re: Javascript API documentation
Ok nvm, sure it's ok.
Probably the most curious one is that we just accidentally found out that js groups are broken ...
Probably the most curious one is that we just accidentally found out that js groups are broken ...
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
-
Andrie
- Regular

- Posts: 533
- Joined: 20 Jun 2012, 14:11
- Location: Suid Afrika
Re: Javascript API documentation
@Per
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.javascript.pdf wrote:A number of very good guides to JavaScript exist on the Internet.
"My IRC en multiplay naam is Andrie"
Groete Andrie
Groete Andrie
-
NoQ
- Special

- Posts: 6226
- Joined: 24 Dec 2009, 11:35
- Location: /var/zone
Re: Javascript API documentation
Nevermind.NoQ wrote:somebody is asking for a JS function to make those flashy red lights, similar to what you see on LZ in campaign.
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam
-
Per
- Warzone 2100 Team Member

- Posts: 3780
- Joined: 03 Aug 2006, 19:39
Re: Javascript API documentation
This should be covered by removeObject(object[, special effects?]), which sadly is 3.2 only.NoQ wrote:Just noticed that i seriously miss two things:
-
Per
- Warzone 2100 Team Member

- Posts: 3780
- Joined: 03 Aug 2006, 19:39
Re: Javascript API documentation
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.
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.
-
aubergine
- Professional

- Posts: 3462
- Joined: 10 Oct 2010, 00:58
Re: Javascript API documentation
Yessssss!!!!!!!!! 
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
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
-- https://warzone.atlassian.net/wiki/display/GO
-
Per
- Warzone 2100 Team Member

- Posts: 3780
- Joined: 03 Aug 2006, 19:39
Re: Javascript API documentation
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+).
-
NoQ
- Special

- Posts: 6226
- Joined: 24 Dec 2009, 11:35
- Location: /var/zone
Re: Javascript API documentation
NullBot 2.0, for which chat support was planned as a improvement worth bumping first digit, is coming soon, i guess (:
(close #3199?)
Maps | Tower Defense | NullBot AI | More NullBot AI | Scavs | More Scavs | Tilesets | Walkthrough | JSCam