Wick code html file

I have created a project where you plug in javascript code (or wick built-in code) in reference to 2 pixels, and 2 text objects to create a program. You can create new objects through cloning, and all this project really does is allow you to run code on these objects.

My Project1-17-2021_18-33-54.html (2.1 MB)

Before I share the wick file, I would like to see if anyone can guess how this project was made
(can you guess how this project works, what types of code I used, assets I uploaded, etc.?)

2 Likes

mmm… it could be achieve in more than one way… you could be using some kind of eval() function in the editor tabs for pixel 1 and for pixel 2, then when you hit play, it would eval the textboxes at run time…

Am I cold? or hot? a little?

1 Like

You’re very close

I did use a function that is like eval, but one that works with wick objects

Ever wondered how they would be “un-evaled” when the project pauses?


I also forgot to add an error reporter, luckily you can try to alert project.error to find error after running the project (the project.error resets to “” after the project pauses).

Also, you can refer to pixel 1 as pixel1 and pixel 2 as pixel2

Just put logic for that… create a variable which would be your higher if condition…

Good guess Yes, that’s a good method

I actually used a function that removes a specific script from the program

Here’s how it works:

Clip.removeScript('update'); // remove update script

I thought that you were trying to do it… (I was not guessing…). I was about to tell you: “I could help you with that”… ok… now I understand.

Nice work!

1 Like

it’s very interesting. :) can you tell me how you changed the text box stuff? (font, text/background color, size)

For the text box, I added this code to change the color and disable resizing it in load script:

// Black and white colors
this.inputElem.style="background-color: black;color:white;"; 

// Disable resizing
this.inputElem.style.resize="none";

Thank you @pumpkinhead for showing me how I can turn the text box to textarea type of text box.
Here’s the code in an image:
Screenshot 2021-01-17 at 7.51.56 PM

I didn’t change the size, the text size is just smaller in html version
(idk how to change size yet, but might look it up rn)

Edit

I just looked it up. In html, you use something like

textarea { font-size: 18px; }

but in javascript wick, you can probably write:

this.inputElem.style="font-size: 5px;" // Set size to 5px

Edit #2:

this.inputElem.style="background-color: black;color:white; font-size: 5px;"; 

works better than

this.inputElem.style="background-color: black;color:white;"; 
this.inputElem.style="font-size: 5px;"
2 Likes

How did you change the font of the text thats typed into the text input?

You can add this code into the textbox and play around with it to change the font

You can also set the font family using this:

font-family: monospace; // I'm using monospace as an example

Here’s an example file:
My Project3-7-2021_15-52-16.wick (4.6 KB)
(see text box, load script, line 21)