• What do you need help with? Version 1
    5,001 replies, posted
Since you're using VS2010, just add [cpp] #pragma comment(lib, "lua5.1.lib" ) [/cpp] To the top of the file and make sure that the .lib and .dll files are in your project folder.
A crap forgot to link them :P Also i installed the lua for windows but i still had to download the source files copyy them into my own folder. Where should the libs be?
[QUOTE=Richy19;27013552]Where should the libs be?[/QUOTE] [url]http://luabinaries.sourceforge.net/download.html[/url]
[QUOTE=q3k;27013726][url]http://luabinaries.sourceforge.net/download.html[/url][/QUOTE] Shouldnt that be included in the Lua for windows?
[QUOTE=Richy19;27013771]Shouldnt that be included in the Lua for windows?[/QUOTE] LuaForWindows is a package containing a ton of different things for standalone scripting with Lua. It does contain the library files you need, but they're probably bunched up some place weird in there. It's easier for you to just get the compiled binaries q3k linked.
ok, also theres 2 Lua libs and DLLs which should i link to? theres Lua51 and Lua5.1
[QUOTE=Richy19;27013886]ok, also theres 2 Lua libs and DLLs which should i link to? theres Lua51 and Lua5.1[/QUOTE] Obviously Lua51, that's like what, 46 versions ahead?
[QUOTE=WTF Nuke;27013941]Obviously Lua51, that's like what, 46 versions ahead?[/QUOTE] Not very helpfull
[QUOTE=Richy19;27013962]Not very helpfull[/QUOTE] Try one then the other.
[QUOTE=Richy19;27013886]ok, also theres 2 Lua libs and DLLs which should i link to? theres Lua51 and Lua5.1[/QUOTE] IIRC one is for complete static linking, the other one is for distribution with a DLL (protip: one is bigger).
Got it working. Are there any good links to using lua with with C++? Like using lua variables in C++, accessing C++ functions with lua and stuff like that. [editline]28th December 2010[/editline] [QUOTE=q3k;27014019]IIRC one is for complete static linking, the other one is for distribution with a DLL (protip: one is bigger).[/QUOTE] Yea the Lua5.1 is bigger, so should i link to the smaller one to make it static?
[QUOTE=Richy19;27014099]Got it working. Are there any good links to using lua with with C++? Like using lua variables in C++, accessing C++ functions with lua and stuff like that. [editline]28th December 2010[/editline] Yea the Lua5.1 is bigger, so should i link to the smaller one to make it static?[/QUOTE] No, the bigger one is for static compiling (as all the code is in the lib, and then the executable). The smaller one just wants lua51.dll at startup, and uses the code from there.
Both libs are the same 5kb the lua5.1.dll is 74kb and the lua51.dll is 4kb Which is the static one? BTW i tried linking both and none of them copied the dll to the executable location
[QUOTE=Richy19;27014466]Both libs are the same 5kb the lua5.1.dll is 74kb and the lua51.dll is 4kb Which is the static one? BTW i tried linking both and none of them copied the dll to the executable location[/QUOTE] Oh you're talking about dlls. I have no idea then, sorry :(.
[QUOTE=Richy19;27014099]Got it working. Are there any good links to using lua with with C++? Like using lua variables in C++, accessing C++ functions with lua and stuff like that.[/QUOTE] What's wrong with the [url=http://www.lua.org/pil/24.html][b]Lua manual[/b][/url]?
[QUOTE=Overv;27016715]What's wrong with the [url=http://www.lua.org/pil/24.html][b]Lua manual[/b][/url]?[/QUOTE] Its ok, but id rather have a purpose tutorial that goes straight to the point
I'm writing up some non-working C++ code to get an idea of a good API that I can implement. [cpp]int main(void) { ... // Application is /opt/application/test.bin IPath path1 = filesystem->getPath("./"); IPath path2 = filesystem->getPath("test/"); // path1.getType() == EFileTypeDirectory // (!failPath) == (path1.getType() == EFileTypeNone) // (path1 + path2) == "/opt/application/test/" IPath path3 = filesystem->getPath("/opt/"); // (path2 - path3) == "../../" // Relative Path. // (path3 - path2) == "./application/test/" // Relative Path. IPath path4 = filesystem->getPath(path2 + "testFile"); // path1.getType() == EFileTypeFile IDirectory directory1 = filesystem->getDirectory(path2); // ./test IFile file1 = filesystem->getFile(path4); // ./test/testFile std::vector<IPath> directoryContents = directory1.getContents(); for(std::vector<IPath>::iterator path = directoryContents.begin(); path != directoryContents.end(); ++path) { // Only one path here: testFile IFile file2 = filesystem->getFile(*path); // (file1 == file2) == true file2->write() << "Look, I can write to files using streams!" << flush; std::string testText; file2->read() << testText; } ... }[/cpp] Would anybody use that?
I just (well, 12 hours ago) tried to think about how to move a rectangle out of another rectangle for 3 fucking hours before falling asleep and I still don't know how. Please assist me.
[cpp]void moveSecondRectOutOfFirstRect(const Rect &a, Rect &b) { Rect::PositionType temp = a.bottom - b.top; if(temp >= 0) return; //a.bottom lies over b.top Rect::PositionType dy = a.top - b.bottom; if(dy <= 0) return; //b.bottom lies over a.top if(-temp < dy) dy = temp; //selects the smaller dy temp = a.right - b.left; if(temp >= 0) return; //a.right lies left of b.left Rect::PositionType dx = a.left - b.right; if(dx <= 0) return; //b.right lies left of a.left if(-temp < dx) dx = temp; //selects the smaller dx if(std::abs(dx) < std::abs(dy)) b.move(dx, 0); else b.move(0, dy); }[/cpp] This will move the second rect passed to the function out of the first rect with the smallest motion required. Code untested.
[QUOTE=Dlaor-guy;27023317]I just (well, 12 hours ago) tried to think about how to move a rectangle out of another rectangle for 3 fucking hours before falling asleep and I still don't know how. Please assist me.[/QUOTE] It sounds like you're looking for something like SAT (Separate Axis Theorem). [url=http://www.metanetsoftware.com/technique/tutorialA.html]Here's a good tutorial.[/url]
I just have a simple question: What are some GREAT books to read for learning how to program. I'm talking concepts, not languages.
[QUOTE=Werem00se;27024339]I just have a simple question: What are some GREAT books to read for learning how to program. I'm talking concepts, not languages.[/QUOTE] [url]http://www.amazon.com/Art-Computer-Programming-Fundamental-Algorithms/dp/0201896834/ref=sr_1_2?ie=UTF8&qid=1293547308&sr=8-2[/url] And the rest of the series. There are none better if you can understand them.
[QUOTE=yakahughes;27024566][url]http://www.amazon.com/Art-Computer-Programming-Fundamental-Algorithms/dp/0201896834/ref=sr_1_2?ie=UTF8&qid=1293547308&sr=8-2[/url] And the rest of the series. There are none better if you can understand them.[/QUOTE] I'm already buying a C++ book, I can't afford that right now.
[QUOTE=ZeekyHBomb;27023852][cpp]void moveSecondRectOutOfFirstRect(const Rect &a, Rect &b) { Rect::PositionType temp = a.bottom - b.top; if(temp >= 0) return; //a.bottom lies over b.top Rect::PositionType dy = a.top - b.bottom; if(dy <= 0) return; //b.bottom lies over a.top if(-temp < dy) dy = temp; //selects the smaller dy temp = a.right - b.left; if(temp >= 0) return; //a.right lies left of b.left Rect::PositionType dx = a.left - b.right; if(dx <= 0) return; //b.right lies left of a.left if(-temp < dx) dx = temp; //selects the smaller dx if(std::abs(dx) < std::abs(dy)) b.move(dx, 0); else b.move(0, dy); }[/cpp] This will move the second rect passed to the function out of the first rect with the smallest motion required. Code untested.[/QUOTE] Turned that into: [cpp]void GameManager::MoveSecondRectOutOfFirstRect(const sf::FloatRect &a, sf::FloatRect &b) { float temp = a.Bottom - b.Top; if(temp >= 0) return; //a.bottom lies over b.top float dy = a.Top - b.Bottom; if(dy <= 0) return; //b.bottom lies over a.top if(-temp < dy) dy = temp; //selects the smaller dy temp = a.Right - b.Left; if(temp >= 0) return; //a.right lies left of b.left float dx = a.Left - b.Right; if(dx <= 0) return; //b.right lies left of a.left if(-temp < dx) dx = temp; //selects the smaller dx if(std::abs(dx) < std::abs(dy)) b.Offset(dx, 0); else b.Offset(0, dy); }[/cpp] Unfortunately, nothing happens. It seems, according to breakpoints, to always stop at either the first return or the second return: it never gets further than line 7.
I made that logic for +y is up and +x is right. Your coordinate-system could be different; the top left is probably (0,0), so -y would be up (though +x still right).
Hello I'm playing with SFML on C# but I ran on little problem. How can I trigger an event from another class' event? I want MenuText's OnClick event to happen when RenderWindow class's MouseButtonPressed event happens. I have this [code] interface IClickable { event EventHandler OnClick; } class MenuText : String2D, IClickable { public event EventHandler OnClick; //Rest of the code } class Program { static void Main(string[] args) { // Create the main window RenderWindow app = new RenderWindow(new VideoMode(800, 600), "fffffffffffff"); app.Closed += new EventHandler(OnClose); app.MouseButtonPressed +=new EventHandler<MouseButtonEventArgs>(app_MouseButtonPressed); // Create a graphical string to display // Start the game loop while (app.IsOpened()) { // Process events app.DispatchEvents(); // Clear screen app.Clear(); // Update the window app.Display(); } } static MenuText startGame; //Initialized elsewhere static void app_MouseButtonPressed(object sender, MouseButtonEventArgs e) { //Ok, so when this happens it should trigger startGame's //OnClick event. How can I do this? I'm shit at coding omg } //Rest of the code } [/code]
[QUOTE=ZeekyHBomb;27025109]I made that logic for +y is up and +x is right. Your coordinate-system could be different; the top left is probably (0,0), so -y would be up (though +x still right).[/QUOTE] Could you tell me what I'd have to flip around so I don't have to sit through hours of debugging by flipping the wrong variables?
[cpp] float temp = a.Bottom - b.Top; if(temp <= 0) return; //a.bottom lies over b.top float dy = a.Top - b.Bottom; if(dy >= 0) return; //b.bottom lies over a.top if(-temp < dy) dy = temp; //selects the smaller dy[/cpp] If the original algorithm was okay, this should do it. You should probably just write a few examples down on paper to see if it'd take the right branches.
[QUOTE=Dlaor-guy;27026106]Could you tell me what I'd have to flip around so I don't have to sit through hours of debugging by flipping the wrong variables?[/QUOTE] You'd probably be better off setting your view so it makes a "proper" cartesian plane. As, (0,0) being the middle of your screen. [url]http://sfml-dev.org/tutorials/1.6/graphics-views.php[/url]
Hey I got a small problem with my Regex in my programm, I used Expresso to make it and test it, and it works just fine there, but once I escape it and put it in my programm it seems to match the inverse :/ The original regex = (?<=\s)"[^"]*" Once I escape it = (?<=\\s)\"[^\"]*\" I use it to find quoted text, here is an exemple text I use: [code] "AddonInfo" { "name" "CS:S Content" "version" "1.0" "up_date" "5th August 2006" "author_name" "Valve" "author_email" "n/a" "author_url" "http://www.counter-strike.net/" "info" "Contains the default Garry's Mod content (spawnmenus, playermodels, map icons) for Counter-Strike" // Won't be active unless the following GCFs are available and // are mounted "GCFRequires" { "0" "240" } } [/code] Any help would be awesome! The programm is written in C#
Sorry, you need to Log In to post a reply to this thread.