self:say("Take", numToTakeDown + " down, pass it around!")
on the watch screen it shows the hero singing with the rest perfectly just like he should but I get a syntax error from this line and I don’t pass the level
nvm just removed the function and said 1 like you should tho it seemed like it should have worked at least I was positive I seen my hero singing along now thought after reset he dont when using said code.
local someFunction = function( firstArgument, secondArgument, thirdArgument )
if firstArgument then
hero:say( firstArgument )
hero:say("There is no first argument")
if secondArgument then
hero:say( secondArgument )
hero:say("There is no second argument")
if thirdArgument then
hero:say( thirdArgument )
hero:say("There is no third argument")
The pet.on() function is predefined as well. It takes 2 arguments. the first being an indicator about what action took place and the second is the actual name of a function to execute when this occurs.
It is like saying in English:
Pet, when you “hear” something perform the “speak” functions action.
The list of actions that can be used to trigger this to happen are limited by a predefined list. "hear" was chosen for when characters in the game speak.
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 ")
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:
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.
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
on this line I have a syntax error that keeps poping up and saying that there is a problem with my code.