Page 1 of 1

Is Lua different here?

Posted: 2010-08-17, 21:11
by Viggsy
I may seem like a complete newbie when I ask this, but I used to play a game called Roblox which involved a simpler version of Lua scripting, which used mainly functions, and events that connected to the functions. Like, a script would be inserted into a brick, and would change color when touched like so:


function onTouched(hit)
script.Parent.BrickColor = BrickColor.new((math.random(1,255)))
wait(1)
end

script.Parent.Touched:connect(onTouched)


Roblox said that their version of Lua was heavily simplified since it's audience is mostly children, but would a script like that even do anything in Cafu? I have more examples if needed.

Re: Is Lua different here?

Posted: 2010-08-18, 14:34
by Carsten
Viggsy wrote:Roblox said that their version of Lua was heavily simplified since it's audience is mostly children, but would a script like that even do anything in Cafu?
Well, Lua is an extensible, embedded language, and I guess each project uses it in a different, project-specific way.

In Cafu, the key idea is that the relevant "objects", i.e. the windows in a GUI or the entities in a map, are made available to the script.
The Cafu engine then calls the script as a whole, or specific script-defined functions ("methods") of the objects, e.g. when an event occurs.

Please see thread http://www.cafu.de/forum/viewtopic.php?f=8&t=730, where I've posted some details about documentation (which unfortunately is still sparse) and examples.