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

#201 2013-04-13 15:58:23

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

Re: M30W New Official Topic

Do you have python knowledge and time for coding?

Offline

 

#202 2013-04-13 16:44:04

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

Re: M30W New Official Topic

Yes!  big_smile  python is my favourite language actually.


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

Offline

 

#203 2013-04-14 15:17:29

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

Re: M30W New Official Topic

Do you have a sourceforge account?

Offline

 

#204 2013-04-16 18:00:33

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

Re: M30W New Official Topic

do I need one?

Last edited by davidkt (2013-04-19 17:08:42)


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

Offline

 

#205 2013-04-21 04:34:29

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

Re: M30W New Official Topic

I added you to the sourceforge project, now you can post code with svn. (there are some instructions in the old m30w topic on how to do that). I don't really know though what you can do at this stage. Try to get yourself familiar with the code, you can try to stop the stage from redrawing itself when the frame is resided.

Offline

 

#206 2013-04-22 13:23:41

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: M30W New Official Topic

Nice work so far! Could you implement the design of executing the scripts? That way I can work on adding the "blocks" and making myself useful.  tongue

Offline

 

#207 2013-04-22 16:28:12

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

Re: M30W New Official Topic

That's exactly what I'm working on right now  smile

I still haven't figured out how I want to add the methods - unlike squeak you can't have neither ':' in a method name, nor method names like '&' or '+'.  hmm

Offline

 

#208 2013-04-23 09:45:42

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: M30W New Official Topic

You could name the methods like this:

Code:

i_add_i(a, b): # Adds two numbers together
i_sub_i(a, b): # Subtracts b from a
join_s_s(a, b): # Joins two strings together

i = integer (at least, that's what it represents)
s = string
b = boolean

Offline

 

#209 2013-04-23 11:07:54

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

Re: M30W New Official Topic

Magnie wrote:

You could name the methods like this:

Code:

i_add_i(a, b): # Adds two numbers together
i_sub_i(a, b): # Subtracts b from a
join_s_s(a, b): # Joins two strings together

i = integer (at least, that's what it represents)
s = string
b = boolean

Yes, but I still get ugly exceptions list when converting from/to kurt.

Offline

 

#210 2013-04-23 14:18:17

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

Re: M30W New Official Topic

roijac wrote:

I still haven't figured out how I want to add the methods - unlike squeak you can't have neither ':' in a method name, nor method names like '&' or '+'.  hmm

Try using a dictionary to convert command names to method names, and then the methods can be Python methods. And strip the colons (or maybe replace 'em with underscores?). Something like this:

command = 'wait:elapsed:from:' # parameter

SPECIAL_NAMES = {
    '+': 'add',
    '&': 'and',
    # ... etc
}

method_name = SPECIAL_NAMES.get(command, command) # use command as default
method_name = method_name.replace(":", "_").rstrip("_")
method = getattr(sprite, method_name) # Note this throws AttributeError if the method doesn't exist
method(*args) # ...


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

Offline

 

#211 2013-04-23 15:06:09

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

Re: M30W New Official Topic

That, or I use decos  hmm

I slightly like decos better; What do you think?

Offline

 

#212 2013-04-23 15:19:53

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

Re: M30W New Official Topic

roijac wrote:

That, or I use decos

How would you use decorators? I don't think they would be better.


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

Offline

 

#213 2013-04-23 16:21:07

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

Re: M30W New Official Topic

roijac wrote:

I added you to the sourceforge project, now you can post code with svn. (there are some instructions in the old m30w topic on how to do that). I don't really know though what you can do at this stage. Try to get yourself familiar with the code, you can try to stop the stage from redrawing itself when the frame is resided.

Thanks!  big_smile  Can you post a link to the old M3OW topic?


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

Offline

 

#214 2013-04-23 18:51:58

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

Re: M30W New Official Topic

I'm writing this on mobile, but anyway...

Code:

class Sprite:
    blocks = {}
    def block(name):
        def func(method): blocks[name] = method
        return func

    def __getattr__(self, key):
        try to return from self.blocks

    @block('+')
    def _ (a, b):
        return float(a) + float(b)

It'll work because getattr accepts any strings (even empty ones). Anyway a decorate on all blocks is extremely useful for debugging.

@davidkt, try searching  wink

Edit: bbcode is case eensitive?!

In fact, I really like this approach  smile

Last edited by roijac (2013-04-23 18:57:09)

Offline

 

#215 2013-04-24 11:58:42

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: M30W New Official Topic

roijac wrote:

I'm writing this on mobile, but anyway...

Code:

class Sprite:
    blocks = {}
    def block(name):
        def func(method): blocks[name] = method
        return func

    def __getattr__(self, key):
        try to return from self.blocks

    @block('+')
    def _ (a, b):
        return float(a) + float(b)

It'll work because getattr accepts any strings (even empty ones). Anyway a decorate on all blocks is extremely useful for debugging.

@davidkt, try searching  wink

Edit: bbcode is case eensitive?!

In fact, I really like this approach  smile

I agree, decorations is probably best and probably easiest in the long run. I was thinking you could use a dictionary {'+':i_add_i} (i_add_i being the function, since you can "move it around" if you drop the parentheses), but decorators would make it easier to add new blocks in the future.

Offline

 

#216 2013-04-26 16:24:05

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

Re: M30W New Official Topic

roijac wrote:

@davidkt, try searching  wink

You never said M30W used to be called Emerald!  mad  Now; scrolling through a bunch of chatting between Magnie, markyparky56 and coolstuff; I still can't find the post. What's the post number?

Also, should I start implementing the green flag?


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

Offline

 

#217 2013-04-26 22:00:50

darkness3560
Scratcher
Registered: 2010-07-28
Posts: 30

Re: M30W New Official Topic

I can't install on Ubuntu 12.10 64-bit.  It downloads the M30W files fine, but cannot install them.  Here is the error message:

Installing collected packages: M30W, kurt, construct, PLY
  Running setup.py install for M30W
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help
   
    error: option --single-version-externally-managed not recognized
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/darkness3560/build/M30W/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-2GCZM5-record/install-record.txt:
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

   or: -c --help [cmd1 cmd2 ...]

   or: -c --help-commands

   or: -c cmd --help



error: option --single-version-externally-managed not recognized


http://1024128.webs.com/1.pnghttp://1024128.webs.com/2.pnghttp://1024128.webs.com/3.pnghttp://1024128.webs.com/4.png
Pi is Pi, and Pi is 3.1415926535897932384626433832795028841971693993751058209749.

Offline

 

#218 2013-04-27 15:04:18

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: M30W New Official Topic

Do you have subversion?

Code:

sudo apt-get install subversion

Did you get the latest version from the Repository?

Code:

cd ~/Documents
svn checkout svn://svn.code.sf.net/p/m30w/svn/trunk m30w-svn

OR if you already have it:

Code:

cd ~/Documents/m30w-svn
svn update

And did you put in the right arguments for the file?

Code:

cd ~/Documents/m30w-svn
sudo python setup.py install

Btw roijac: Comments and maybe a little txt guide on what goes on where.

Last edited by Magnie (2013-04-27 15:14:49)

Offline

 

#219 2013-04-27 22:04:46

darkness3560
Scratcher
Registered: 2010-07-28
Posts: 30

Re: M30W New Official Topic

Weird... It gives me this message when I run svn...

darkness3560@PenguinsFromMars:~/Documents$ svn checkout svn://svn.code.sf.net/p/m30w/svn/trunk m30w-svn
svn: E000111: Unable to connect to a repository at URL 'svn://svn.code.sf.net/p/m30w/svn/trunk'
svn: E000111: Can't connect to host 'svn.code.sf.net': Connection refused


http://1024128.webs.com/1.pnghttp://1024128.webs.com/2.pnghttp://1024128.webs.com/3.pnghttp://1024128.webs.com/4.png
Pi is Pi, and Pi is 3.1415926535897932384626433832795028841971693993751058209749.

Offline

 

#220 2013-04-29 10:07:43

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: M30W New Official Topic

darkness3560 wrote:

Weird... It gives me this message when I run svn...

darkness3560@PenguinsFromMars:~/Documents$ svn checkout svn://svn.code.sf.net/p/m30w/svn/trunk m30w-svn
svn: E000111: Unable to connect to a repository at URL 'svn://svn.code.sf.net/p/m30w/svn/trunk'
svn: E000111: Can't connect to host 'svn.code.sf.net': Connection refused

Hmm, try this instead:

Code:

svn checkout http://svn.code.sf.net/p/m30w/svn/trunk m30w-svn

Offline

 

#221 2013-04-29 11:42:55

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

Re: M30W New Official Topic

@darkness3560, what command did you exactly use in the first try?

@daviddkt, configure whatever you use for svn with this address:
svn+ssh://YOURSOURCEFORGENAME@svn.code.sf.net/p/m30w/svn/

Offline

 

#222 2013-04-30 13:55:39

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: M30W New Official Topic

Hey roijac, (here) is it possible to decrease the amount of code in Client.new_message by using decorators for the functions? If so, how would I do it, as I'm completely lost on how to use decorators and how they work. I want to do something similar as to what you are doing with the blocks (assign the method to a string in a dictionary so I can call it with a different name without needing the user to send a message like '/cmd_pm username message here').

Offline

 

#223 2013-04-30 15:18:02

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

Re: M30W New Official Topic

Magnie wrote:

how to use decorators and how they work

A decorator is just a convenient way of applying a "decorator" function to the function you're defining.
   
    @decorator
    def some_function(x):
        return x + 1

Is equivalent to

    def some_function(x):
        return x + 1

    some_function = decorator(some_function)

Search Google for better explanation.  tongue


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

Offline

 

#224 2013-04-30 16:53:49

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: M30W New Official Topic

blob8108 wrote:

Search Google for better explanation.  tongue

Already, did, still confused.  tongue

Offline

 

#225 2013-04-30 17:56:34

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

Re: M30W New Official Topic

@roijac: WHAT IS SVN??!?!
@Magnie: A decorator is just kind of a way to reduce code in functions. So if you need to call a function (func1) with another function (func2) as its only parameter, like

Code:

def func2():
    #Define func2 here

func1(func2)

you could just use a decorator, like

Code:

@func1
def func2():
    #Define func2 here

This is commonly used with property() (tell me if you don't know what that is) so it's like

Code:

class Example:
    @property
    def class_property():
        #define class_property here

Hope this helps!  big_smile

Last edited by davidkt (2013-04-30 17:57:58)


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

Offline

 

Board footer