| 08-19-2006, 10:37 PM | #1 |
I feel so stupid asking this, but I'll do it anyways. I hear about natives everywhere. My problem is, how do you use them? When I was flipping through JASScraft, I decided to look at some natives, so I looked at "CreateNUnitsAtLoc" This is what it showed me: JASS:function CreateNUnitsAtLoc takes integer count, integer unitId, player whichPlayer, location loc, real face returns group call GroupClear(bj_lastCreatedGroup) loop set count = count - 1 exitwhen count < 0 call CreateUnitAtLocSaveLast(whichPlayer, unitId, loc, face) call GroupAddUnit(bj_lastCreatedGroup, bj_lastCreatedUnit) endloop return bj_lastCreatedGroup endfunction So what does that mean? Is it just saying what the native "CreateNUnitsAtLoc" does? Do I need to put this into my code, or just "CreateNUnitsAtLoc"? |
| 08-19-2006, 11:03 PM | #2 |
use JASS:call CreateNUnitsAtLoc(count, unitId, whichPlayer, loc, face) (for those with a return like the previous one) JASS:local group g set g = CreateNUnitsAtLoc(count, unitId, whichPlayer, loc, face) |
| 08-19-2006, 11:06 PM | #3 |
CreateNUnitAtLoc isnt a native. It is a blizzard.j (referred to as BJ) function. The natives for creating a unit are: JASS:native CreateUnit takes player id, integer unitid, real x, real y, real face returns unit native CreateUnitAtLoc takes player id, integer unitid, location whichLocation, real face returns unit native CreateUnitAtLocByName takes player id, string unitname, location whichLocation, real face returns unit native CreateUnitByName takes player whichPlayer, string unitname, real x, real y, real face returns unit |
| 08-19-2006, 11:29 PM | #4 |
but don't you call them like you do a function? |
| 08-20-2006, 12:06 AM | #5 |
Yes you do. The only (valuable) difference between the native function and any non-native function is that the natives are directly called from the game engine, which mean its execution is much faster. |
| 08-20-2006, 12:40 AM | #6 |
looking on jass manual, it appears all functions are natives. |
| 08-20-2006, 12:43 AM | #7 |
That would be wrong. Only functions in common.j are natives. |
| 08-20-2006, 12:44 AM | #8 |
natives are declared in common.j some functions are declared in blizzard.j the rest in your map. |
| 08-20-2006, 12:51 AM | #9 | |
Quote:
I thought they were just functions not natives. |
| 08-20-2006, 01:01 AM | #10 |
Natives are functions, the difference is that they are hard coded in the game engine. The rest we call functions , are JASS functions declared by either blizzard (in blizzard.j) generated by world editor or wrote by users |
| 08-20-2006, 01:33 AM | #11 |
ahh, i see now. |
| 08-20-2006, 03:38 AM | #12 |
uhh no questions were answered, im sorry... I mean, how do you use a native? Do you just put in the line with all the takes and returns, or do you put in the function? Thats my question, becuase everytime I show a trigger here, someone tells me to use natives, but I don't know how to: 1. find the natives of BJ's 2. how to put them in. I guess thats what I was asking. |
| 08-20-2006, 04:11 AM | #13 |
All BJ functions call at least one native function. To find the native, and skip using the BJ, use JassCraft or something, and spot the native inside the BJ function. For example, here is a BJ function: JASS:function DisplayTextToForce takes force toForce, string message returns nothing if (IsPlayerInForce(GetLocalPlayer(), toForce)) then call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, message) //This text is red! endif endfunction JASS:DisplayTextToPlayer takes player toPlayer, real x, real y, string message returns nothing Use a native the same way you would use a BJ function. JASS:call DisplayTextToForce(...) BJ function call DisplayTextToPlayer(...) Native function EDIT: Dang! You can't format text inside JASS tags :( |
| 08-20-2006, 04:14 AM | #14 | |
Quote:
Razernok's first ost in this thread should have answered all your needs. |
| 08-20-2006, 04:31 AM | #15 | |
Quote:
Not that this changes anything. |
