Ah you're getting a little bit confused with how TheoTown uses functions.
You don't put values in
script:click(x, y, level) instead you put in variables like
x, y, level (a variable is a word that can have a mutateable
(changeable) value). The general rule would be when you declare functions (using the
function keyword) you use variables in the parameters
(round brackets).
Code: Select all
--- Declaring a function
function sum(a, b) -- use variables in here
return a + b
end
But when calling
(using) a function you use normal values or variables that contain values.
Code: Select all
local number = 12 -- declare variable
--- Calling a function
foo(50, number) -- Use values or variables that were declared
--> res0: number = 62
-- Output of foo(50, number) is 62
The same logic applies when using
script:tap(tileX, tileY, x, y) (using tap as it's easier to explain).
Let's say you had this code:
Code: Select all
function script:tap(tileX, tileY, x, y)
Debug.toast("You tapped: "..x..","..y)
end
What this would do is that whenever TheoTown detects that the user tapped the screen it would call this function (hence the name "tap"). Then TheoTown gives you information about the tap. That's what's going to be inside the parameters.
Let's say if you tapped (20, 40) on the screen TheoTown will put those values inside the
x, y of the parameter so that you can use it.
This is probably hard to understand by just reading. I think it would be easier to understand by experiments so try this code out and try to figure out how it works.
Code: Select all
function script:tap(tileX, tileY, x, y)
local name = "TheoTown"
Debug.toast(name.." detected that you tapped: ("..tileX..","..tileY..")")
end