# Help needed creating simple p5.js library

**URL:** <https://discourse.processing.org/t/help-needed-creating-simple-p5-js-library/34045>\
**Category:** Development\
**Created:** [December 11, 2021, 12:00am UTC](https://discourse.processing.org/t/help-needed-creating-simple-p5-js-library/34045 "2021-12-11T00:00:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![scottc19](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@scottc19](https://discourse.processing.org/u/scottc19)\
**Post date:** [December 11, 2021, 12:00am UTC](https://discourse.processing.org/t/help-needed-creating-simple-p5-js-library/34045/1 "2021-12-11T00:00:45Z")

</div>

Quick background I am using p5.js in instance mode (long story why I have to use instance mode, so just pretend its required) and I want to write a simple library that contains stuff that I do in all my sketches, for example print a title. Can someone help me out with this?

My main sketch is instanced so it looks something like this (but with more stuff…):

```auto
const sketchStuff = (p) => {
p.draw = () => {
      p.background(360, 3);
      p.drawCrap()
    }
}
new p5(sketchStuff );

```

This is more to it, but you get the idea…  
Anyway so I want to define functions in a separate library that I can call. For example in the above code I have a function called drawCrap(). I haven’t been successful so far, but here’s where I started (this would be saved in a .js file and linked in my html file:

```auto
p5.prototype.drawCrap = function() {
  fill(0, 102, 153);
  text("Title", 8, 22);
}

```

My instance sketch stuff works fine, but my library function doesnt work, so what do I need to change in my library file to make it work?  
Thanks and sorry for my crappy example and my poor p5 skills.

Update: the solution was that I was missing “this.” In from of the p5 library calls like fill and text
