//! textmacro LUA_JASS_IO takes FILE_NAME
//! i do
//! i local PATH = "jass\\luajass.$FILE_NAME$.j"
//! i function jassread()
//! i local f = io.open(PATH, "r")
//! i if (f == nil) then
//! i return nil
//! i end
//! i local code = f:read("*all")
//! i f:close()
//! i return code
//! i end
//! i function jasswrite(code)
//! i local f = io.open(PATH, "w")
//! i f:write(code)
//! i f:close()
//! i end
//! i end
//! endtextmacro
//! externalblock extension=lua ObjectMerger $FILENAME$
//! runtextmacro LUA_GET_OBJECT_ID()
//generates an object id for hpea (peasant) of object type units
//! i local object obj = getobjectid("hpea", "units")
//create the object using the retrieved object id
//! i setobjecttype("units")
//! i createobject("hpea", obj)
//modifications
//! endexternalblock
//! external ObjectMerger w3a Adef OUIN anam "Unit Indexing" ansf "(Unit Indexing)" aart "" arac 0
setobjecttype
and createobject
? Where are these functions defined or given?//! external ObjectMerger w3a Adef OUIN anam "Unit Indexing" ansf "(Unit Indexing)" aart "" arac 0
??createobject
and setobjecttype
in the GrimEx manual; I have read the GrimEx manual before. I was not asking for a vague interpretation of what that external code does, instead I was asking for specific details on where functions like these two are explicitly defined. //! map.w3x lookuppaths ( w3u | w3t | w3b | w3d | w3a | w3h | w3q ) originalid newid { changeid [ level | variation ] value }
lookuppaths
(I don't see an API anywhere) and that it takes these parameters; not that I'm really sure of what this code even does.//! external ObjectMerger w3a Adef OUIN anam "Unit Indexing" ansf "(Unit Indexing)" aart "" arac 0
It can... all of those snippets I've put up can be cnp'd into WE and run.
If you put this in WE
//! external ObjectMerger w3a Adef OUIN anam "Unit Indexing" ansf "(Unit Indexing)" aart "" arac 0
and you save your map, close your map, then open it and look in Units, you'll see a new unit called Unit Indexing.
function What_Does_Set_Do takes nothing returns nothing
set Example_Function
// What does the 'set' thingy do?
endfunction
//example
set KILLER = GetTriggerUnit()
//this sets the Triggering Unit to the unit variable KILLER
function dogrunsfast takes nothing returns real
return 50
endfunction
function DogGoesVroom takes nothing returns nothing
local real DogSpeed
set DogSpeed = dogrunsfast()
endfunction
function dogrunsfast takes unit dog returns real
call SetUnitMoveSpeed(dog, GetUnitMoveSpeed(dog) + 100)
return GetUnitMoveSpeed(dog)
endfunction
function DogGoesVroom takes nothing returns nothing
local real DogSpeed
set DogSpeed = dogrunsfast(GetTriggerUnit())
endfunction
function GetPlayerTextColor takes player p returns string//If someone calls GetPlayerTextColor, sets a string to = GetPlayerTextColor, or just shoves this guy in a place the requires you to input a string, this function will be ran.
//Now, we just check which player was put in the ( ) when this function was called.
if p == Player(0) then
return "|cffff0000"
elseif p == Player(1) then
return "|cff0000ff"
elseif p == Player(2) then
return "|cff40e0d0"
elseif p == Player(3) then
return "|cff800080"
elseif p == Player(4) then
return "|cffffff00"
elseif p == Player(5) then
return "|cffffa500"
elseif p == Player(6) then
return "|cff00ff00"
elseif p == Player(7) then
return "|cffdb7093"
elseif p == Player(9) then
return "|cffadd8e6"
elseif p == Player(10) then
return "|cff006421"
elseif p == Player(11) then
return "|cff592e0d"
endif
return "" //If it's none of those players we don't change the color. Simple as that.
endfunction
call DisplayTextToForce(GetPlayersAll(), GetPlayerTextColor(LeavingPlayer) + " This dude|r has left the game.")
function takes unit returns real
// Well, I was thinking, since it takes a Test Unit and returns a Real Value, which in this case, is the number the Movement Speed is. Hence my choice of 'takes' and 'returns'.
call SetUnitMoveSpeed (TestUnit Player 1, 300)
// I found this in JASSCraft and thought it would be related to a Unit's Movement Speed, since the unit isn't specified in the question, I chose to use TestUnit instead, Player 1 would be the 'WhichUnit' log and 300 would be the new Movement Speed
endfunction
Player
must have its parameters contained in ( )
. Also, you haven't given a name to your parameter you've simply stated it as unit
; you need to give it a name so that you can reference it inside the function.SetUnitMoveSpeed
are incorrect - the method only takes two parameters, a specific unit
and a real
value of the new movement speed.function Test takes unit(TestUnit) returns real
// Well, I was careless about that, but would the 'Takes' and 'Returns' part be correct this time?
call GetUnitMoveSpeed (TestUnit Player(1))
// I assumed that the movespeed wouldn't be default for the unit (Meaning the unit has items such as Boots) so I didn't use the "Default Move Speed" one.
call SetUnitMoveSpeed (TestUnit Player(1), 300)
endfunction
function Test takes unit TestUnit returns real
call SetUnitMoveSpeed(TestUnit,300.0)
return GetUnitMoveSpeed(TestUnit)
endfunction
PS: You've failed...horribly!
Omg I'm so sorry... I'll promise to do better in the next test...
PS: I hope you could give more tests please![]()
In a right triangle, the cathetus (originally from the Greek word Κάθετος; plural: catheti), commonly known as a leg, is either of the sides that are adjacent to the right angle. It is called occasionally called the periphrasis ("side about the right angle").
function HurtsEm takes nothing returns boolean
call SetWidgetLife( GetFilterUnit(), GetWidgetLife(GetFilterUnit()) - DAMAGE )
return false
endfunction
function SetHurts takes nothing returns nothing
local integer lvl = GetUnitAbilityLevel( GetTriggerUnit(), 'A000' )
set DAMAGE = lvl*80
call SetUnitMoveSpeed( GetTriggerUnit(), 50*lvl )
endfunction
I learnt about Pythagoras' Theorem in school when I was 14, but I never heard of the word Cathetuse before.
function Test takes real a,real b returns real
return SquareRoot(a * a + b * b)
endfunction
Yeah me neither. Anyways. Lets give you a very practical test that you would normally use in JASS.
Set a local variable in one function. The local variable should be an integer that gets a units ability level, the Trigger Unit.
Then, set a global variable in that same function that uses the local variable to decide how much damage it'll do, preferably 80 per level. Use the rawcode 'A000'. Then in that same function make it set a units move speed to 50 per level.
In a new function, which returns a boolean and takes nothing, set the GetFilterUnit()'s life to it current life minus the damage from the global variable. Remember to return a boolean in the function at the end of the code (Anything past a returns won't run).
These are the natives you should be using and their parameters:
GetUnitAbilityLevel( unit whichUnit, abilityrawcode whichrawcode )
SetUnitMoveSpeed( unit whichUnit, real whatSpeed )
SetWidgetLife( widget whichUnit, real howMuchLife )
GetWidgetLife( widget whichUnit )
GetFilterUnit( )
GetTriggerUnit( )
Good luck! Answers in the hidden tags.
JASS:function HurtsEm takes nothing returns boolean call SetWidgetLife( GetFilterUnit(), GetWidgetLife(GetFilterUnit()) - DAMAGE ) return false endfunction function SetHurts takes nothing returns nothing local integer lvl = GetUnitAbilityLevel( GetTriggerUnit(), 'A000' ) set DAMAGE = lvl*80 call SetUnitMoveSpeed( GetTriggerUnit(), 50*lvl ) endfunction
function Test takes location returns unit
call CasterCastAbilityAOE
returns CreateUnitAtLoc(Player(1), A000, GetSpellTargetLoc, returns A000)
endfunction
function Test takes location loc returns unit
return CreateUnitAtLoc(Player(0), 'A000', loc, 0)
endfunction
Please do bear with my mistakes, and help me out...
JASS:function Test takes location returns unit call CasterCastAbilityAOE returns CreateUnitAtLoc(Player(1), A000, GetSpellTargetLoc, returns A000) endfunction
Thank you guys! And rate me please, like a score over 100
I'm really sorry if I'm troubling anyone...
Okay Adiktuz![]()
I'm really sorry for giving that request earlier...
function Trig_test_Actions takes nothing returns nothing
call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING )
endfunction
//===========================================================================
function InitTrig_test takes nothing returns nothing
set gg_trg_test = CreateTrigger( )
call TriggerRegisterPlayerEventLeave( gg_trg_test, Player(0) )
call TriggerAddAction( gg_trg_test, function Trig_test_Actions )
endfunction
JASS:function Trig_test_Actions takes nothing returns nothing call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING ) endfunction //=========================================================================== function InitTrig_test takes nothing returns nothing set gg_trg_test = CreateTrigger( ) call TriggerRegisterPlayerEventLeave( gg_trg_test, Player(0) ) call TriggerAddAction( gg_trg_test, function Trig_test_Actions ) endfunction
Hurr, does this leak?very simple question. And wut is the Event in GUI form?
function Durr takes nothing returns nothing
call CreateUnit(Player(0), 'hfoo', GetSpellTargetX(), GetSpellTargetY(), 0)
endfunction
//===========================================================================
function InitTrig_test takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(t, EVENT_PLAYER_UNIT_SPELL_CAST)
call TriggerAddAction(t, function Durr)
set t = null
endfunction
call TriggerRegisterPlayerUnitEvent(t, EVENT_PLAYER_UNIT_SPELL_CAST)
then just add a null parameter like this: call TriggerRegisterPlayerUnitEvent(t, EVENT_PLAYER_UNIT_SPELL_CAST, null)
Ewww ugly code
JASS:function Durr takes nothing returns nothing call CreateUnit(Player(0), 'hfoo', GetSpellTargetX(), GetSpellTargetY(), 0) endfunction //=========================================================================== function InitTrig_test takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterPlayerUnitEvent(t, EVENT_PLAYER_UNIT_SPELL_CAST) call TriggerAddAction(t, function Durr) set t = null endfunction
This should work. If you get an error in this line:call TriggerRegisterPlayerUnitEvent(t, EVENT_PLAYER_UNIT_SPELL_CAST)
then just add a null parameter like this:call TriggerRegisterPlayerUnitEvent(t, EVENT_PLAYER_UNIT_SPELL_CAST, null)
Can't remember how many arguments it takes![]()
Haha... Actually, I might need a bit of guiding about the 'Leaks' part. After reading some guides, I still don't get what Leaks are in Triggering, I know they are bad and can be a little annoying, but what exactly do they do and how do you remove them? Do tell me in layman terms because I am a little... Dumb.
set udg_>YOURVARIABLE< = GetUnitLoc(GetLastCreatedUnit())
call RemoveLocation(udg_>YOURVARIABLE<)
function Leak takes nothing returns nothing
endfunction
Now, what does that do? And how does a Leak look like?
JASS:function Leak takes nothing returns nothing endfunction
I'm really confused. Because it seems to me from your example that a Leak is... Well, it's nothing (If you take and remove something, doesn't that give you nothing?).