LUA code patch for - Forest - Backwoods Fork - posted intro/ overview / and default code


Default code for LUA - - Copy-Paste into the editor to start

-- Incoming ogres!
-- Use the checkAndAttack function to make your code easy to read.

-- This function has a parameter.
-- An parameter is a way of passing information into a function.
local checkAndAttack = function(target)
    -- The 'target' parameter is just a variable!
    -- It contains the argument when the function was called.
    if target then
    hero:moveXY(43, 34)

while true do
    hero:moveXY(58, 52)
    local topEnemy = hero:findNearestEnemy()

    -- Move to the bottom X mark.

    -- Create a variable named bottomEnemy and find the nearest enemy.
    -- Use the checkAndAttack function, and include the bottomEnemy variable.

Introduction for LUA

A `function` is an important concept when writing code! They are used to separate individual, **repeatable** parts of your code into easier to digest pieces.

Often times, a function requires an argument. This is a way to customize a repeatable action while still optimizing and cutting down the length of one’s code. This is what you put in between ( and ) when calling the function.

A parameter is what a potential argument is called inside the function definition.

-- This function has 1 parameter: 'target':
local checkAndAttack = function(target)
    -- 'target' is a predefined variable.
    if target then

local enemy = hero:findNearestEnemy()
-- Below, 'enemy' is the argument. This becomes 'target' inside checkAndAttack.

Overview for LUA

Functions are an important part of writing code! They can be used to separate individual parts of code to help understand each bit easier.

Functions can do much more than just do some actions independent of any input! Using arguments and parameters, functions are capable of acting on what is sent in.

An argument is the information included between the () when any given function is called.

A parameter is a variable containing the information passed in from a function. It is just a predefined variable containing any information sent in!

-- 'target' after the function name is called a 'parameter'.
-- Think of a parameter as a new variable containing information from outside the function!
local checkAndAttack = function(target)
    -- 'target' is a predefined variable by the parameter, so nothing more needed to use it!
    if target then -- Check if the 'target' exists.
        hero:attack(target) -- If so, attack!

local enemy = hero:findNearestEnemy()
-- Below, the variable 'enemy' is an 'argument'.
-- Including 'arguments' when calling functions lets them behave differently depending on the input!
-- In this case, well attack whatever enemy is passed in!

Please feel free to use this to help you with the level until the patch is applied.

Tomb Raider - code help - what are functions - lua default code for level

It dosen’t help me because this is just what’s in the hints. The code you put here is the same as in the editor. It is the orc comes in and kills the villager after you’ve left the x mark there.