[QUOTE=high;34156709]I was hoping to do a generic unbox method but apparently it cant tell what return type you want. [/QUOTE]
Combined both methods.
[csharp] public class BotEx : Bot
{
public string Text { get; set; }
static readonly List<IFields> SFields = new List<IFields>
{
new Fields<BotEx, string>((b, o) => b.Text = o, b => b.Text),
};
static IEnumerable<IFields> fields;
public override IEnumerable<IFields> Fields
{
get { return fields ?? (fields = base.Fields.Concat(SFields)); }
}
}[/csharp]
A little bit more setup but worth it. No longer have to write 2 separate Read/Write methods with the exact same code which can easily get out of sync.
[url]http://pastebin.com/H4hBXmDv[/url]
[QUOTE=garry;34158207]That's a pretty cool idea - you making a `best shot` app?[/QUOTE]
That reminds me of that one time when I was playing while being drunk, and I kicked ass and sank 4 balls with a single shot, and they even were the right ones.
Went to melbjs tonight, saw a couple of interesting talks and put my name down to do a talk on Twostroke next month (if you're in Melbourne (read: nobody) you should come along!)
In somewhat related news, Twostroke can now run the CoffeeScript compiler over itself! (I haven't checked if the output is [i]correct[/i] yet, but it doesn't throw any parse/compile errors and the output definitely looks correct!)
I also made Twostroke a shit load faster by caching some expensive stuff that I was calculating each time a function was closed over.
Wrote this little snippet to save my last directory and restore it again when I start my msys bash shell:
[php]function on_hangup ()
{
pwd > ~/.bash_lastdir
exit
}
trap on_hangup SIGHUP
[ -s ~/.bash_lastdir ] && [ -s `cat ~/.bash_lastdir` ] && cd `cat ~/.bash_lastdir` && rm ~/.bash_lastdir[/php]
Put it in /home/.profile if you'd like to have that feature.
[editline]11th January 2012[/editline]
Only works with mintty though.
[editline]11th January 2012[/editline]
FUCK, PERL IS BUILDING.. FUCK
[editline]11th January 2012[/editline]
[QUOTE]`sh cflags "optimize='-O2'" perlapi.o` perlapi.c
CCCMD = gcc -DPERL_CORE -c -DWINVER=0x0500 -DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -mwin32 -mms-bitfields -march=i686 -L/usr/local/lib -L/usr/lib -I/usr/local/include -I/usr/include -I/include -fno-strict-aliasing -pipe -O2 -Wall -W -Wextra -Wdeclaration-after-statement -Wendif-labels
perlapi.c: In function `Perl_Gppaddr_ptr':
perlapi.c:81: error: initializer element is not constant
perlapi.c: In function `Perl_Gcheck_ptr':
perlapi.c:86: error: initializer element is not constant
perlapi.c: In function `Perl_Gfold_locale_ptr':
perlapi.c:91: error: initializer element is not constant
make: *** [perlapi.o] Error 1
[/QUOTE]
FUCK YOU PERL
[QUOTE=amcfaggot;34156636]That doesn't explain two Lua states running concurrently; one which doesn't know anything about the other's bindings, as well as being a different dialect.[/QUOTE]
It actually does. The LuaJIT instance doesn't know the GLua types, but it doesn't need to. It only handles the references. He gives it the references, pushes them as-is to GLua, which then converts them back to objects and uses them.
[QUOTE=garry;34158207]That's a pretty cool idea - you making a `best shot` app?[/QUOTE]
Yeah. Not sure if it's gonna work yet. Gonna go to the pool hall this week and take a better shot and try with that. [url=http://alexturpin.net/pool/]Here's the code if anyone's interested[/url]. It's JavaScript, so check the page source.
[cpp]/* -*- buffer-read-only: t -*-
*
* perlapi.c
*
* Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999,
* 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*
* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
* This file is built by embed.pl from data in embed.fnc, embed.pl,
* pp.sym, intrpvar.h, and perlvars.h.
* Any changes made here will be lost!
*
* Edit those files and run 'make regen_headers' to effect changes.
*
*
* Up to the threshold of the door there mounted a flight of twenty-seven
* broad stairs, hewn by some unknown art of the same black stone. This
* was the only entrance to the tower; ...
*
* [p.577 of _The Lord of the Rings_, III/x: "The Voice of Saruman"]
*
*/[/cpp]
So their coders have time to add Tolkien quotes to their code but not actually make it work. Perfect.
[QUOTE=Xeon06;34155586]Tried my hand at pool table detection for eventual recognition of the individual balls. Gonna need the whole table in the shot I think.
[img]http://i.imgur.com/YGP6d.png[/img][/QUOTE]
Projects like that are awesome to make and use, but it's a shame that observations that are so easy to do with our eyes and human brain are so much more complicated to replicate on a computer.
Are there any way to clear the java console?
String s = "xxxx";
s *= -10000;
System.out.println(s);
[QUOTE=Overv;34160085]Projects like that are awesome to make and use, but it's a shame that observations that are so easy to do with our eyes and human brain are so much more complicated to replicate on a computer.[/QUOTE]
They are very fun indeed. I thought about how the human brain works in the case of pathfinding around dynamic obstacles(crowd of humans), and then I tried to develop an algorithm that works realtime in dynamic enviroments. Think robots that are able to perform a volumetric analysis using some kind of camera(kinect) on moving objects.
Then apply this to a moving object in a game. The good thing is that you can combine the volumetric analysis with already existing data in memory and you have tools you can use (raytracing and checking if a point is inside something)
The problem that I am working on is to find a path from point A to point B through a complex map with tight spots and dynamic moving obstacles using a fancy octree point plotting(lazy prm) combined with a modified A* pathfinding algorithm with path optimizing.
Think a moving flying object in gmod, It has to navgate from spawn to your house, then it has to find an entrance to your house, then it has to find the room you're in and the entrance to that room, all in one go.
The crude idea is there, it's almost working on paper, it sounds like bullshit and it probably is. I'm probably overcomplicating stuff and there is probably a working algorithm that does this already.
What the fuck?
[cpp]#ifndef PERL_GLOBAL_STRUCT
/* A few evil special cases. Could probably macrofy this. */
#undef PL_ppaddr
#undef PL_check
#undef PL_fold_locale
Perl_ppaddr_t** Perl_Gppaddr_ptr(pTHX) {
static Perl_ppaddr_t* const ppaddr_ptr = PL_ppaddr;
PERL_UNUSED_CONTEXT;
return (Perl_ppaddr_t**)&ppaddr_ptr;
}
Perl_check_t** Perl_Gcheck_ptr(pTHX) {
static Perl_check_t* const check_ptr = PL_check;
PERL_UNUSED_CONTEXT;
return (Perl_check_t**)&check_ptr;
}
unsigned char** Perl_Gfold_locale_ptr(pTHX) {
static unsigned char* const fold_locale_ptr = PL_fold_locale;
PERL_UNUSED_CONTEXT;
return (unsigned char**)&fold_locale_ptr;
}
#endif[/cpp]
They #undef shit then use them as initialisers? What the fuck is wrong with whoever wrote this?
[QUOTE=r0b0tsquid;34157843]Working on arrays at the minute, ironed out a few issues as well - you can do stuff like this now:
[img]http://i.imgur.com/PaJ4A.png[/img]
Passing a procedure as an argument to a procedure! :D[/QUOTE]
How accurate is it?
Did you write your own libraries or are you using external ones?
[QUOTE=Killuah;34160507]How accurate is it?
Did you write your own libraries or are you using external ones?[/QUOTE]
I think he mentioned that he used wxWidgets.
[code]$ perl -v
This is perl 5, version 12, subversion 3 (v5.12.3) built for msys-thread-multi-64int
[/code]
Oh god..
[editline]11th January 2012[/editline]
tears of joy
I think I'm having a stroke
I rewrote the ConCommand bindings. They work like I expected. Except they still disappear when I go ingame.
Which is really making me go WTF now. I managed to debug it a bit. When I print the ConCommand object in the menu, it prints this:
[code]ConCommand [ir_lua_run]: 1, 0x00413638[/code]
ConCommand is the class name. ir_lua_run is the command. 1 is the bool for ConCommand::IsRegistered. The last thing is the address of the object.
I also stuck a print in the paint hook to see if it disappears.
While still in the loading screen:
[code]ConCommand [ir_lua_run]: 1, 0x00413638[/code]
But at one point this happens:
[code]ConCommand [ir_lua_r ]: 1, 0x00413638[/code]
Oh...kay. Two characters of the name disappeared? What.
At this point I'm in the menu, I was fast enough to type ir_ and see "ir_lua_r" in the autocomplete list. So it's still registered, but the name is changing.
Couple seconds later:
[code]ConCommand []: 1, 0x00413638[/code]
So the name has completely disappeared. Interesting. This would explain why typing "ir_lua_run" does nothing, as if the command was unregistered.
Next, I created an instance of LuaCCommand in C++ instead of Lua. Just a test, with a nil object as callback. It worked, the name didn't mutate. So the name changing was related to how Lua or Luabind handles strings... hmm.
As a temporary hack I created a separate name variable holding a copy of the name, and overrode GetName to return that. The commands now work in-game.
Am I doing something horribly wrong in the code ([url]http://pastie.org/3167400[/url]) or is it just Lua/Luabind doing something weird with the strings?
[QUOTE=raBBish;34162171]Am I doing something horribly wrong in the code ([url]http://pastie.org/3167400[/url]) or is it just Lua/Luabind doing something weird with the strings?[/QUOTE]
[cpp]// Oh well...
#define private public
#include <convar.h>
#include <icvar.h>
#undef private[/cpp]
My eyes are bleeding.
[editline]11th January 2012[/editline]
Use tolua++
[QUOTE=voodooattack;34162241][cpp]// Oh well...
#define private public
#include <convar.h>
#include <icvar.h>
#undef private[/cpp]
My eyes are bleeding.[/QUOTE]
Well, besides that :v:
I just need access to couple private members, and I have the SDK as a submodule from an external repo, so I can't change the files themselves.
[QUOTE=voodooattack;34162241]Use tolua++[/QUOTE]
Gee, thanks for the answer. Really helped and all. How about explaining why I should use it over Luabind?
I'm trying to find out a way to check if a directory exists or not.
[csharp]
private FtpWebRequest CreateRequest(string serverpath)
{
FtpWebRequest request = WebRequest.Create(new Uri(_baseUri, serverpath)) as FtpWebRequest;
request.Credentials = _creds;
request.Timeout = Timeout;
return request;
}
public bool DirectoryExists(string path)
{
FtpWebRequest request = CreateRequest("this/folder/does/not/exist");
request.Method = WebRequestMethods.Ftp.PrintWorkingDirectory;
FtpWebResponse response = request.GetResponse() as FtpWebResponse;
System.Diagnostics.Debug.WriteLine(response.StatusDescription);
response.Close();
return false;
}
[/csharp]
However, whether that path exists or not, it always prints this:
[code]257 "/" is your current location[/code]
Ugh. Why can't it just fail like all the examples everywhere suggest it would?
[QUOTE=raBBish;34162329]Well, besides that :v:
I just need access to couple private members, and I have the SDK as a submodule from an external repo, so I can't change the files themselves.
Gee, thanks for the answer. Really helped and all. How about explaining why I should use it over Luabind?[/QUOTE]
When you have to redefine keywords and break programming taboos to get what you want, it might be a good choice to rethink your approach.
I consider tolua++ to be superior to Luabind, simply because it does it the way it should be done, using an external tool/generator. This makes the code [I]a lot[/I] simpler and much cleaner. Not to mention compile times.
[QUOTE=voodooattack;34162566]When you have to redefine keywords and break programming taboos to get what you want, it might be a good choice to rethink your approach.
I consider tolua++ to be superior to Luabind, simply because it does it the way it should be done, using an external tool/generator. This makes the code [I]a lot[/I] simpler and much cleaner. Not to mention compile times.[/QUOTE]
That redefining has nothing to do with the Lua bindings. It's simply because I want to be able to change ConVars' names by changing the private member m_pszName.
Can tolua++ handle Source headers ([url=http://hg.alliedmods.net/hl2sdks/hl2sdk-ob-valve/file/tip/public/tier1/convar.h]convar.h[/url] for example) without choking? If not, it would mean more work for me, since I'd have to write wrappers for everything, in which case I'd rather use normal Lua. I chose Luabind because it helps me work faster.
Also, my compile times are fine, thanks. 15 seconds for a full rebuild.
Does anyone know if there is a way to decompile gamemaker assets? as in graphics
[QUOTE=raBBish;34162329]Gee, thanks for the answer. Really helped and all. How about explaining why I should use it over Luabind?[/QUOTE]
I found LuaBind to be generally very unpleasant to use because it increases compile times exponentially.
[QUOTE=horsedrowner;34162475]I'm trying to find out a way to check if a directory exists or not.
[csharp]
private FtpWebRequest CreateRequest(string serverpath)
{
FtpWebRequest request = WebRequest.Create(new Uri(_baseUri, serverpath)) as FtpWebRequest;
request.Credentials = _creds;
request.Timeout = Timeout;
return request;
}
public bool DirectoryExists(string path)
{
FtpWebRequest request = CreateRequest("this/folder/does/not/exist");
request.Method = WebRequestMethods.Ftp.PrintWorkingDirectory;
FtpWebResponse response = request.GetResponse() as FtpWebResponse;
System.Diagnostics.Debug.WriteLine(response.StatusDescription);
response.Close();
return false;
}
[/csharp]
However, whether that path exists or not, it always prints this:
[code]257 "/" is your current location[/code]
Ugh. Why can't it just fail like all the examples everywhere suggest it would?[/QUOTE]
Maybe your ftp server is redirecting to '/' when it gets an invalid directory.
[QUOTE=high;34162811]Maybe your ftp server is redirecting to '/' when it gets an invalid directory.[/QUOTE]
Well, it prints that even if I create a request to a valid, existing directory.
[QUOTE=raBBish;34162674]That redefining has nothing to do with the Lua bindings. It's simply because I want to be able to change ConVars' names by changing the private member m_pszName.
Can tolua++ handle Source headers ([url=http://hg.alliedmods.net/hl2sdks/hl2sdk-ob-valve/file/tip/public/tier1/convar.h]convar.h[/url] for example) without choking? If not, it would mean more work for me, since I'd have to write wrappers for everything, in which case I'd rather use normal Lua. I chose Luabind because it helps me work faster.
Also, my compile times are fine, thanks. 15 seconds for a full rebuild.[/QUOTE]
Yeah it can, considering that you'll have to write a 'clean' version of the header and add it to a package file for the generator to work on.
This allows you to specify exactly what you want to include or exclude on the Lua side.
Small tip: If you don't need to expose it, don't.
[QUOTE=horsedrowner;34162862]Well, it prints that even if I create a request to a valid, existing directory.[/QUOTE]
Capture your request packets and make sure your library isn't doing something odd.
[QUOTE=raBBish;34159650]It actually does. The LuaJIT instance doesn't know the GLua types, but it doesn't need to. It only handles the references. He gives it the references, pushes them as-is to GLua, which then converts them back to objects and uses them.[/QUOTE]
Sounds like you'd need to detect what references were usable in LuaJIT and which weren't, otherwise you lose the benefit of speed (which is the whole point). I'm awfully sure he's not magically doing partial execution.
I'll ask him about the code later today, sounds interesting, but ultimately I'm not understanding how you can really do anything meaningful with this.
[editline]11th January 2012[/editline]
[QUOTE=voodooattack;34162566]When you have to redefine keywords and break programming taboos to get what you want, it might be a good choice to rethink your approach.
I consider tolua++ to be superior to Luabind, simply because it does it the way it should be done, using an external tool/generator. This makes the code [I]a lot[/I] simpler and much cleaner. Not to mention compile times.[/QUOTE]
You have literally no idea what you're talking about. The only thing that made sense in your rambling was compile times, which anyone can figure out after using LuaBind for about 15 seconds (then realizing their compile isn't done).
[QUOTE=amcfaggot;34163056]You have literally no idea what you're talking about. The only thing that made sense in your rambling was compile times, which anyone can figure out after using LuaBind for about 15 seconds (then realizing their compile isn't done).[/QUOTE]
What are YOU talking about? Care to elaborate?
[QUOTE=raBBish;34162674]That redefining has nothing to do with the Lua bindings. It's simply because I want to be able to change ConVars' names by changing the private member m_pszName.
Can tolua++ handle Source headers ([url=http://hg.alliedmods.net/hl2sdks/hl2sdk-ob-valve/file/tip/public/tier1/convar.h]convar.h[/url] for example) without choking? If not, it would mean more work for me, since I'd have to write wrappers for everything, in which case I'd rather use normal Lua. I chose Luabind because it helps me work faster.
Also, my compile times are fine, thanks. 15 seconds for a full rebuild.[/QUOTE]
I'm kinda gettin' a kick out of your failures (in a respective manner), because I had to go through the exact same shit you're going through right now. You'll figure out the issue, I'm sure.
Ignore voodoo, he doesn't know what he's talking about. Focus on managing ConVar and ConCommand memory manually. That's what you need to take care of, and it's why your commands are disappearing.
You'll also need to pass a new string to the commands instead of a typical luaL_checkstring(L, idx) (or similar) call, considering these values are interned and will be garbage collected, and the command objects in question do not copy passed strings.
[editline]11th January 2012[/editline]
[QUOTE=voodooattack;34163215]What are YOU talking about? Care to elaborate?[/QUOTE]
Who gives a shit what library you use to bind functions, it has nothing to do with handling the objects he's dealing with.
Sorry, you need to Log In to post a reply to this thread.