chanmanpartyman wrote:
fetchydog567 wrote:
U know what I like about BYOB! Look!
Opps, heres the pic.That won't work if the input is negative. Try 0-x.
just do: step * -1
Last edited by tpaley (2012-06-24 17:07:52)
Offline
tpaley wrote:
Here's a cond block made in BYOB (remember to change the booleans the same amount as the actions!):
Example of usage:
http://i46.tinypic.com/11jtekw.gif
Block code:
http://i47.tinypic.com/2hs87j5.gif
So yeah. Those who do scheme or lisp or stuff like that will know what cond is. Bacically, it's like a whole lot of if/else statements but it's a lot cleaner to look at.
It's like a switch/case block.
Offline
tpaley wrote:
Here's the set draggable block. (Another version)
Example:
http://i48.tinypic.com/2uic6m1.gif
if version:
http://i45.tinypic.com/2u3vdvs.gif
cond version (using the cond block I posted 2 posts ago):
http://i46.tinypic.com/5xpgy1.gif
It would have been much easier if you had done
set (the (attribute of [draggable? v]) block) to <(t/f) = [true]> //hehe scratchblocks made it a variable
Offline
Make the source code for byob blocks and panther blocks so you can put thim in scratch!
block ideas:
render [cube v] at x:[10] y:[10] with size:[20]
Offline
Would it work to use Panther, and mysql to make a user register and login. I want to eventually make a chatbot, that can grow in intelligence. Along with this, I want users to be able to login so the bot will recognize users, and remember things like their name, and other information given by the user. Is there a custom block that would make this possible, and how would it work?
Offline
you don't need any custom blocks, they're already in panther. the (contents of url []) block uses httpGet: in which you could also use to write using php scripts. so you could say (contents of url [http://www.chatbot.com/write_information.php?key=yourKey&value=yourValue]). Then the php script could receive the two arguments, key and value, and write that into the database. Then you could also write an access script in php which would be like (contents of url [http://www.chatbot.com/get_information.php?key=name]). This could return the value of the key if the key exists, or if it doesn't exist some default value.
Do you know what i'm saying?
you could also have (contents of url [http://www.chatbox.com/newUser=userName&password=password]).
of course the strings would be replaced.
Offline
dreamod wrote:
you don't need any custom blocks, they're already in panther. the (contents of url []) block uses httpGet: in which you could also use to write using php scripts. so you could say (contents of url [http://www.chatbot.com/write_information.php?key=yourKey&value=yourValue]). Then the php script could receive the two arguments, key and value, and write that into the database. Then you could also write an access script in php which would be like (contents of url [http://www.chatbot.com/get_information.php?key=name]). This could return the value of the key if the key exists, or if it doesn't exist some default value.
Do you know what i'm saying?
you could also have (contents of url [http://www.chatbox.com/newUser=userName&password=password]).
of course the strings would be replaced.
Huh? Wouldn't it just be easier to make a custom block?
Offline
One block isn't going to do that, you're going to have to do some scripting. Most login forms and post spaces in forums use POST and Panther only natively handles GET. If you want to make a chatbot you'll have to work out how to get Panther to POST data. You'll probably need a good understanding of HTML too.
Just a note, if you make a chatbot that goes round the Scratch forums, its likely to be spotted by myself of one of the Scratch team and marked as a potential spammer, since that's what most chatbots that actually go onto forums do
Offline
sparks wrote:
One block isn't going to do that, you're going to have to do some scripting. Most login forms and post spaces in forums use POST and Panther only natively handles GET. If you want to make a chatbot you'll have to work out how to get Panther to POST data. You'll probably need a good understanding of HTML too.
Just a note, if you make a chatbot that goes round the Scratch forums, its likely to be spotted by myself of one of the Scratch team and marked as a potential spammer, since that's what most chatbots that actually go onto forums do![]()
I think I made some POSTing Squeak code for the Block Library website a while ago. Perhaps I should just rearrange that a bit and post it (no pun intended) as a Panther block?
Last edited by Greenatic (2012-07-03 10:10:38)
Offline
Greenatic wrote:
sparks wrote:
One block isn't going to do that, you're going to have to do some scripting. Most login forms and post spaces in forums use POST and Panther only natively handles GET. If you want to make a chatbot you'll have to work out how to get Panther to POST data. You'll probably need a good understanding of HTML too.
Just a note, if you make a chatbot that goes round the Scratch forums, its likely to be spotted by myself of one of the Scratch team and marked as a potential spammer, since that's what most chatbots that actually go onto forums do![]()
I think I made some POSTing Squeak code for the Block Library website a while ago. Perhaps I should just rearrange that a bit and post it (no pun intended) as a Panther block?
I could give him the code.
Offline
Wait. I'm not making a chat bot for the forums. I want it to link with mysql so that it can learn from other people. Also, then people could login to their account, and the bot will remember things about them.
Offline
elfin8er wrote:
Wait. I'm not making a chat bot for the forums. I want it to link with mysql so that it can learn from other people. Also, then people could login to their account, and the bot will remember things about them.
I'm having a bit of trouble with the code for some reason, I'll keep working on it and try to find the problem.
Offline
hey do you think the code below could be used to POST projects to a mod website (aka mine) I know how to get the website to receive but could this send the contents of the project:
upload: url user: user password: password | t1 t2 t3 t4 t6 args | self stopAll. self world ifNotNil: [self world activeHand newKeyboardFocus: nil]. self canonicalizeSoundsBits: nil saveOriginal: false. self canonicalizeImagesQuality: nil saveOriginal: false. t1 _ scriptsPane target. t2 _ scriptsPane tabPane currentTab. t3 _ viewerPane currentCategory. scriptsPane target: nil. workPane updateSpritesList. t4 _ workPane position. workPane delete; position: 0 @ 0. self updatePenPositions. ScriptableScratchMorph buildBlockSpecDictionary. workPane allMorphsDo: [:t7 | (t7 isKindOf: ScriptableScratchMorph) ifTrue: [t7 blocksBin allMorphsDo: [:t8 | (t8 isKindOf: BlockMorph) ifTrue: [t8 stop]]. t7 convertStacksToTuples]]. t6 _ WriteStream on: (ByteArray new: 100000000). t6 nextPutAll: 'ScratchV02' asByteArray. self storeProjectInfoOn: t6. ObjStream new storeObj: workPane on: t6. workPane allMorphsDo: [:t7 | (t7 isKindOf: ScriptableScratchMorph) ifTrue: [t7 convertTuplesToStacks]]. self addMorph: (workPane position: t4). t1 ifNil: [t1 _ workPane]. t1 viewBlocksAndScripts. scriptsPane tabPane currentTab: t2. viewerPane currentCategory: t3. self updatePenPositions. args _ Dictionary new. args at: 'project' put: {projectName}. args at: 'data' put: (Array with: t6 contents asString). args at: 'user' put: {user}. args at: 'password' put: {password}. HTTPSocket httpPostDocument: url args: args
If so, anyone know how to script the dialog box, if I can't from the scratch one?
Thanks
Last edited by P110 (2012-07-03 15:09:56)
Offline
dreamod wrote:
elfin8er wrote:
Wait. I'm not making a chat bot for the forums. I want it to link with mysql so that it can learn from other people. Also, then people could login to their account, and the bot will remember things about them.
I'm having a bit of trouble with the code for some reason, I'll keep working on it and try to find the problem.
Awesome. Thanks!
Offline
P110 wrote:
hey do you think the code below could be used to POST projects to a mod website (aka mine) I know how to get the website to receive but could this send the contents of the project:
Code:
upload: url user: user password: password | t1 t2 t3 t4 t6 args | self stopAll. self world ifNotNil: [self world activeHand newKeyboardFocus: nil]. self canonicalizeSoundsBits: nil saveOriginal: false. self canonicalizeImagesQuality: nil saveOriginal: false. t1 _ scriptsPane target. t2 _ scriptsPane tabPane currentTab. t3 _ viewerPane currentCategory. scriptsPane target: nil. workPane updateSpritesList. t4 _ workPane position. workPane delete; position: 0 @ 0. self updatePenPositions. ScriptableScratchMorph buildBlockSpecDictionary. workPane allMorphsDo: [:t7 | (t7 isKindOf: ScriptableScratchMorph) ifTrue: [t7 blocksBin allMorphsDo: [:t8 | (t8 isKindOf: BlockMorph) ifTrue: [t8 stop]]. t7 convertStacksToTuples]]. t6 _ WriteStream on: (ByteArray new: 100000000). t6 nextPutAll: 'ScratchV02' asByteArray. self storeProjectInfoOn: t6. ObjStream new storeObj: workPane on: t6. workPane allMorphsDo: [:t7 | (t7 isKindOf: ScriptableScratchMorph) ifTrue: [t7 convertTuplesToStacks]]. self addMorph: (workPane position: t4). t1 ifNil: [t1 _ workPane]. t1 viewBlocksAndScripts. scriptsPane tabPane currentTab: t2. viewerPane currentCategory: t3. self updatePenPositions. args _ Dictionary new. args at: 'project' put: {projectName}. args at: 'data' put: (Array with: t6 contents asString). args at: 'user' put: {user}. args at: 'password' put: {password}. HTTPSocket httpPostDocument: url args: argsIf so, anyone know how to script the dialog box, if I can't from the scratch one?
Thanks![]()
wow, that's nice. The dialog would be a piece of cake. I'll let you use the one for my block importer slightly modified.
'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 4 July 2012 at 9:30:09 am'! DialogBoxMorph subclass: #UploadDialogBoxMorph instanceVariableNames: 'userNameMorph target blockFile commentMorph passwordMorph ' classVariableNames: 'URL ' poolDictionaries: '' category: 'Scratch-UI-Dialogs'! !UploadDialogBoxMorph methodsFor: 'accessing' stamp: 'dreamod 7/4/2012 09:29'! getUserResponse "Wait for the user to type in and accept a string, then report that string. Answer the empty string if the user cancels the operation." "Details: This is invoked synchronously from the caller. In order to keep processing inputs and updating the screen while waiting for the user to respond, this method has its own version of the World's event loop." | w | self openInWorld. self centerOnScreen. w _ self world. w activeHand newKeyboardFocus: userNameMorph. done _ false. [done] whileFalse: [w doOneCycle]. "wait for user to press a button" response = #cancelled ifTrue: [^ self]. target upload: URL user: userNameMorph contents asString password: passwordMorph contents asString. self delete. w doOneCycle. "erase myself from the screen" ! ! !UploadDialogBoxMorph methodsFor: 'accessing' stamp: 'dreamod 7/4/2012 09:29'! target ^ target ! ! !UploadDialogBoxMorph methodsFor: 'accessing' stamp: 'dreamod 7/4/2012 09:29'! target: t1 ^ target! ! !UploadDialogBoxMorph methodsFor: 'initialization' stamp: 'dreamod 7/4/2012 09:25'! initialize super initialize. mainColumn addMorph: (Morph new extent: 5 @ 6; color: Color transparent). mainColumn addMorph: (Morph new extent: 5 @ 6; color: Color transparent); addMorph: (passwordMorph _ StringFieldMorph new client: self; borderWidth: 2; color: (Color r: 211 / 255 g: 214 / 255 b: 216 / 255)); addMorph: (Morph new extent: 5 @ 6; color: Color transparent). passwordMorph font: (ScratchFrameMorph getFont: #StringDialogTypeIn); width: 250. passwordMorph passwordMode: true. mainColumn addMorph: (Morph new extent: 5 @ 6; color: Color transparent); addMorph: (userNameMorph _ StringFieldMorph new client: self; borderWidth: 2; color: (Color r: 211 / 255 g: 214 / 255 b: 216 / 255)); addMorph: (Morph new extent: 5 @ 6; color: Color transparent). userNameMorph font: (ScratchFrameMorph getFont: #StringDialogTypeIn); width: 250. tabFields add: userNameMorph. tabFields add: passwordMorph. self message: 'Enter username and password'. self title: 'Upload Project to: ' , URL asString. self withButtonsForYes: false no: false okay: true cancel: true! ! !UTF8 methodsFor: 'converting'! asString | t2 | t2 _ ''. self do: [:t1 | t2 _ t2 , t1 asString]. ^ t2! !
Call it from ScratchFrameMorph like this:
UploadDialogBoxMorph new target: self; getUserResponse
The dialog will then call the method you made to the instance of ScratchFrameMorph defined once you're done filling in the form.
Offline
elfin8er wrote:
dreamod wrote:
elfin8er wrote:
Wait. I'm not making a chat bot for the forums. I want it to link with mysql so that it can learn from other people. Also, then people could login to their account, and the bot will remember things about them.
I'm having a bit of trouble with the code for some reason, I'll keep working on it and try to find the problem.
Awesome. Thanks!
![]()
Here's the working block.
spec
post data $String$ to url $String$
code
| t3 | t5 _ Compiler evaluate: '^ #(' , t1 , ')' for: self logged: false. t3 _ #() asOrderedCollection. t5 do: [:t4 | t3 add: (WeakKeyAssociation new value: {t4 last}; key: t4 first)]. ^ (HTTPSocket httpPostDocument: t2 args: t3) content
This code is VERY powerful because it uses the Squeak Compiler to evaluate a string as an array. But if you use it properly no damage should come.
This is how to use it:
post data [(key=value) (name='your Name') (password=secret)] to url [http:/www.yourdomain.com(or any other url)
Offline
dreamod wrote:
I made a mistake: add t5 in to the first line before the last |
So now it's this.
| t3 t5 | t5 _ Compiler evaluate: '^ #(' , t1 , ')' for: self logged: false. t3 _ #() asOrderedCollection. t5 do: [:t4 | t3 add: (WeakKeyAssociation new value: {t4 last}; key: t4 first)]. ^ (HTTPSocket httpPostDocument: t2 args: t3) content
It seems like overkill to use the Compiler, but it should work.
Offline
Greenatic wrote:
dreamod wrote:
I made a mistake: add t5 in to the first line before the last |
So now it's this.
![]()
Code:
| t3 t5 | t5 _ Compiler evaluate: '^ #(' , t1 , ')' for: self logged: false. t3 _ #() asOrderedCollection. t5 do: [:t4 | t3 add: (WeakKeyAssociation new value: {t4 last}; key: t4 first)]. ^ (HTTPSocket httpPostDocument: t2 args: t3) contentIt seems like overkill to use the Compiler, but it should work.
![]()
I didn't want to write a completely new array parser.
It's pretty safe though. unless you type a "dangerous" code within in curly brackets {}, because than that's evaluated and the value is put in the array. Then again, that can also be done through a custom block, so there's really no difference.
Offline
Did anybody do my panther block requests? (a while back)
Last edited by LiquidMetal (2012-07-04 12:53:03)
Offline
dreamod wrote:
P110 wrote:
hey do you think the code below could be used to POST projects to a mod website (aka mine) I know how to get the website to receive but could this send the contents of the project:
Code:
upload: url user: user password: password | t1 t2 t3 t4 t6 args | self stopAll. self world ifNotNil: [self world activeHand newKeyboardFocus: nil]. self canonicalizeSoundsBits: nil saveOriginal: false. self canonicalizeImagesQuality: nil saveOriginal: false. t1 _ scriptsPane target. t2 _ scriptsPane tabPane currentTab. t3 _ viewerPane currentCategory. scriptsPane target: nil. workPane updateSpritesList. t4 _ workPane position. workPane delete; position: 0 @ 0. self updatePenPositions. ScriptableScratchMorph buildBlockSpecDictionary. workPane allMorphsDo: [:t7 | (t7 isKindOf: ScriptableScratchMorph) ifTrue: [t7 blocksBin allMorphsDo: [:t8 | (t8 isKindOf: BlockMorph) ifTrue: [t8 stop]]. t7 convertStacksToTuples]]. t6 _ WriteStream on: (ByteArray new: 100000000). t6 nextPutAll: 'ScratchV02' asByteArray. self storeProjectInfoOn: t6. ObjStream new storeObj: workPane on: t6. workPane allMorphsDo: [:t7 | (t7 isKindOf: ScriptableScratchMorph) ifTrue: [t7 convertTuplesToStacks]]. self addMorph: (workPane position: t4). t1 ifNil: [t1 _ workPane]. t1 viewBlocksAndScripts. scriptsPane tabPane currentTab: t2. viewerPane currentCategory: t3. self updatePenPositions. args _ Dictionary new. args at: 'project' put: {projectName}. args at: 'data' put: (Array with: t6 contents asString). args at: 'user' put: {user}. args at: 'password' put: {password}. HTTPSocket httpPostDocument: url args: argsIf so, anyone know how to script the dialog box, if I can't from the scratch one?
Thanks![]()
wow, that's nice. The dialog would be a piece of cake. I'll let you use the one for my block importer slightly modified.
Code:
'From MIT Squeak 0.9.4 (June 1, 2003) [No updates present.] on 4 July 2012 at 9:30:09 am'! DialogBoxMorph subclass: #UploadDialogBoxMorph instanceVariableNames: 'userNameMorph target blockFile commentMorph passwordMorph ' classVariableNames: 'URL ' poolDictionaries: '' category: 'Scratch-UI-Dialogs'! !UploadDialogBoxMorph methodsFor: 'accessing' stamp: 'dreamod 7/4/2012 09:29'! getUserResponse "Wait for the user to type in and accept a string, then report that string. Answer the empty string if the user cancels the operation." "Details: This is invoked synchronously from the caller. In order to keep processing inputs and updating the screen while waiting for the user to respond, this method has its own version of the World's event loop." | w | self openInWorld. self centerOnScreen. w _ self world. w activeHand newKeyboardFocus: userNameMorph. done _ false. [done] whileFalse: [w doOneCycle]. "wait for user to press a button" response = #cancelled ifTrue: [^ self]. target upload: URL user: userNameMorph contents asString password: passwordMorph contents asString. self delete. w doOneCycle. "erase myself from the screen" ! ! !UploadDialogBoxMorph methodsFor: 'accessing' stamp: 'dreamod 7/4/2012 09:29'! target ^ target ! ! !UploadDialogBoxMorph methodsFor: 'accessing' stamp: 'dreamod 7/4/2012 09:29'! target: t1 ^ target! ! !UploadDialogBoxMorph methodsFor: 'initialization' stamp: 'dreamod 7/4/2012 09:25'! initialize super initialize. mainColumn addMorph: (Morph new extent: 5 @ 6; color: Color transparent). mainColumn addMorph: (Morph new extent: 5 @ 6; color: Color transparent); addMorph: (passwordMorph _ StringFieldMorph new client: self; borderWidth: 2; color: (Color r: 211 / 255 g: 214 / 255 b: 216 / 255)); addMorph: (Morph new extent: 5 @ 6; color: Color transparent). passwordMorph font: (ScratchFrameMorph getFont: #StringDialogTypeIn); width: 250. passwordMorph passwordMode: true. mainColumn addMorph: (Morph new extent: 5 @ 6; color: Color transparent); addMorph: (userNameMorph _ StringFieldMorph new client: self; borderWidth: 2; color: (Color r: 211 / 255 g: 214 / 255 b: 216 / 255)); addMorph: (Morph new extent: 5 @ 6; color: Color transparent). userNameMorph font: (ScratchFrameMorph getFont: #StringDialogTypeIn); width: 250. tabFields add: userNameMorph. tabFields add: passwordMorph. self message: 'Enter username and password'. self title: 'Upload Project to: ' , URL asString. self withButtonsForYes: false no: false okay: true cancel: true! ! !UTF8 methodsFor: 'converting'! asString | t2 | t2 _ ''. self do: [:t1 | t2 _ t2 , t1 asString]. ^ t2! !Call it from ScratchFrameMorph like this:
Code:
UploadDialogBoxMorph new target: self; getUserResponseThe dialog will then call the method you made to the instance of ScratchFrameMorph defined once you're done filling in the form.
Wait, is that the actual dialog box code? Thanks!
So, if I add that all to scratchFrameMorph it should all work?
Last edited by P110 (2012-07-05 14:37:22)
Offline
Hi. I'm attempting to make a Panther block named 'number of letter $String$ in the alphabet'. The code is:
t1 = a ifTrue: [^ '1]. t1 = b ifTrue: [^ '2']. t1 = c ifTrue: [^ '3']. t1 = d ifTrue: [^ '4']. t1 = e ifTrue: [^ '5']. t1 = f ifTrue: [^ '6']. t1 = g ifTrue: [^ '7']. t1 = h ifTrue: [^ '8']. t1 = i ifTrue: [^ '9']. t1 = j ifTrue: [^ '10']. t1 = k ifTrue: [^ '11']. t1 = l ifTrue: [^ 12l']. t1 = m ifTrue: [^ '13']. t1 = n ifTrue: [^ '14']. t1 = o ifTrue: [^ '15']. t1 = p ifTrue: [^ '16']. t1 = q ifTrue: [^ '17']. t1 = r ifTrue: [^ '18']. t1 = s ifTrue: [^ '19']. t1 = t ifTrue: [^ '20']. t1 = u ifTrue: [^ '21']. t1 = v ifTrue: [^ '22']. t1 = w ifTrue: [^ '23']. t1 = x ifTrue: [^ '24']. t1 = y ifTrue: [^ '25']. t1 = z ifTrue: [^ '26']. ^ self error
Any idea how to fix it?
UPDATE: Yes, I'm a Scratcher now!
Last edited by Randomno (2012-07-06 03:30:47)
Offline
Randomno wrote:
Hi. I'm attempting to make a Panther block named 'number of letter $String$ in the alphabet'. The code is:
Code:
t1 = a ifTrue: [^ '1]. t1 = b ifTrue: [^ '2']. t1 = c ifTrue: [^ '3']. t1 = d ifTrue: [^ '4']. t1 = e ifTrue: [^ '5']. t1 = f ifTrue: [^ '6']. t1 = g ifTrue: [^ '7']. t1 = h ifTrue: [^ '8']. t1 = i ifTrue: [^ '9']. t1 = j ifTrue: [^ '10']. t1 = k ifTrue: [^ '11']. t1 = l ifTrue: [^ 12l']. t1 = m ifTrue: [^ '13']. t1 = n ifTrue: [^ '14']. t1 = o ifTrue: [^ '15']. t1 = p ifTrue: [^ '16']. t1 = q ifTrue: [^ '17']. t1 = r ifTrue: [^ '18']. t1 = s ifTrue: [^ '19']. t1 = t ifTrue: [^ '20']. t1 = u ifTrue: [^ '21']. t1 = v ifTrue: [^ '22']. t1 = w ifTrue: [^ '23']. t1 = x ifTrue: [^ '24']. t1 = y ifTrue: [^ '25']. t1 = z ifTrue: [^ '26']. ^ self errorAny idea how to fix it?
Try fixing a and l-the quotes are messed up...
Offline