I don't think I use any jass, Macadamia. Could you hand me a link to good tutorial how to set up Lua into map? Kind of a newbee on that stuff.
Well there's no real tutorial. But Lua has a reference manual, and note that, if you use Reforged, it uses Lua version 5.3 IIRC.
Now before being able to use Lua in a map, you could probably start easy :
Create a GUI trigger with Map Initialization as event, then a custom script line that could start a Lua function, name it as you please, call it GameStart or whatever.
Just to give you an example of how things can be made, let's say we'd start the map with creating a Paladin for Player 1, that is Player(0) for the game, at the player's start location, then give him some experience. Then start a 5 seconds timer that will start the next function that will create a trigger that displays the text "Hello Lua World" when the paladin casts Divine Shield.
-
Lua test
-
Events
-
Conditions
-
Actions
-
Custom script: GameStart()
Now in a right-click -> New Custom Script entry, add :
Lua:
function FirstTrigger()
local message="Hello Lua World"
local hello=CreateTrigger()
TriggerRegisterUnitEvent(hello, Hero, EVENT_UNIT_SPELL_EFFECT)
TriggerAddCondition(hello, Condition(function()
if (GetSpellAbilityId()==FourCC("AHds")) then
return true
else
return false
end
end))
TriggerAddAction(hello, function()
print(message)
end)
end
function GameStart()
Hero=CreateUnit(Player(0), FourCC("Hpal"), GetStartLocationX(0), GetStartLocationY(0), 270.0)
SetHeroXP(Hero, 1000, false)
TimerStart(CreateTimer(), 5.0, false, FirstTrigger)
end
Note "Hero" is a global variable because it is not declared "local". A local variable is a variable that only exists in the current "scope" or context if you prefer.
Also note that the Raw codes for units or abilities have to be converted to an integer in Lua, thus we use the "FourCC" native function for that.
You also noticed we call a function by its name with no brackets in the TimerStart.
But to add a condition and an action to the trigger "hello", we define the function directly with no name. It is called an anonymous function, and the advantage is huge : you can use the local variables defined in the "mother" function in it. Like the string "Hello Lua World" in this case.
If you are not familiar with scripting, you will desperately need to grab the
common.j file from the game - actually I have attached it to this message for you - because it contains all the native functions that Warcraft III adds to Lua to help you make Lua triggers and do things game-related.
I could also attach the
blizzard.j file but I would strongly advise you to stay away from these as they're just extra functions blizzard made with the common.j natives to help making GUI, and it can't do anything that you couldn't do yourself.
Now for the rest, here is the link to the Lua manual :
Lua 5.3 Reference Manual
Not really a full tutorial, but I hope this will help you taking a good start.
Never forget that it is really worth learning Lua, because it is so powerful (much more than Jass for example), and once you will master it, your only limit will be the game limits itself.
Also Lua is a very commonly used language, so all what you will learn can be used in the future for other things.
Good Luck !!!
EDIT : fixed a small mistake and attached the corresponding map.