This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#201 2012-10-15 05:47:23

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: kurt — Scratch file format Python library

roijac wrote:

why do I get Containers on some vars when opening a project in kurt? I got Container({'length': 4, 'data': [106, 134, 95, 169]}) instead of 2841609834 and Container({'length': 5, 'data': [212, 248, 93, 150, 2]}) instead of 11112675540  hmm
maybe some precision number saving?

Urgh, must be a bug in fixed_objects.py, maybe in LargePositiveInteger. Feel free to take a look for me  smile  Otherwise I'll try and fix it this evening. I think it's supposed to do something like:

number = 0
for x in reversed(data):
    number <<= 8
    number += x


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#202 2012-10-15 06:25:01

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: kurt — Scratch file format Python library

blob8108 wrote:

roijac wrote:

why do I get Containers on some vars when opening a project in kurt? I got Container({'length': 4, 'data': [106, 134, 95, 169]}) instead of 2841609834 and Container({'length': 5, 'data': [212, 248, 93, 150, 2]}) instead of 11112675540  hmm
maybe some precision number saving?

Urgh, must be a bug in fixed_objects.py, maybe in LargePositiveInteger. Feel free to take a look for me  smile  Otherwise I'll try and fix it this evening. I think it's supposed to do something like:

number = 0
for x in reversed(data):
    number <<= 8
    number += x

apparently it is O.O
didn't try it reversed  roll

Offline

 

#203 2012-10-15 11:55:43

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: kurt — Scratch file format Python library

roijac wrote:

blob8108 wrote:

roijac wrote:

why do I get Containers on some vars when opening a project in kurt? I got Container({'length': 4, 'data': [106, 134, 95, 169]}) instead of 2841609834 and Container({'length': 5, 'data': [212, 248, 93, 150, 2]}) instead of 11112675540  hmm
maybe some precision number saving?

Urgh, must be a bug in fixed_objects.py, maybe in LargePositiveInteger. Feel free to take a look for me  smile  Otherwise I'll try and fix it this evening. I think it's supposed to do something like:

number = 0
for x in reversed(data):
    number <<= 8
    number += x

apparently it is O.O
didn't try it reversed  roll

Fixed — I'll push to Github/PyPI once I get internet.  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#204 2012-10-15 13:35:20

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: kurt — Scratch file format Python library

blob8108 wrote:

roijac wrote:

blob8108 wrote:

Urgh, must be a bug in fixed_objects.py, maybe in LargePositiveInteger. Feel free to take a look for me  smile  Otherwise I'll try and fix it this evening. I think it's supposed to do something like:

number = 0
for x in reversed(data):
    number <<= 8
    number += x

apparently it is O.O
didn't try it reversed  roll

Fixed — I'll push to Github/PyPI once I get internet.  smile

Done!  smile  Should all work now.

Use

Code:

sudo pip install --upgrade kurt

to update (assuming you installed from PyPI...)

Last edited by blob8108 (2012-10-15 13:36:12)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#205 2012-10-18 07:57:44

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: kurt — Scratch file format Python library

bug reporting ftw xD
after you saved, you can't save again without load(), you get

Code:

  File "/usr/local/lib/python2.7/dist-packages/kurt/files.py", line 94, in save
    bytes = self._save()
  File "/usr/local/lib/python2.7/dist-packages/kurt/files.py", line 167, in _save
    self.info["thumbnail"] = self.info["thumbnail"].form
AttributeError: 'ColorForm' object has no attribute 'form'

Offline

 

#206 2012-10-18 11:19:37

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: kurt — Scratch file format Python library

roijac wrote:

bug reporting ftw xD

At least it's just you... considering more users find more bugs...  tongue
Thanks, anyway!  smile

after you saved, you can't save again without load(), you get

Code:

  File "/usr/local/lib/python2.7/dist-packages/kurt/files.py", line 94, in save
    bytes = self._save()
  File "/usr/local/lib/python2.7/dist-packages/kurt/files.py", line 167, in _save
    self.info["thumbnail"] = self.info["thumbnail"].form
AttributeError: 'ColorForm' object has no attribute 'form'

Fixed — will upload in a few hours when I get home  smile

I also allowed you to use `file.thumbnail` in addition to `file.info['thumbnail']`, just for fun  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#207 2012-10-19 12:24:47

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: kurt — Scratch file format Python library

Pushed v1.4.4 to GitHub/PyPI:

    Multiple ScratchProjectFile .save()s no longer throw errors
    Can now access project info data using dot notation:
         `file.info['thumbnail']` -> `file.thumbnail`


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#208 2012-10-23 14:42:35

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: kurt — Scratch file format Python library

some questions o.O

how do I set parent morph of a script?
what do I pass to replace_sprite_refs?
what is the use of find_undefined_vars?

I'm getting closer and closer  big_smile

edit: nm, got them xD

Last edited by roijac (2012-10-23 14:54:31)

Offline

 

#209 2012-10-23 15:13:45

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: kurt — Scratch file format Python library

got NotImplementedError: no field type for 171981620135355968629L
i guess a LargePositiveInteger or something?

Offline

 

#210 2012-10-23 16:41:30

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: kurt — Scratch file format Python library

roijac wrote:

how do I set parent morph of a script?

script.morph = ...


what do I pass to replace_sprite_refs?
what is the use of find_undefined_vars?

See my post, if you didn't find it.


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#211 2012-10-23 16:47:48

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: kurt — Scratch file format Python library

roijac wrote:

got NotImplementedError: no field type for 171981620135355968629L
i guess a LargePositiveInteger or something?

Darn, I don't handle Python's `long` number type. Fixed. (Make sure you "sudo pip install --upgrade kurt", blah blah...  smile  )

Btw, in future you can test this with:

>>> from kurt.inline_objects import Field
>>> Field.build(171981620135355968629L)

(You've found bugs in inline_objects twice now...  tongue  And that's supposed to be the simplest module!)

Last edited by blob8108 (2012-10-23 16:48:11)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#212 2012-11-05 19:59:26

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: kurt — Scratch file format Python library

(You've found bugs in inline_objects twice now...    And that's supposed to be the simplest module!)

It amazing what creating a visualizer (as in editor) for the data can uncover.  tongue


http://block.site90.net/scratch.mit/text.php?size=30&amp;text=%20A%20signature!&amp;color=333333

Offline

 

#213 2012-11-06 02:19:36

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: kurt — Scratch file format Python library

MathWizz wrote:

(You've found bugs in inline_objects twice now...    And that's supposed to be the simplest module!)

It amazing what creating a visualizer (as in editor) for the data can uncover.  tongue

Yes! It's also amazing what bugs people using your code can encounter…  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#214 2012-12-10 16:47:00

Lellowsfuzz
Scratcher
Registered: 2009-04-17
Posts: 500+

Re: kurt — Scratch file format Python library

Just a suggestion...
Maybe change the "when green flag clicked" to "when program starts/runs"? Now that you've made Scratch text-based, it would make more sense.

Offline

 

#215 2012-12-10 17:09:03

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: kurt — Scratch file format Python library

Lellowsfuzz wrote:

Just a suggestion...
Maybe change the "when green flag clicked" to "when program starts/runs"? Now that you've made Scratch text-based, it would make more sense.

The program still runs in Scratch, and Kurt converts directly between the text-based representation and a Scratch project, so it makes sense to use the same names for the blocks. Also, the code's syntax is identical to the scratchblocks plugin used on the forums/wiki, so using the same names makes it consistent with that, too.

Thanks for suggesting  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#216 2012-12-10 20:11:05

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: kurt — Scratch file format Python library

Hi blob,

I'm trying to use Enchanting with leJos to run a robot. Since Enchanting is rather buggy when it comes to editing, I thought I might want to edit an Enchanting project in Xcode like you did with Scratch.

Will kurt work for this? Since Enchanting is a mod, it should have basically the same file format.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#217 2012-12-11 02:22:25

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: kurt — Scratch file format Python library

Hardmath123 wrote:

Will kurt work for this? Since Enchanting is a mod, it should have basically the same file format.

Cool idea! It really depends how similar the Enchanting file format is. It shouldn't be too hard to just fork Kurt and tweak/add things until it works -- at some point I'll figure out a way of supporting multiple formats (like .sb2) in Kurt itself.

Things like new blocks are pretty trivial -- I already parse blocks from the Squeak blockspecs (I have a little subset-of-Squeak syntax defined (using the binary parser Construct, of all things)) -- so you should just be able to paste in the new blockspecs straight from Enchanting's source.

Sounds like a fun project -- I'll go and try Enchanting!  smile


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#218 2012-12-11 15:40:24

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: kurt — Scratch file format Python library

...so it turns out Enchanting is based on BYOB, not directly Scratch, so it's a little more complicated  tongue


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#219 2012-12-11 20:14:24

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: kurt — Scratch file format Python library

Yeah, should I have mentioned that?  tongue

Maybe you should first handle BYOB. That'll get Jens and Brian excited, too.  wink

EDIT: Let's try to revive the Hex game at some point. The thing is, I'm totally stuffed with events till March (USAMTS, AMC, a bunch of robotics competitions (hence Enchanting), and school tests).  sad

Last edited by Hardmath123 (2012-12-11 20:15:41)


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#220 2012-12-12 02:32:53

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: kurt — Scratch file format Python library

Hardmath123 wrote:

Yeah, should I have mentioned that?  tongue

Maybe you should first handle BYOB.

EDIT: Let's try to revive the Hex game at some point. The thing is, I'm totally stuffed with events till March (USAMTS, AMC, a bunch of robotics competitions (hence Enchanting), and school tests).  sad

I'm off on a train to another CS interview today, so I could finish the JS then if you want...  wink


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#221 2013-01-26 14:33:27

davidkt
Scratcher
Registered: 2011-11-09
Posts: 100+

Re: kurt — Scratch file format Python library

What version of Python?

Code:

Traceback (most recent call last):
  File "C:\Python27\Lib\site-packages\kurt-master\util\kurtgui.py", line 34, in <module>
    import kurt
  File "C:\Python27\lib\site-packages\kurt\__init__.py", line 43, in <module>
    from kurt.objtable import *
  File "C:\Python27\lib\site-packages\kurt\objtable.py", line 34, in <module>
    from user_objects import *
  File "C:\Python27\lib\site-packages\kurt\user_objects.py", line 373, in <module>
    class Sprite(ScriptableScratchMorph):
  File "C:\Python27\lib\site-packages\kurt\user_objects.py", line 420, in Sprite
    @costumes.fset
TypeError: 'NoneType' object is not callable

Last edited by davidkt (2013-01-27 14:39:02)


I'm Upsilon920 for everything else.
http://www.blocks.scratchr.org/API.php?action=text&amp;string=I_am_currently_&amp;bgr=123&amp;bgg=132http://blocks.scratchr.org/API.php?user=davidkt&amp;action=onlineStatus&amp;type=squarehttp://blocks.scratchr.org/API.php?user=davidkt&amp;action=onlineStatus&amp;type=text

Offline

 

#222 2013-01-27 17:45:48

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: kurt — Scratch file format Python library

davidkt wrote:

What version of Python?

Code:

Traceback (most recent call last):
  File "C:\Python27\Lib\site-packages\kurt-master\util\kurtgui.py", line 34, in <module>
    import kurt
  File "C:\Python27\lib\site-packages\kurt\__init__.py", line 43, in <module>
    from kurt.objtable import *
  File "C:\Python27\lib\site-packages\kurt\objtable.py", line 34, in <module>
    from user_objects import *
  File "C:\Python27\lib\site-packages\kurt\user_objects.py", line 373, in <module>
    class Sprite(ScriptableScratchMorph):
  File "C:\Python27\lib\site-packages\kurt\user_objects.py", line 420, in Sprite
    @costumes.fset
TypeError: 'NoneType' object is not callable

Hmm. 2.7 should work -- but that line should read "@costumes.setter".  hmm

EDIT: Yeah, where have you installed from?

Last edited by blob8108 (2013-01-27 17:51:42)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#223 2013-03-29 09:16:59

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: kurt — Scratch file format Python library

Hey, blob, I can't get the .sprite files quite right - I'm doing it partly right because Scratch could display the right thumbnail in the open dialog, but it couldn't open it  hmm

I'm using this code: (it would be nice to have @sprite.setter, btw  tongue  )

Code:

file = kurt.ScratchSpriteFile(path, load=False)
file.stage = kurt.Stage()
file.stage.submorphs.append(self.to_kurt())
file.save()

And I have here the .sprite file I got. Help?

Offline

 

#224 2013-03-29 09:29:05

blob8108
Scratcher
Registered: 2007-06-25
Posts: 1000+

Re: kurt — Scratch file format Python library

roijac wrote:

(it would be nice to have @sprite.setter, btw  tongue  )

Yeah, sprite file support is slim  tongue

The file you gave me opens fine in BYOB, but not Scratch. Weird. I can't really help anymore without seeing your code...

EDIT: random guess here, but based on the Squeak traceback I'd say your Sprite (or maybe the costume?) doesn't have a valid "position" property.

Last edited by blob8108 (2013-03-29 09:31:36)


Things I've made: kurt | scratchblocks2 | this cake

Offline

 

#225 2013-03-29 09:38:07

roijac
Scratcher
Registered: 2010-01-19
Posts: 1000+

Re: kurt — Scratch file format Python library

blob8108 wrote:

roijac wrote:

(it would be nice to have @sprite.setter, btw  tongue  )

Yeah, sprite file support is slim  tongue

The file you gave me opens fine in BYOB, but not Scratch. Weird. I can't really help anymore without seeing your code...

EDIT: random guess here, but based on the Squeak traceback I'd say your Sprite (or maybe the costume?) doesn't have a valid "position" property.

Sprites don't have positions, they have only bounds  tongue

Last edited by roijac (2013-03-29 10:02:25)

Offline

 

Board footer