Is Lua different here?

Get technical support about the C++ source code and about Lua scripts for maps, entities, GUIs, the console, materials, etc. Also covered are the Cafu libraries and APIs, as well as compiling, linking, and the build system.
Post Reply
User avatar
Viggsy
Posts:3
Joined:2010-08-16, 03:56
Contact:
Is Lua different here?

Post by Viggsy » 2010-08-17, 21:11

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.
Image
"Many men who live deserve death, and many men who are dead, deserve life."
User avatar
Carsten
Site Admin
Posts:2170
Joined:2004-08-19, 13:46
Location:Germany
Contact:

Re: Is Lua different here?

Post by Carsten » 2010-08-18, 14:34

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.
Best regards,
Carsten
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests