drarem Posted December 26, 2014 Share Posted December 26, 2014 I took the plunge and steam-purchased both lua and c++ versions. BTW running x64 Linux LXDE (Ubuntu). So far pretty neat stuff. Is there a better option to my idea of creating a preloader for something like this in c++? I found the code below in the forum, and perhaps want to enhance it so I don't have to loop through all the entities to find the one I want to make an impact to. list<Entity*>::iterator iter; for (iter = world->entities.begin(); iter != world->entities.end(); ++iter){ Entity* currEnt = (*iter); // cout << "Entity loaded: " + currEnt->GetKeyValue("name") << endl; if (currEnt->GetKeyValue("name") == "barrel1"){ currEnt->Turn(0,0,1); } In psuedo, here's what I'm thinking of doing.. enum { bear, pot, pan, knife, gun, gold piece }; class Entities; Entities entities = new Entities[255]; // up to 255 'objects' list<Entity*>::iterator iter; for (iter = world->entities.begin(); iter != world->entities.end(); ++iter){ Entity* currEnt = (*iter); if (currEnt->GetKeyValue("name") == "bear1"){ entities[bear].entity = currEnt; } if (currEnt->GetKeyValue("name") == "pot"){ entities[bear].entity = currEnt; } .. .. // now i know how to move or kill the bear for example // or pick up the gold piece, only if i can figure out how to check for collisions in c++ Quote Link to comment Share on other sites More sharing options...
Roland Posted December 26, 2014 Share Posted December 26, 2014 You can see me showing an alternative method using hooks in this video (at around 17:00 ) http://youtu.be/Utb3z4hs79Q?t=17m14s 1 Quote AV MX Linux Link to comment Share on other sites More sharing options...
martyj Posted December 28, 2014 Share Posted December 28, 2014 I think your question might be related to mine. Basically you have entities in the map that you wish to use c++ code with. http://www.leadwerks.com/werkspace/topic/11361-inheritance-and-entity-objects/ Here is the solution that I came up with. Create classes in C++ for your entity. Have the classes use Hooks http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/object/ Using ToLua++, you can create a Lua function to assign your entity to a class that has an entity property. http://lua-users.org/wiki/BindingCodeToLua Quote Link to comment Share on other sites More sharing options...
drarem Posted December 28, 2014 Author Share Posted December 28, 2014 Correct, how to use entities with C++. I'm trying it this way, so far except for maintenance when i add a new object I want to manipulate, it seems ok. What I want to do is only update the enum, change the enum item to a string so I can match it automatically in the pre-loader function. Perhaps something like this or with the hooks, could be implemented in the leadwerks engine, where you can manipulate the object as named in the editor. enum { none, barrel, cardboardbox, ship1 } entities *ents; ents = new entities(world, 255); // up to 255 objects ents->turn(cardboardbox, 0.1, 0, 0); // rotate cardboardbox entity Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.