New to Cafu

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.
Tym
Posts: 5
Joined: 2012-10-25, 08:19

New to Cafu

Postby Tym » 2012-10-25, 08:31

Hello, I'm new to this game engine and have a few questions.

First, I've read that Cafu uses both Lua and C++. Which is used for which instance?

Second, when I bring up the properties window (ALT + ENTER) I notice a tab that says "map script", but the entire page is just blank. You cannot click to add anything in to it. Is there something I'm supposed to do to attach my scripts (which I've read is done in Lua) for the map and/or gui of the level I'm building?

I'm assuming I need to. The tutorial for the teleporter uses a gui script to make the teleporters work, but when I load the level, and walk over to one, I can see the pointer on the screen, but I cannot click anything (and nothing happens).

If any of this is in the intro/FAQ section, I missed it.

Can anyone help me with this?

Thank you so much!
User avatar
Carsten
Site Admin
Posts: 2143
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: New to Cafu

Postby Carsten » 2012-10-25, 10:52

Hi Tym,
welcome to the Cafu forums! :welcome:

Tym wrote:First, I've read that Cafu uses both Lua and C++. Which is used for which instance?

C++ is used for most of the application code, Lua is used for map and GUI scripts.
For more information about scripting, please see http://api.cafu.de/scripting/

Second, when I bring up the properties window (ALT + ENTER) I notice a tab that says "map script", but the entire page is just blank. You cannot click to add anything in to it. Is there something I'm supposed to do to attach my scripts (which I've read is done in Lua) for the map and/or gui of the level I'm building?

You're doing everything right, this tab is not yet implemented. :oops:
Right now, map scripts are written with a normal programmers text editor, and placed next to the map they're for.

The tutorial for the teleporter uses a gui script to make the teleporters work, but when I load the level, and walk over to one, I can see the pointer on the screen, but I cannot click anything (and nothing happens).

Did you use the "0" (zero) key for clicking?
This (instead of the left mouse button) is one of the awkward quirks that we really need to iron out asap...

:up:
Best regards,
Carsten
Tym
Posts: 5
Joined: 2012-10-25, 08:19

Re: New to Cafu

Postby Tym » 2012-10-25, 11:18

First off,

Thank you for the warm welcome and fast reply!

That clarification helps me understand this engine more, so thanks!

As of right now, what are the steps needed to take to implement map/gui scripts with a .cmap file? I'm going to begin designing levels for a game in the next month or so, so I'm trying to learn as much as I can about Cafu in the meantime.

Thanks again!
User avatar
Carsten
Site Admin
Posts: 2143
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: New to Cafu

Postby Carsten » 2012-10-25, 18:22

Tym wrote:As of right now, what are the steps needed to take to implement map/gui scripts with a .cmap file? I'm going to begin designing levels for a game in the next month or so, so I'm trying to learn as much as I can about Cafu in the meantime.

Generally, the documentation at http://www.cafu.de/wiki/ is a good start to mapping. For example, it has sections about compiling maps (turning .cmap files into .cw files that the game engine actually reads), and a lot more.

Specifically to scripting, your question is a good one, because we have no "definitive" answer or self-contained tutorial or other "complete, all-in-one" documentation right now.
Good starting points are

I'm also actively working on improving the game/entity code currently, so if you get stuck, it is a very good time to post here at the forums. :cheesy:
In fact, I'd be happy to hear about any problems that you might encounter, because, for example, a new big problem like teleportation might not be solvable with the code as-is, and new functionality might be required that we might add as needed.
Best regards,
Carsten
Tym
Posts: 5
Joined: 2012-10-25, 08:19

Re: New to Cafu

Postby Tym » 2012-10-28, 08:22

I read through all of that, but I am wondering what needs to be done to make sure a specific lua script (for map and/or gui) gets implemented in with the map when caWE compiles. Is there a specific folder the scripts should be placed in for the compiler? Should I be using a specific naming convention so it knows to compile with a certain map file?

Thanks
User avatar
Carsten
Site Admin
Posts: 2143
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: New to Cafu

Postby Carsten » 2012-10-28, 12:07

Tym wrote:I read through all of that, but I am wondering what needs to be done to make sure a specific lua script (for map and/or gui) gets implemented in with the map when caWE compiles. Is there a specific folder the scripts should be placed in for the compiler? Should I be using a specific naming convention so it knows to compile with a certain map file?


Oh, good questions, sorry that I didn't mention this earlier or anywhere else:

  • The Lua script must be placed into the Worlds/ directory next to the compiled world file.
  • The script must have the same base name, but suffix .lua instead of .cw.
  • Good news is that the script is not compiled with the .cw file: You can change it at any time, and the changes become effective as soon as the map is loaded/restarted the next time. (In fact, you can reload the script "live", in the running map, without quitting. This can be a very useful feature, but you should understand how it can affect the maps global script state before you use it. Please let me know if you're interested.)
Best regards,
Carsten
Tym
Posts: 5
Joined: 2012-10-25, 08:19

Re: New to Cafu

Postby Tym » 2012-10-28, 23:48

Thanks, and I am interested in fully understanding how it can affect the global script state. I definitely see myself editing the script "live" to figure out various values I'll want to use for certain features down the road.
User avatar
Carsten
Site Admin
Posts: 2143
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: New to Cafu

Postby Carsten » 2012-11-01, 17:01

Hi Tym,

I now added the answer to your previous question about map script details also to the related documentation,

Tym wrote:Thanks, and I am interested in fully understanding how it can affect the global script state. I definitely see myself editing the script "live" to figure out various values I'll want to use for certain features down the road.

and added the answer to this as a new Developer FAQ: How do I dynamically reload the map script in-game?

About the global state, it's really just a matter of how dofile() works: It does nothing special but "append" the reloaded map script to the existing map script state.

:up:
Best regards,
Carsten
Tym
Posts: 5
Joined: 2012-10-25, 08:19

Re: New to Cafu

Postby Tym » 2012-11-01, 20:47

Thanks!

One more question: Do you know of any IDE that I can run that allows some sort of error/bug check for the source C++ code? I want to begin tweaking it, but am afraid that if I try to do too much (or my programmer adds a lot of extra code) there is no way to check through the 1k+ lines of code for the errors.

Thanks
User avatar
Carsten
Site Admin
Posts: 2143
Joined: 2004-08-19, 13:46
Location: Germany
Contact:

Re: New to Cafu

Postby Carsten » 2012-11-02, 12:24

Tym wrote:Do you know of any IDE that I can run that allows some sort of error/bug check for the source C++ code? I want to begin tweaking it, but am afraid that if I try to do too much (or my programmer adds a lot of extra code) there is no way to check through the 1k+ lines of code for the errors.


I've just added this page to the documentation:
IDEs and Text Editors

Does that answer your question?
Best regards,
Carsten

Return to “Coding and Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest