Skip to content

Thoughts On Creating The IRC Client (Day 1)

Chris Double edited this page Oct 23, 2016 · 3 revisions

Downloaded the ircBot.self file. The instructions say "Copy to 'objects/applications' in the self directory", but in the world of Self 4.4 the location of objects/applications isn't clear.

The instructions continued:

and file in with: bootstrap read: 'ircBot' from: 'applications'

I opened the Clean snapshot, and attempted reading in the ircBot file using the full path to the parent directory as the from: argument, but got:

Lookup error, 'from:' not found

After some not-useful poking around for the 'objects/applications' directory, I got smart and pulled up the bootstrap outliner by simply typing 'bootstrap' into the shell and hitting 'Get it' . Looking through the bootstrap slots, I see that the slot name is read:From: (note the capital F). Doing:

bootstrap read: 'ircBot' From: '/Path/to/ircBot/Parent'

now returns no errors. Actually appears to do nothing at all, so I pull up a new shell and do a Get it on 'ircBot'. This gives me the now familiar 'Lookup error':

Lookup error, 'ircBot' not found.

A separate e-mail has come across the mailing list with a user complaining of the exact same issues on the 4.4 Mac VM, so I'm guessing this is related to not having a 'objects/applications' directory.

I pull up the bootstrap object and look at the read:From: slot, which leads me to the read:From:IfFail: slot, which makes it pretty clear what the problem is. bootstrap is consing up the file's path by doing:

selfObjectsDir + / + dir + / + name + .self

Where selfObjectsDir is '.'. I've put the ircBot.self file into the same directory as the snapshot, so will try using '.' as the From: value. Sure enough that works.

So now that I've got an ircBot slot in globals, I pull up the outline. Looks like there's an 'ircBot parent' slot on that, so I pull the outliner for 'ircBot parent' too. The parent has a few obviously useful methods - connect, disconnect, join:, and say:To:. The ircBot itself has: nick, port, and server (among others). I use the evaluator to set nick to 'notbot' (server is already correctly set to irc.freenode.net, and port to 6667 (which I assume is right)) Going to try connecting….

Strangely that seems to have 'just worked'. ircBot has a 'lines' slot, which is suddenly grown to be 77 elements. I pull up an outliner for lines, but it doesn't give me much. A size slot; prototype; rep… nothing of interest here, so I'll checkout the parent.

parent is 'traits list'. I see a group labeled accessing, so going to check it out. It's got the typical first/at:/last. Calling 'lines first' gives me back a string which makes it pretty obvious I'm getting a response from the server, but I don't feel like going through the list one by one. Must be an easy way to print the lines….

OK, I see a 'printing' group on the 'traits list'. Unfortunately it's only got one slot - collectionName. That appears to return the string 'list', which isn't much.

On going back to Self the lines element has grown to 80, and I immediately got an error:

Error: EOF reached before min transfer limit while trying to read file "socket". Receiver is: a unixGlobals os_file.

Going to ignore that until after I figure out how to display the contents of lines.

I don't see anything to easily print a list, but iterating over it is easy. Now I just need to figure out how to display a string somewhere in the UI…. Still find it strange that there is no slot on the 'lines' list itself represents the array of elements. Maybe that's what the rep slot is, though that points to 'a link' who's most interesting slot - value - has 'no value'. There is a 'next' and 'prev' slot though - maybe this is a linked list where - oddly - 'no value' is the first value? I'd be damned if I believed in damnation - that's it!

I can now look at the ircBot's lines via outlines. Not a real user friendly way to follow an irc chat, but it clearly shows that things are working. I'm about 8 links deep and already sick of twisting open outlines, so it's time to find a way to get the lines to display in the UI.

I was about to go Google some docs, but I've got all these outlines sitting in front of me displaying text - wonder if I can just inspect them to see what's going on….

That leads me to think maybe there's some sort of 'display' slot on strings, to I'm going to search for that first.

OK, I don't see anything really useful on strings. There's a 'print' slot, but it doesn't print to anywhere that I can see. Going to see if I can figure out how an outline text field morph works.

Pulled up the command menu on an outliner and selected the 'Submorphs' menu item. That gave me a selection of morphs to look at, the most interesting being named….

Well, it was named something like ui2_test_morph, but I'd already made a duplicate of it, and when I just clicked on it in the self environment I got the following:

[Will insert images once I know how]

Clicking on 'restart world Self 1' pulled up an almost identical window with a 'restart world Self 2' button, which pulled up another similar window, which made me content with force quitting Self and trying to get some sleep.

[Note: Need to fees up to cheating here. I didn't actually go to sleep, but played around with the ircBot for another half an hour, but I'm picking back up where I left off, even though I've peeked ahead. I'll consciously go through a similar thought process.]

Day 2

Clone this wiki locally