About Store Forum Documentation Contact



Post Reply 
GetWaypoints?
Author Message
Driklyn Offline
Member

Post: #1
GetWaypoints?
First off, since this is my first post, I would just like to say how amazing this engine is. I am looking to create a commercial game and have recently been glancing over 6-7 different game engines (including Leadwerks, Torque, C4, SHiVa, Unity, and Visual3D) and, even though I have only been messing around with this one for a little over a week, I have to say this is engine is by far the best! It is so incredibly easy to do incredibly difficult tasks using this engine. This is definitely the easiest and most advanced engine I have ever used (even compared with UDK which the editors are way too complex for my tastes). Congrats! It is very hard to believe there is only one developer.

Okay, now on with my question. I know you can get a certain waypoint using Game::World.getWaypoint() and I am currently using this method. The problem is that I need to be able to get multiple waypoints without knowing the full name. For instance, I am using waypoints to replicate ladders. I need to be able to call a function, such as Game::World.getWaypoints("Ladder*"), and be able to return the waypoints for Ladder01, Ladder02, Ladder03, etc.

I saw this post which I thought was going to work, but, as far as I can tell, Game::Waypoints is only a cache of the previously loaded waypoint using Game::World.getWaypoint(). I currently have the following code, but Ladders only ever has a length of 1, even with 3 waypoints in the world (and even if I remove the if(Contains()) statement).

Code:
Memb<Game::Waypoint *> Ladders;

...

Game::Waypoints.lock();
REPA(Game::Waypoints) {
    if (Contains(Game::Waypoints.lockedElm(i).file, S + "Ladder")) {
        Ladders.add(&Game::Waypoints.lockedElm(i).data);
    }
}
Game::Waypoints.unlock();

I have a few ideas of my own but I am not entirely sure how to implement them yet. Any suggestions?
04-15-2010 07:05 AM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #2
RE: GetWaypoints?
Hello,

Thanks and welcome to the forum,

Game::Waypoints stores only previously loaded waypoints (if the waypoint hasn't been loaded earlier it will not be stored in container)

Take a look at Game::World.find/getWaypoint(..) they load a waypoint from given world path

You can search the world waypoints path once at startup for example using FileFind or FAll (functions have tutorials in the SDK\tutorials..)
and for each waypoint file that you've found, cache the waypoint - just call Game::Waypoints(file_name);
this will include the waypoint in the cache, so you can access it later
04-15-2010 07:26 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #3
RE: GetWaypoints?
Ah, thanks for the fast response! I believe this will work. This was basically the idea that I had, I just didn't know the right functions to call (FileFind/FAll). Thanks again.
04-15-2010 08:27 AM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #4
RE: GetWaypoints?
I finally got it working using FAll() after looking at the FileFind tutorial and reading over string.h to figure out how to replace part of a string. In case anyone wants to know, here's the final code.

Code:
Memb<Waypoint *> Ladders;

void GetWaypoints(CChar *path)
{
    Str8 name = Replace(path, S + "Data/World/temp.world/Game/Waypoint", S);
    if (Contains(name, "Ladder")) Ladders.add(World.getWaypoint(name));
}

FAll("Data/World/temp.world/Game/Waypoint", GetWaypoints);
04-16-2010 07:37 AM
Find all posts by this user Quote this message in a reply
Post Reply