Skip to content
User Avatar
#2257
Auto-translated
-- initialize a variable with some default state.
-- Not required, but very useful, as if we accidentally access it before
-- creating it, the script will crash. Initialization at the beginning of the file
-- guarantees that the variable will always exist.
hero_level = 1; -- assign a value to the variable?

-- when the need arose to remember the current hero's level,
-- we call this function, and the global variable remembers its value
-- until it is reassigned again.
function foo()
hero_level = GetHeroLevel('hero'); -- in the function, the variable is equal to the hero's level?
end

-- at any subsequent moment from any other function, we can use this value.
-- let's say a more meaningful example - give the hero as many peasants as he has level:
function bar()
AddHeroCreatures('hero_name', CREATURE_PEASANT, hero_level);
end

Statistics

Welcome our newest member: artem

Users Online 4 users 1589 guests