The tutorial is filled with errors and doesnt work.
How it's done correctly.
function poopaDoopa(player, cmd, id)
if (id) and (id > 0) then -- checks if an ID was typed and if id is greater than 0)
ana = setElementData(player, "poops", tonumber(id)) -- to number verifies that the id is a number
else
outputChatBox("SYNTAX: /"..cmd.." [id]", player, 255, 2, 0, false)
end
end
addCommandHandler("poops", poopaDoopa)
function howMuch (player)
outputChatBox("You have ".. getElementData(player, "poops").."amounts of poops", thePlayer, 255, 2, 0, false)
end
addCommandHandler("poopa", howMuch)
What was incorrect to your code was the string insertion from lua, which should be done by placing 2 dots in front and behind when it's completely surrounded by the string( "this " ..value.. " is a value"). When there's a string infront you should place 2 dots infront of the value("This" .. value) same goes for behind the value, ( value .. " is a value").
Also I suggest you not to pass values across functions unless they're delivered by a function, like the value AMA you were calling, you can better just call the getElementData from the code where you want it to be.
What was also not really clever was the localPlayer you used, you can better use (player, command, value) instead of using localplayer, as it can be used in both serversided scripting and clientsided scripting.
Also, this made very little sense to me;
function poopaDoopa
local id = tonumber(id)(cmd, id)
You're declaring the varible id the value id, which is the same. I know many scripting languages need you to declare the type of a variable before you can use them, but LUA doesnt. LUA's variables are pretty much dynamic, they are all types in one, when they are empty.
I suggest you to try and master LUA before you start writing tutorials.