Defold Codepad

How many of you know about https://godbolt.org/ ?
It’s a great site I use a lot to see what different compilers do to the code I write. It’s quite informative.

And, perhaps you didn’t know we have a similar tool, for Defold, called codepad: https://defold.com/codepad/

With it, you can choose a collection, write some test code, and then see the result.

The source is available on github, and we’d very much like to see this way of writing quick examples grow even further:
https://github.com/defold/codepad

To post an example, you put it in an iframe:

<iframe width="100%" height="800" frameborder="0" scrolling="no" marginheight="0"
 marginwidth="0" src="CODEPAD_URL"></iframe>

And the CODEPAD_URL is the one you get from pressing “Share” in the code pad.

And here’s what it looks like.

24 Likes

One good way to use this would be to infuse our documentation with small codepad links that explain the behavior of a function or a concept, interactively.

6 Likes

I use the codepad all the time when I need to find out how exactly something embarassingly simple works and don’t want to test it in the project I have open at the moment.

5 Likes

This will come in handy, for sure.

I think your links have issues, though. They all appear to be Slack redirects, which don’t work for me.

Fixed!

:open_mouth::heart_eyes_cat: wow this is great!

I’m in <3, this is like https://codepen.io/ but with Defold!

“Try it here or host your own custom version.”

Where to start if I wanted to host my custom version? With the possibility also of sharing code URLs?
I don’t know nothing about web servers programming. I only know about getting shared hosting plans and installing Wordpress :stuck_out_tongue: !

A good solution is to use GitHub Pages: https://pages.github.com/

That is how we host the website and codepad.

1 Like

Do I need to do something special to make the “share” button work?
When people click share, the code need to be saved somewhere and a new URL is created. Is all this handled by the codepad app?

The url contains the settings + code as base 64 encoded info (iirc)

1 Like

:heart_eyes_cat::open_mouth::heart_eyes_cat::open_mouth: oh! great!

How could we get input to work in Codepad?

https://defold.com/codepad/#?c=#cp_gui_nodes&s1=GYVwdgxgLglg9mABDMMoAoDOBTANsASgCgBIAcxBgDoBDVAWxqm3QurOygH0w4ATFgCIARnAAegggBpEbKgAUASgHl5XecoDKASQAq25QDkZAN0ZQAFlRPZocAE4BmdAAZpsylQCiAQR2GAcS5tQ2UAVV0ARTCfABEZACYZFxlUXBk5eQAZHwBNACEfAGEAaS4s5VV1EICNQOISekwyKgAHOEwMQSpBGUEaCABHSntsLhRWkG5gOAgQTEkibDA+IiJQSFgERGAUGlwsPEJSJpb2zvRu3sRBUdxsGhxxsEnp2fnF5dX18Gh4JBArT4TBYOHwMj4UGISxWaw2f22CC49GwmEwNA4h3BiBRaIxYxgfBkuPRHBkOBW2Hs0K+cN+WyQSImUyxwBkAwZ4yJiA5/2IiAFiFarXsKAwvKZ3IlYGItJ+m3+iCRdzgND4rJpsKAA==&s2=GYVwdgxgLglg9mABDMMoAoDOBTANsASgCgBIAczgDoBDVAW2qm3QCJKWAaRF7EXbAE6UAXp0QVKABQAyAQQCaAIVkBhANIB9aQHltkjQDFtAJQDqs4wBEuAZgCsATi4SAorIDKASQByAcS0+bsZcAEzE2GAAJkREoJCwCIjAKNS4WHiEMRHRseDQ8EggAA6RjMw4+FyRUMRE2TFx+YkIGnTYmJjUZOUZXG0dXdgaMJF97Z3dXDhRgrX1ufEFiC0oRSAYFcBc1E1gw6OIOwlgc1ENecfLewJ4cNSR6fin0UA=

Just use print,
pprint doesn’t work in codepad.

1 Like

Indeed, the input is working, the pprint not :smiley: Thank you!

Hmm, why is that?

I didn’t check it myself, I just know it doesn’t work

Probably because only print was monkey patched but not pprint?

1 Like

It would be nice to have a iFrame button on Forum for codepad. Is it possible?

I believe we looked into a tighter forum integration with the codepad a few years ago. I can’t recall what came out of it…