--- Log opened Sat Mar 10 00:00:56 2007 |
00:06 | | Meh is now known as gnolam |
00:10 | | Derakon [~Derakon@Nightstar-12737.sea2.cablespeed.com] has joined #code |
00:39 | | * Derakon writes some hideously expensive quadtree-expansion code. |
00:41 | | gnolam [Lenin@Nightstar-13557.8.5.253.se.wasadata.net] has quit [Quit: I wonder if I should come back...] |
00:56 | < Derakon> | Oooh..."illegal hardware instruction"! |
00:56 | <@Vornicus> | Okay, that's just impressive. |
00:57 | <@McMartin> | You smashed your stack and returned somewhere weird, I would guess. |
00:58 | < Derakon> | Hrm...I think this is a case of infinite recursion, actually. |
00:58 | | * Derakon eyes his console buffer. |
00:58 | <@Vornicus> | ...wait, did you get Stack Collision With A Heap? |
00:58 | < Derakon> | Just illegal hardware instruction. |
00:59 | < Derakon> | gdb sez: |
00:59 | < Derakon> | Program received signal EXC_BAD_ACCESS, Could not access memory. |
00:59 | < Derakon> | Reason: KERN_INVALID_ADDRESS at address: 0xbf7ffffc |
00:59 | < Derakon> | 0x9000297e in szone_malloc () |
01:00 | < Derakon> | Ahh, there we go, heh. I should verify not only that I am the root node before expanding the quadtree, but also that I have a reason to expand the tree. "(parent == NULL)" -> "(parent == NULL && !results.empty())" |
01:00 | < Derakon> | I r smrt. |
01:07 | < Derakon> | Man, I hardly ever get plain old segfaults any more. The most vanilla I get is bus errors, and even that's not the majority. |
01:14 | | Reiver is now known as ReivOut |
01:14 | | * Derakon finds himself wanting to do "temp = this; this = newNode; newNode = temp;". ;.; |
01:15 | <@Vornicus> | woo swaps |
01:16 | <@Vornicus> | well, except that you have to do it in the right order. |
01:16 | < Derakon> | Swaps that involve modifying the this pointer, more to the point. |
01:16 | < MyCatVerbs> | Mmmmmm, tea... <3 |
01:16 | <@Vornicus> | ...oh, yes |
01:17 | < MyCatVerbs> | Derakon: the only immediately sensible way to effect something like a change to the this pointer I can think of would be to put in (ewww, ick) an extra layer of indirection with a smart pointer. |
01:18 | < Derakon> | Well, fortunately for my circumstances, there's a hack I can do to fix this particular problem. |
01:19 | < Derakon> | Namely, this situation only comes up when I supplant the root node with a new root (so the object holding the root needs to update its pointer). There's only one class allowed to hold roots, so I can just have a pointer to that class (whee circularity!) and have it be null when I'm not at a root node. |
01:19 | < Derakon> | Horrible hack, though. |
01:19 | < MyCatVerbs> | I saw "ewww ick" because C++ gets grottier at around O(n^2) of the cleverness of what you try to do with it. |
01:19 | < MyCatVerbs> | That sounds rather sensible. |
01:20 | | * Derakon creates a field "ultima". |
01:57 | | Mahal [~Mahal@Nightstar-4998.worldnet.co.nz] has quit [Quit: fuk off i got biskit] |
02:17 | | timelady [~romana@Nightstar-9473.lns10.adl2.internode.on.net] has joined #Code |
02:20 | | Mahal [~Mahal@Nightstar-4998.worldnet.co.nz] has joined #Code |
02:20 | | mode/#code [+o Mahal] by ChanServ |
02:23 | <@ToxicFrog> | Derakon: this is why I implemented the Morph() function for my Lua OO framework~ |
02:52 | | Netsplit DeepThought.NY.US.Nightstar.Net <-> Troika.TX.US.Nightstar.Net quits: @Pi, Derakon, @Vornicus, @Raif, Serah, AnnoDomini, @jerith, @Mahal, SupineSoldier, @Chalain |
02:53 | | ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has quit [Client exited] |
02:53 | | Netsplit over, joins: Chalain, jerith |
02:53 | | mode/#code [+o Chalain] by ChanServ |
02:53 | | Netsplit over, joins: Raif, Pi |
02:53 | | mode/#code [+o jerith] by ChanServ |
02:53 | | mode/#code [+o Raif] by ChanServ |
02:53 | | Netsplit over, joins: Serah, Vornicus, SupineSoldier |
02:53 | | Netsplit over, joins: AnnoDomini |
02:53 | | mode/#code [+o Pi] by ChanServ |
02:53 | | Netsplit over, joins: Derakon |
02:53 | | Netsplit over, joins: Mahal |
02:53 | | Clairvoire [~Cerulean@Nightstar-10302.columbus.res.rr.com] has joined #Code |
02:53 | | mode/#code [+o Vornicus] by ChanServ |
02:53 | | mode/#code [+o Mahal] by ChanServ |
02:53 | | ToxicFrog [~ToxicFrog@Admin.Nightstar.Net] has joined #code |
02:53 | | mode/#code [+o ToxicFrog] by ChanServ |
02:54 | | Janus [~Cerulean@Nightstar-10302.columbus.res.rr.com] has quit [Ping Timeout] |
03:06 | | Clairvoire is now known as Jan[bathipoo] |
03:24 | | timelady [~romana@Nightstar-9473.lns10.adl2.internode.on.net] has quit [Quit: run away! run away!] |
04:02 | < MyCatVerbs> | OMFGWTFBBQ? |
04:03 | < MyCatVerbs> | http://www.codinghorror.com/blog/archives/000781.html <-- has one of the most egreriously appalling replies tucked away in the comments that I have ever seen. |
04:03 | | Jan[bathipoo] is now known as Janus |
04:03 | < MyCatVerbs> | "Instead of using recursion, it's often faster to use a Stack." |
04:04 | < MyCatVerbs> | AAAAAAARGH! Diediediediediedie and BURN IN PREMATURE OPTIMIZATION HELL! |
04:05 | < MyCatVerbs> | And that goes *doubly* on platforms where an equivalent to -fomit-frame-pointer is available. Triply for anyone working in a language with strong optimizations to make funcalls cheap like ML or a decent compiled Scheme. |
04:09 | | * Janus falls into the chasm. Dies on the pointy rocks. |
04:09 | < MyCatVerbs> | ...which chasm? |
04:12 | | * Janus tries feebly to highlight the statement. Fails for some reason. Wensday Thursday Friday? |
04:13 | < Janus> | "I assumed anyone applying for a job as a programmer had already crossed this chasm" |
04:18 | < Janus> | Recursion is much better than a stack. Quicksort()'s are proof of that, being made of kittens and sunshine and all. |
04:22 | <@Vornicus> | Recursion /is/ a stack. |
04:22 | <@Vornicus> | Tail recursion isn't even that, it's just "replace the parameters with new ones, call me on those" |
04:23 | < MyCatVerbs> | I prefer to think of tail recursion by a different metaphor entirely. |
04:23 | <@Vornicus> | It sort of is |
04:23 | < MyCatVerbs> | Namely, sunshine and kittens lapping up strawberry ice cream. |
04:23 | <@Vornicus> | Hey! |
04:23 | <@Vornicus> | that's /my/ strawberry ice cream! |
04:24 | < MyCatVerbs> | While simultaneously The Dude travels back and forth across the horizon on a unicycle with the largest doobie you have ever seen firmly glued to his lips. |
04:29 | | Netsplit DeepThought.NY.US.Nightstar.Net <-> Troika.TX.US.Nightstar.Net, Blargh.CA.US.Nightstar.Net quits: @Pi, Forj, MyCatVerbs, Derakon, @Vornicus, @Raif, Serah, Thaqui, Janus, AnnoDomini, (+5 more, use /NETSPLIT to show all of them) |
04:29 | | Netsplit over, joins: Chalain, jerith, Raif, Pi |
04:29 | | mode/#code [+o Chalain] by ChanServ |
04:29 | | mode/#code [+o jerith] by ChanServ |
04:29 | | mode/#code [+o Raif] by ChanServ |
04:29 | | Netsplit over, joins: Serah, Vornicus, SupineSoldier, AnnoDomini, Derakon |
04:29 | | mode/#code [+o Pi] by ChanServ |
04:29 | | Netsplit over, joins: Mahal, Janus |
04:29 | | mode/#code [+o Vornicus] by ChanServ |
04:29 | | mode/#code [+o Mahal] by ChanServ |
04:29 | | Mahal2 [~reiver@Nightstar-435.ubs-dsl.xnet.co.nz] has joined #Code |
04:29 | <@ToxicFrog> | Tail recursion is like exec(), except it replaces the function rather than the process. |
04:30 | | ReivOut [~reiver@IRCop.Nightstar.Net] has quit [Ping Timeout] |
04:33 | <@Vornicus> | In some circles, tail recursion is called a "certificate" - the answer for a particular input is based on the answer for a less complex input. |
04:36 | <@McMartin> | Tail Recursion lets you implement GOTO. |
04:36 | < Derakon> | This is a good thing? |
04:37 | <@McMartin> | Well, it's proof that it's The Only Control Structure You Need |
04:37 | < Derakon> | Ahh. |
04:38 | < Derakon> | 'Course, the Only Control Structure You Need is also subtract and branch if negative. |
04:39 | <@Vornicus> | heh |
04:39 | < Derakon> | And now, having re-hydrated, I really should get a shower. BBIAB. |
04:40 | <@McMartin> | Well, that's "jump to arbitrary location" |
04:40 | <@McMartin> | Which I'm counting as a Goto. |
04:41 | <@McMartin> | Hum. |
04:42 | | * McMartin finds the reward for beating Lists and Lists. |
04:42 | <@Vornicus> | whut? |
04:43 | <@McMartin> | OK, so, step back three or four steps first. |
04:43 | <@McMartin> | Lists and Lists is a Scheme 'terp, with some problems to work through, for the Z-Machine. |
04:43 | <@McMartin> | In Inform. |
04:43 | <@Vornicus> | ...wacky wacky. |
04:44 | <@McMartin> | http://www.eblong.com/zarf/ftp/lists.z5 |
04:44 | | * McMartin recommends this until all Lispers here! |
04:44 | <@McMartin> | And non-ones, as it has a nice big tutorial, too. |
05:09 | | McMartin [~mcmartin@Nightstar-5796.dsl.pltn13.sbcglobal.net] has quit [Quit: Rebooting because of kernel update] |
05:12 | | McMartin [~mcmartin@75.36.151.ns-11815] has joined #code |
05:12 | | mode/#code [+o McMartin] by ChanServ |
05:16 | < Derakon> | Okay, I think the auto-expanding quadtree is working now. |
05:19 | | Netsplit over, joins: MyCatVerbs, Forj, Thaqui, Chalcy |
05:19 | | mode/#code [+o Chalcy] by ChanServ |
05:21 | | * Derakon makes his first backup of FlatCosmos. |
05:30 | | Vornicus is now known as Vornicus-Latens |
05:57 | | Thaqui [~Thaqui@Nightstar-25354.jetstream.xtra.co.nz] has quit [Quit: This computer has gone to sleep] |
05:59 | < Derakon> | I need to find a way to distinguish the list of ships that are instantiatable from the list of ships that are currently instantiated, with the constraint that "ships" is the latter. |
06:01 | | * Derakon calls the former "hangar" for the moment. |
06:03 | < Derakon> | ...okay, Lua question. I have "hangar = { korg = { various_stats_about_the_korg}}". I'm iterating over elements in hangar: "for ship in hangar do ... end". How do I access the ship's name (in this case, "korg")? |
06:04 | <@ToxicFrog> | for key,value in pairs(hangar) do |
06:04 | < Derakon> | Ahhh. |
06:04 | <@ToxicFrog> | key will be "korg" and value will be the table containing the stats. |
06:04 | < Derakon> | Right. |
06:05 | < Derakon> | Thanks. |
06:05 | <@ToxicFrog> | Also see ipairs. |
06:06 | <@ToxicFrog> | Although, I think that "for <list> in <table> do" is actually a (very version-specific and nonportable!) sugar for "for <list> in pairs(<table>) do" |
06:06 | <@ToxicFrog> | So if it works, you should be able to just go: for key,value in hangar do |
06:06 | < Derakon> | "go"? |
06:06 | <@ToxicFrog> | It's a verb. |
06:06 | < Derakon> | ...ah, not part of the syntax. |
06:08 | | * Derakon mutters at the Lua manual. "Surely there's a way to extra the values of a table as a list, but I can't for the life of me find it." |
06:08 | <@ToxicFrog> | ...how do you mean? |
06:09 | <@ToxicFrog> | I mean, first of all, there's no such thing as a list. You can use tables as lists, but there's no list type. |
06:09 | < Derakon> | korg.graphics = {main = "korga"; light = "korgl"}; |
06:09 | < Derakon> | I want to get {"korga", "korgl"} |
06:09 | <@ToxicFrog> | Aah. So { [1]="korga", [2]="korgl" } |
06:09 | <@ToxicFrog> | This will kind of do it: |
06:09 | <@ToxicFrog> | local list |
06:10 | <@ToxicFrog> | for key,value in pairs(input) do |
06:10 | <@ToxicFrog> | table.insert(list, value) |
06:10 | <@ToxicFrog> | end |
06:10 | < Derakon> | I was kinda hoping for something more compact. |
06:10 | <@ToxicFrog> | However, the order in which stuff goes into the list is entirely undefined. |
06:10 | < Derakon> | Like, say, "list = values(korg.graphics);" |
06:10 | < Derakon> | That doesn't matter. *shrug* |
06:10 | <@ToxicFrog> | function values(input) |
06:10 | <@ToxicFrog> | local list |
06:10 | < Derakon> | Yeah, yeah. :p |
06:10 | <@ToxicFrog> | for key,value in pairs(input) do |
06:10 | <@ToxicFrog> | etc etc |
06:11 | <@ToxicFrog> | Why do you need this anyways? |
06:11 | < Derakon> | Loading assets. The engine cares about the directory in which graphics are stored, but not the name of those graphics as a set. |
06:12 | <@ToxicFrog> | Yeah, but...why does it have to be integer-indexed rather than string-indexed, is what I mean? |
06:13 | < Derakon> | Well, it appears that what I want to do isn't possible anyway. Ahh, well. |
06:13 | <@ToxicFrog> | ...what do you want to do? |
06:13 | < Derakon> | I want to call loadObject, which is a C function that takes a string, and then a set of string pairs. |
06:13 | < Derakon> | I wanted to call loadObject(first_string, list_of_string_pairs). |
06:14 | < Derakon> | But I don't think it'll flatten that for me properly, will it? It'll stay a table. |
06:14 | <@ToxicFrog> | unpack() |
06:14 | <@ToxicFrog> | foo(unpack({ 1, 2, 3 })) is equivalent to foo(1,2,3) |
06:14 | < Derakon> | Oooh, excellent. Thanks! |
06:14 | <@ToxicFrog> | What does LoadObject do? o.O |
06:15 | < Derakon> | Loads all of the graphics for an object type, and associates the type with the graphics. |
06:15 | <@ToxicFrog> | ...what're the stringpairs for? |
06:15 | < Derakon> | So for example, a given ship might have standard rotation graphics, a set of engine glows, and the running lights. |
06:15 | < Derakon> | They map the graphic name (e.g. "main" for the primary graphics, "light" for running lights) to the location for the graphics. |
06:16 | <@ToxicFrog> | Aah. |
06:16 | <@ToxicFrog> | Why the requirement to unpack the table before feeding it to C? |
06:16 | <@ToxicFrog> | Try looking at lua_next() - there's a simple idiom for iterating over table contents. |
06:17 | < Derakon> | Because C expects a list of arguments instead of a table, currently? ¬.¬ |
06:17 | <@ToxicFrog> | This solves both the need to listify it and the need for unpack() |
06:20 | < Derakon> | So given that the first argument is a string, then, I'd get the string, pop it, and then use the sample construct they give. |
06:20 | < Derakon> | http://www.lua.org/manual/5.1/manual.html#lua_next |
06:20 | <@ToxicFrog> | Yes. |
06:20 | <@ToxicFrog> | For the string, try luaL_checkstring(L, 1) |
06:21 | < Derakon> | Yeah. |
06:21 | < Derakon> | That doesn't actually pop it though, IIRC. |
06:21 | < Derakon> | It's a peek. |
06:21 | <@ToxicFrog> | Yeah, but it's at the bottom of the stack *anyways* |
06:22 | <@ToxicFrog> | Unless you're desperate to conserve stack slots, not worth popping. |
06:22 | < Derakon> | Okay, I screwed this up somehow... |
06:22 | < Derakon> | Probably because I'm forgetting how the stack works. :\ |
06:23 | <@ToxicFrog> | Arguments are passed in direct order. |
06:23 | <@ToxicFrog> | Argument 1 is stack element 1, which is at the bottom. |
06:23 | <@ToxicFrog> | Argument N is stack element N and is at the top. |
06:23 | < Derakon> | http://pastie.caboo.se/46001 |
06:24 | < Derakon> | Oh, the table itself would probably help. |
06:24 | < Derakon> | http://pastie.caboo.se/46002 |
06:26 | <@ToxicFrog> | As it says in the manual, lua_next() pops a key from the stack. |
06:26 | <@ToxicFrog> | To start the traversal, use nil |
06:26 | <@ToxicFrog> | So, you need to lua_pushnil(L) before the loop. |
06:26 | < Derakon> | Ahh. |
06:26 | < Derakon> | Or a do-while loop. |
06:26 | <@ToxicFrog> | No. |
06:26 | <@ToxicFrog> | Because nil is not a valid index. |
06:26 | <@ToxicFrog> | Err, not a valid key. |
06:27 | <@ToxicFrog> | Hang on, here's what the stack looks like: |
06:28 | <@ToxicFrog> | /* at start */ // type table |
06:28 | <@ToxicFrog> | lua_pushnil // type table nil |
06:28 | <@ToxicFrog> | while lua_next // type table keyN valueN |
06:28 | | Janus [~Cerulean@Nightstar-10302.columbus.res.rr.com] has quit [Quit: Die die! *shots the die in the fourhead*] |
06:28 | < Derakon> | This is after you cleared the original string, I assume. |
06:28 | <@ToxicFrog> | next() expects to be called with a valid key on top of the stack, or nil to start at the head of the table. |
06:28 | <@ToxicFrog> | ...er? |
06:28 | <@ToxicFrog> | What do you mean? |
06:28 | < Derakon> | Arguments to loadObject are (string, table). |
06:29 | <@ToxicFrog> | Right. |
06:29 | < Derakon> | Or...wait, that's on the bottom, isn't it? Gah. |
06:29 | <@ToxicFrog> | The string is called "type" and is at the bottom of the stack. |
06:29 | <@ToxicFrog> | The table is on top of it. |
06:29 | < Derakon> | I keep expecting FIFO. ¬.¬ |
06:29 | <@ToxicFrog> | You push nil, then call next, which pops nil and replaces it with the first key and the first value. |
06:30 | <@ToxicFrog> | You do whatever, pop the value and call next again. |
06:30 | <@ToxicFrog> | It pops the key and pushes the next key and the the next value. |
06:30 | < Derakon> | Wouldn't that cause values to accumulate on the stack? |
06:31 | <@ToxicFrog> | ....noooo.... |
06:31 | < Derakon> | ...but I'm popping them. |
06:31 | <@ToxicFrog> | You push nil (+1), next pops nil (0) and pushes key, value (+2) |
06:31 | <@ToxicFrog> | You pop value (+1), next pops key (0) and pushes nextkey, nextvalue (+2) |
06:31 | < Derakon> | Right. |
06:31 | <@ToxicFrog> | Etc. |
06:32 | <@ToxicFrog> | Just as it says in the manual. |
06:32 | < Derakon> | It seems kinda weird that next pops only one of them, though I recognize that for the sake of simple while loops, it needs to work in-place. |
06:32 | <@ToxicFrog> | ...how is that at all weird? |
06:32 | < Derakon> | I'd expect it to pop both, or neither. |
06:32 | <@ToxicFrog> | Next is a key-based traversal. |
06:32 | <@ToxicFrog> | Since keys are unique. |
06:32 | <@ToxicFrog> | Thus, from a given key, it can determine what the next key will be. |
06:32 | <@ToxicFrog> | You pass it a table and a key and it returns the next key and the associated value. |
06:33 | <@ToxicFrog> | It doesn't pop the table because that would be Inconvenient. |
06:33 | < Derakon> | Heh. |
06:33 | < Derakon> | Okay, fair point. |
06:33 | < Derakon> | I never was much good with RPN either. ¬.¬ |
06:34 | | SupineSoldier is now known as GeekSoldier |
06:36 | <@ToxicFrog> | Possibly all my time working with postscript and ASM gives me an edge here. |
06:36 | < Derakon> | I mainly worked with lists and trees. |
06:42 | < Derakon> | Hrm...just because I'm moving most of the game logic to Lua doesn't mean I don't have to worry about design. ¬.¬ |
06:42 | | Thaqui [~Thaqui@Nightstar-25354.jetstream.xtra.co.nz] has joined #code |
06:43 | <@ToxicFrog> | This is in fact the case. |
06:47 | < Derakon> | Anyway, bedtime! |
06:47 | < Derakon> | Thanks again for your help. |
06:47 | <@ToxicFrog> | Also bedtime. Ta! |
06:47 | | Derakon is now known as Derakon[AFK] |
07:03 | | Mahal2 is now known as Reiver |
07:55 | | GeekSoldier_ [Rob@Nightstar-4730.pools.arcor-ip.net] has joined #code |
07:56 | | GeekSoldier [Rob@Nightstar-3722.pools.arcor-ip.net] has quit [Killed (NickServ (GHOST command used by GeekSoldier_))] |
07:56 | | GeekSoldier_ is now known as GeekSoldier |
08:46 | | Derakon[AFK] [~Derakon@Nightstar-12737.sea2.cablespeed.com] has quit [Connection reset by peer] |
09:06 | <@jerith> | So, I decided to restart my Erlang hacking with the basics instead of trying to dive straight into the compicated stuff. |
09:07 | <@jerith> | I have an echo server in 20 lines, including the Erlang boilerplate. |
09:07 | <@jerith> | (Only one client, though.) |
09:07 | <@jerith> | Next step is to make it multiclient. |
09:07 | < GeekSoldier> | sweet. |
09:13 | < GeekSoldier> | stupid python question: |
09:13 | < GeekSoldier> | what is the function to test for integer? |
09:15 | < GeekSoldier> | nevermind |
09:15 | | * GeekSoldier facepalms |
09:15 | | * GeekSoldier facepalms again |
09:19 | < GeekSoldier> | if type(item) == int: |
09:20 | | * GeekSoldier facepalms a third time. |
09:20 | <@jerith> | if is_instance(item, int): |
09:20 | <@jerith> | Although I may have the function name wrong. |
09:21 | <@jerith> | It's now multiclient in under 30 lines. Not multiplayer yet. |
09:21 | | * GeekSoldier fixed it. |
09:21 | < GeekSoldier> | erlang is neat, eh? |
09:21 | <@jerith> | Indeed it is. |
09:22 | <@jerith> | I'm wondering how to make it multiplayer. |
09:22 | | You're now known as TheWatcher |
09:22 | <@jerith> | That'll be a little trickier, because I need to keep a list of pids to send to. |
09:22 | < GeekSoldier> | couldn't begin to tell you yet. I've had to put it on the backburner for now. |
09:23 | <@jerith> | I could look up an implementation, but part of the exercise is to train myself to think in its concurrency model. |
09:23 | <@jerith> | Aha! |
09:23 | < GeekSoldier> | nod nod. |
09:24 | <@jerith> | I keep a process running that receives messages. It can receive connect, disconnect and data. Connect and disconnect maintain the pid list, data sends a message to the pid. |
09:27 | <@jerith> | Hmm, how do I go about pulling a pid out of a list? |
09:31 | <@jerith> | lists:delete/2 |
09:31 | < GeekSoldier> | does that work? |
09:33 | <@jerith> | 2> lists:delete(3, [1,2,3,4,5]). |
09:33 | <@jerith> | [1,2,4,5] |
09:33 | <@jerith> | :-) |
09:34 | < GeekSoldier> | impressive. |
09:36 | <@jerith> | Heh. It's in stdlib. :-) |
09:41 | <@McMartin> | Multiplayer echo? |
09:43 | <@jerith> | Sort of like a basic chat server. |
09:43 | <@jerith> | It echoes to everyone, not just you. |
09:46 | | * McMartin nods |
09:46 | <@McMartin> | It's the "Multiplayer" part that was throwing me. |
09:46 | <@McMartin> | Also, woo, dizzy, bedtime. |
09:46 | <@Mahal> | Nini McM |
09:46 | <@jerith> | G'night McM. |
09:47 | <@McMartin> | But first, to reboot back into Linux so I can keep proper logs. |
09:47 | | McMartin [~mcmartin@75.36.151.ns-11815] has quit [Quit: brb] |
09:47 | <@jerith> | I used multiplayer because I had already used multiclient for "a bunch of people can connect at once, but you only get your own echo back". |
09:47 | | Chalcy [~Chalceon@Nightstar-869.bitstream.orcon.net.nz] has quit [Quit: ] |
09:58 | | Forj [~Forj@Nightstar-869.bitstream.orcon.net.nz] has quit [Quit: Gone] |
10:26 | <@jerith> | Multiplayer echo server in 50 lines! |
10:27 | <@jerith> | And two thirds of my debugging was figuring out that I was trying to send a message to the function looping in the client manager process rather than the process itself. |
10:30 | <@jerith> | http://rafb.net/p/B4LU9544.html <-- Yay for erlang! |
10:31 | <@jerith> | Except I can't find a pastebin that'll syntax highlight it. |
10:32 | < Serah> | pastebin.com won't ? |
10:32 | <@jerith> | Nope. |
10:35 | <@EvilDarkLord> | Make your own? =) |
10:36 | <@jerith> | An acquaintance runs http://pastebin.div0.co.za/ and I may be able to convince him to do it. |
10:36 | <@jerith> | Either that or give me his code so I can write the lexer. |
10:53 | < GeekSoldier> | impressive bit of erlangery, there, jerith. |
10:54 | | * jerith takes a bow. |
10:54 | <@jerith> | I've put that on hold in favour of a little PHP hackery at the moment. |
10:54 | <@jerith> | http://qbnz.com/highlighter/geshi-doc.html#language-files |
10:55 | < GeekSoldier> | Now you just need to write code for character-mob interactions! |
10:55 | < GeekSoldier> | :) |
10:55 | <@jerith> | No, I need to hide the networking loop in a gen_server module. |
11:01 | | Mahal is now known as MahalBEDD |
11:42 | | Thaqui [~Thaqui@Nightstar-25354.jetstream.xtra.co.nz] has left #code [Leaving] |
12:07 | <@jerith> | My Erlang thingy now uses player records instead of raw sockets. |
12:07 | <@jerith> | Next plan is to add some smarts to the manager. |
12:07 | <@jerith> | So it can set a player name. |
12:08 | < GeekSoldier> | sweet. so the port and all is in the record? |
12:08 | | * jerith nods. |
13:24 | | Reiver is now known as ReivSLEP |
15:14 | | * jerith sighs at his silliness. |
15:14 | <@jerith> | I'm changing the player's state in the player manager code, but not actually sending it back to the player. |
15:15 | <@jerith> | *player network handler. |
15:15 | <@jerith> | I think I'll have to modify that bit so that the network handler only knows about sockets. |
15:36 | | Vornicus-Latens is now known as Vornicus |
15:39 | | AnnoDomini [~farkoff@Nightstar-29142.neoplus.adsl.tpnet.pl] has quit [Ping Timeout] |
15:45 | | AnnoDomini [~farkoff@Nightstar-29667.neoplus.adsl.tpnet.pl] has joined #Code |
17:08 | | MyCatVerbs [~mycatownz@Nightstar-379.dsl.in-addr.zen.co.uk] has quit [Quit: AAaarrgh.] |
17:12 | | You're now known as TheWatcher[afk] |
18:31 | | You're now known as TheWatcher |
18:32 | <@jerith> | http://www.jerith.za.net/code/bogochat.html |
18:32 | < GeekSoldier> | yay! |
18:47 | | Derakon [~Derakon@Nightstar-12737.sea2.cablespeed.com] has joined #code |
18:50 | | * Derakon eyes the text editor learning curve picture, things there should be a counterpart that maps difficulty of use to power over time. |
19:05 | | Derakon [~Derakon@Nightstar-12737.sea2.cablespeed.com] has left #code [] |
19:36 | | timelady [~romana@Nightstar-9473.lns10.adl2.internode.on.net] has joined #Code |
19:40 | | Syloq [Syloq@NetAdmin.Nightstar.Net] has joined #code |
20:04 | | timelady [~romana@Nightstar-9473.lns10.adl2.internode.on.net] has quit [Quit: run away! run away!] |
20:29 | | Janus [~Cerulean@Nightstar-10302.columbus.res.rr.com] has joined #Code |
20:35 | | Derakon [~Derakon@Nightstar-12737.sea2.cablespeed.com] has joined #code |
20:36 | | timelady [~romana@Nightstar-9473.lns10.adl2.internode.on.net] has joined #Code |
20:39 | | * Derakon grumbles at his broken stackDump function. |
20:40 | | timelady [~romana@Nightstar-9473.lns10.adl2.internode.on.net] has quit [Quit: run away! run away!] |
20:40 | <@ToxicFrog> | stackDump? |
20:40 | < Derakon> | A C function to dump the Lua stack in a human-readable form. |
20:40 | < Derakon> | http://pastie.caboo.se/46062 |
20:41 | < Derakon> | Note that I'm only ever calling it with 1 for the value of start. |
20:42 | <@ToxicFrog> | The call to lua_next needs to be lua_next(L, i) |
20:42 | <@ToxicFrog> | Not lua_next(L, 2) |
20:42 | < Derakon> | Yay! |
20:42 | < Derakon> | I'm a dumbass, but it works now! Thanks. |
20:42 | | * ToxicFrog bows |
20:43 | < Derakon> | Hrm...adding proper handling of all the possible ways to screw this stuff up is going to be annoying. |
20:44 | <@jerith> | Such is always the case. |
20:46 | < Derakon> | (gdb) print this |
20:46 | < Derakon> | $1 = (Animation * const) 0x0 |
20:46 | < Derakon> | That's generally a bad sign. |
20:46 | | MahalBEDD is now known as Mahal |
20:49 | <@ToxicFrog> | ....yeah. |
20:53 | | Forj [~Forj@Nightstar-869.bitstream.orcon.net.nz] has joined #code |
20:54 | | timelady [~romana@Nightstar-9473.lns10.adl2.internode.on.net] has joined #Code |
20:56 | | * Derakon makes stackDump properly recursive, glees. |
21:52 | | GeekSoldier is now known as SleepingSoldier |
21:59 | < Derakon> | TF, another Lua question? ¬.¬ |
21:59 | < Derakon> | http://pastie.caboo.se/46083 |
21:59 | < Derakon> | I'm trying to tack an update function onto my various ships, but I get the error "attempt to call a table value" when I invoke the function. |
22:03 | <@ToxicFrog> | Show me the call? |
22:03 | < Derakon> | It's at the bottom, in the "update" function. |
22:03 | < Derakon> | Line 66. |
22:03 | <@ToxicFrog> | Also, um. |
22:04 | <@ToxicFrog> | Shouldn't it be 'function ships.korg:positionUpdate()' |
22:04 | <@ToxicFrog> | Or 'local function positionUpdate(self)'? |
22:04 | <@ToxicFrog> | Do you really want that in the global namespace? |
22:04 | < Derakon> | No, positionUpdate is a generic "apply velocity to position, etc". |
22:04 | < Derakon> | Possibly ships.positionUpdate. |
22:04 | <@ToxicFrog> | And, ok, what's the contents of objects{}? |
22:05 | < Derakon> | It starts out as empty, then is populated by createShip. |
22:05 | < Derakon> | objects[name] = ship |
22:05 | <@ToxicFrog> | (also, don't you want object:update(), not object.update(object)?) |
22:05 | <@ToxicFrog> | Aah. There's your problem. |
22:05 | < Derakon> | (Yes; fixed, but didn't fix the root problem) |
22:05 | <@ToxicFrog> | Well, part of the problem. |
22:05 | <@ToxicFrog> | for key,object in objects do |
22:06 | < Derakon> | Bahhh. |
22:06 | <@ToxicFrog> | (how does that even work, though? What version of lua are you using, 4.x?) |
22:07 | < Derakon> | You mean the iteration in update()? |
22:07 | < Derakon> | I'm using v5.1. |
22:07 | <@ToxicFrog> | No, 'for foo in sometable' |
22:07 | <@ToxicFrog> | Which isn't part of the formal grammar. |
22:07 | <@ToxicFrog> | Did you modify your terp? |
22:07 | < Derakon> | Oh. ¬.¬ |
22:07 | < Derakon> | No. |
22:08 | <@ToxicFrog> | Because I know it doesn't work in vanilla 5.1 |
22:08 | <@ToxicFrog> | [ben@leela vwt]$ lua |
22:08 | <@ToxicFrog> | Lua 5.1.1 Copyright (C) 1994-2006 Lua.org, PUC-Rio |
22:08 | <@ToxicFrog> | > t = {} |
22:08 | <@ToxicFrog> | > for k,v in t do print(k,v) end |
22:08 | <@ToxicFrog> | stdin:1: attempt to call a table value |
22:08 | <@ToxicFrog> | > for k,v in pairs(t) do print(k,v) end |
22:08 | <@ToxicFrog> | > |
22:09 | <@ToxicFrog> | ... |
22:09 | <@ToxicFrog> | Or is that where the problem is, and not at the call to update()? |
22:09 | < Derakon> | I'll note that the first example isn't what I was doing. |
22:09 | <@ToxicFrog> | Yes it is. |
22:09 | < Derakon> | I was doing "for foo in t do ... end" |
22:09 | <@ToxicFrog> | Yes. |
22:09 | <@ToxicFrog> | Which doesn't work either. |
22:10 | <@ToxicFrog> | The number of elements in the loop variable list is irrelevant to the fact that for expects an iterator. |
22:10 | < Derakon> | Heh. |
22:10 | <@ToxicFrog> | Tables are not iterator functions unless they overload __call or you are using a modified, non-standard terp. |
22:10 | < Derakon> | I just downloaded the source, compiled it, and installed it. *shrug* |
22:11 | < Derakon> | So anyway, I should be able to do "for name, ship in pairs(objects) do ship.update() end", right? |
22:11 | <@ToxicFrog> | Yes. |
22:11 | < Derakon> | data/scripts/ships/ships.lua:31: attempt to index local 'self' (a nil value) |
22:11 | <@ToxicFrog> | Are you /sure/ that the lack of pairs() wasn't the problem generating the 'attempt to call a table value' error? |
22:11 | < Derakon> | That line is the "self.vx = 2" line. |
22:12 | <@ToxicFrog> | ... |
22:12 | <@ToxicFrog> | You have your function declaration messed up. |
22:12 | <@ToxicFrog> | function foo:bar(self) is the same as function foo.bar(self, self) |
22:12 | <@ToxicFrog> | The latter one of those shadows the former. |
22:12 | <@ToxicFrog> | If you declare using : instead of ., the self parameter is implicit, just like this in C++. |
22:13 | < Derakon> | I was copying from my prior project, which included the "self" explicitly... |
22:13 | <@ToxicFrog> | Same for calls; you call as foo:bar(), not foo:bar(foo) |
22:13 | <@ToxicFrog> | If you get /both/ of those wrong, it will in fact work. Mostly. |
22:13 | < Derakon> | foo:bar() = foo.bar(foo)? |
22:13 | <@ToxicFrog> | Yes. |
22:13 | < Derakon> | Okay then. |
22:13 | <@ToxicFrog> | Except, and this is important, that foo is evaluated only once. |
22:13 | <@ToxicFrog> | get_next_thingy():method() is safe. |
22:14 | | * Derakon nods. |
22:14 | <@ToxicFrog> | get_next_thingy().method(get_next_thingy()) is not, if get_next_thingy has side effects (and with a name like that...) |
22:14 | | * Derakon snerks. |
22:14 | < Derakon> | My favorite side-effect is printing 100 lines of Pascal's Triangle. |
22:14 | < Derakon> | I still have the nil self problem, though. :\ |
22:15 | <@ToxicFrog> | This is all covered in great detail in chapters 2.5.8 and 2.5.9, I note. |
22:15 | <@ToxicFrog> | Paste the updated code? |
22:16 | < Derakon> | http://pastie.caboo.se/46089 |
22:18 | <@ToxicFrog> | Looks fine to me...what's the value of ships.korg.update, and what're the values of name, ship, and ship.update just before it calls? |
22:18 | <@ToxicFrog> | Oh, heyt. |
22:19 | <@ToxicFrog> | There's your problem. |
22:19 | <@ToxicFrog> | It's dying two lines later, isn't it? |
22:19 | < Derakon> | It's dying as soon as it tries to work with self. |
22:19 | <@ToxicFrog> | self = positionUpdate(self) <-- why are you assigning to self? |
22:19 | < Derakon> | ...oh. |
22:19 | <@ToxicFrog> | Especially since positionUpdate returns nil. |
22:19 | | * Derakon blushes in embarrassment. |
22:20 | | AnnoDomini [~farkoff@Nightstar-29667.neoplus.adsl.tpnet.pl] has quit [Ping Timeout] |
22:20 | < Derakon> | Okay, it's not dying any more! I haven't tracked down why it's not drawing anything, but it's not dying! |
22:20 | <@ToxicFrog> | So it was dying two lines later. |
22:20 | < Derakon> | Yes, yes it was. |
22:21 | < Derakon> | Thanks again for the help. I really need to get better at debugging my Lua. |
22:22 | <@ToxicFrog> | A lot of this seems to stem from an unclear understanding of how for loops, method declarations, etc work. |
22:22 | <@ToxicFrog> | You have read the manual, I take it? |
22:22 | < Derakon> | In spots, yes. |
22:23 | < Derakon> | I find its insistence on using language definition syntax instead of examples annoying, though. ::= and lots of `;' get irritating. ¬.¬ |
22:23 | <@ToxicFrog> | It uses both. |
22:45 | | AnnoDomini [~farkoff@Nightstar-29080.neoplus.adsl.tpnet.pl] has joined #Code |
22:55 | | timelady [~romana@Nightstar-9473.lns10.adl2.internode.on.net] has quit [Quit: run away! run away!] |
22:57 | | You're now known as TheWatcher[afk] |
23:36 | < Derakon> | Once again, I make sprites not draw by setting their scaling factors to zero. |
23:36 | | * Derakon puts a warning log message in. |
23:40 | | McMartin [~mcmartin@Nightstar-5796.dsl.pltn13.sbcglobal.net] has joined #code |
23:41 | | mode/#code [+o McMartin] by ChanServ |
23:41 | | * McMartin is reminded he's not logged in here |
23:41 | | * McMartin then wanders off. |
--- Log closed Sun Mar 11 00:00:56 2007 |