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

I see I din’t know you could define a word in " to be a function tho.

so from what I am seeing , dictates target (either function or .id) and + is add.

Is that correct?

@LordMaddog perhaps this illustration will help?

The commas separate things that you send to a function. So for instance if we use our previous example of the function that cleanAndScrub()'s dishes this is one way we could send many dishes to be cleaned:

local dish1 = "A dirty Dish"
local dish2 = "A grimy Dish"
local dish3 = "A filthy Dish"
cleanAndScrub( dish1, dish2, dish3 )

remember that this is just an example and the “dishes” we are talking about are really just strings.

in the pet example we are sending two things to the function on(). A string "hear" and the name of a function speak.

speak would need to be defined in your code:

local speak = function()
    pet:say(" I am talking ")
end

And if you are asking why are we using the word argument for programming and wondering why we should be fighting with our functions and not having a constructive discussion here is a nice read:
1 Like

Thank you.

I am learning a lot and I really like you game its amazing!

You are welcome. And I enjoy their game as well. I am just a community member like yourself.

@LordMaddog if it is alright with you, I am going to update the title of your post to help the rest of the community who might have similar questions.

How so ? I mean can you clarify with an example.

i simply remember how i was confused
then encountered this
why handler is

pet.on( "hear", function )

instead

pet.on( "hear", function() )
@LordMaddog if it is alright with you, I am going to update the title of your post to help the rest of the community who might have similar questions.

sure

also for pets level/go-fetch onward the instructions are in Java not Lua.

So in this case if we think of

function as a noun

and

function() as a verb

Then we can observe that we are sending the actual function as an argument into the pet.on() function and not the result of running the function() right? If we used the function as a verb and ran it, we would be telling the code to take the return value and send that as the argument instead of the function itself.

There is no reason why we couldn’t use a function() that returns a function and put that into the second argument spot right? Unless the programming language disallows calling a function within an argument space.

-HW

2 Likes

O wow that example is phenomenal!

It makes every thing so clear

once again thank you.

Posted LUA conversions

Updated:

  • Go Fetch
  • Buddy’s Name
  • Phd Kitty
  • Pet Quiz
  • Guard Dog
  • Long Road
  • Forest Jogging
  • Forest Cannon Dancing

Adding more patches here:

How about pet quiz? I’m having problems on that. Especially defining petSay thing.:sweat:

I am working on level 28 tomb raider and my code won’t work for some reason, here it is can somone help?
define function checkToDefend(target)
target equals hero:findNearestEnemy()
if target then
hero:attack(target)
on this line I have a syntax error that keeps poping up and saying that there is a problem with my code.

Many reasons for it could exist. Giving some screenshots may help)
Maybe lack of proper equipment (such as glasses f.e.)