Fun and useful JS scripts


#21

@judas sandbox.highfidelity.io is there for you to destroy/break/test whatever you want. If anything bad happened on our side that would actually be a good thing as it would give us a data point with how to deal with script issues.

Go forth and go crazy!


#22

greenGables.js
I have been developing a script to build a simple 2 level 60 x 60 house with a gable roof and some window and door openings. To help the beginners. Thanks to KevinMThomas for getting me started.
The walls are all different colours to help define things in the script, I have commented almost every different line with basic help.

The house can be placed anywhere by changing the first 3 values (constants) in the script to your location, these values are then used as constants throughout the script. (details in the script)

With a little experimenting you can change the colours to suit yourself by changing the last 3 numbers in the Voxels.setVoxel(x, y, z, 1, 100, 100, 255) in this case 100, 100, 255 which is lightblue.

It can be scaled with a little tweaking.

Make sure you also get the removal script eraseGreenGables.js

Modify this all you want, Hopefully more to come.
Download scripts here
Build script https://gist.github.com/Adrianl3d/cd61f1f4697a81f202c8
Removal script https://gist.github.com/Adrianl3d/b8ddcdcb78c24c101ddd

Adrian


#23

I am currently seeing an issue where it doesnt finish cutting the doors and windows right, I think this is due to the server because it works well on localhost or an empty sandbox.
I ran the script a second time after commenting the first 4 build functions from line 238 and just let it run the cutDoors() and cutWindows() functions, then it was ok.
I didnt want to have a separate script for windows and doors for portability reasons.


#24

Great job @Adrian. Looking great. This is a great example!


#25

Hi @Adrian keep in mind when you re-run the entire script is has to recreate every voxel. You can include the cutWindows and cutDoors functionality in one script simply / / comment out the areas you don’t want to do at the time you want to run the script and you should be good to go.


#26

Set Grass

Here is a simple script to map out grass on the street level of your plot. Simply fill in the details of your plot dimensions as everything is specified in the code comments.

DOWNLOAD


#27

Great script to show who owns plots on “The Strip”

Just add this script https://gist.githubusercontent.com/cozza13/fe74658deca5b7fe339c/raw/plotOwnerDisplay.js

and when you are over a plot it will show you who owns.


#28

@chris this is a cool script but I must point out that you have duplicated a location,
the location set for Eve and Aaron are exactly the same, according to Eve this location is hers, directly across the road from me. I am unsure where Aaron’s plot is.


#29

Hi @Adrian I have moved Aaron. If you reload that script it should show up correctly


#30

Simple Teleporter Script
by Konstantin@HighFidelity

Link: https://gist.githubusercontent.com/SydoxX/3bfdc51119ae9833a193/raw/5dd22c6a0e19b4d1330d9e69706259ff187a5931/simpleteleporter.js
How to use: When you run the script by url, an extra menu with the name “Teleporter” will appear. With this menu, you can create your own teleporter or ignore teleporters (still work in progress).
In the background, the script scans for teleporters. When it finds an teleportervoxel under you, it will teleport you to the given coordinates.

Have fun!
Cheers, Konstantin


#31

The Genesis Builder - Residential Building Model 6/6/14 WINDOWS BUILD REVISION (Menu remove function now works on Windows OS)

Here is a script to create a basic residential building at a specific location based on your position. Menu driven.

DOWNLOAD


#32

Some of Douglas Crockford’s remedial JavaScript functions can be rather helpful.

For example, supplant() performs primitive string formatting:

function supplant(string, obj) {
	return string.replace(/\{([^{}]*)\}/g, function(a, b) {
		var r = obj[b];
		return typeof r === 'string' || typeof r === 'number' ? r : a;
	});	
}

…turning print("Voxel at" + voxel.x + "," + voxel.y + "," + voxel.z + ">") into print(supplant("Voxel at <{x}, {y}, {z}>", voxel))


#33

Just updated the Genesis Model to work on the Windows OS. Thread above.


#34

Playing with Color!

Here is a script to give you more colors to play with,

Small tweak to put more colours into the voxel palette. I used a basic 16 colour palette here including black, white, red, blue, green etc. Please try it out to add som more colour to our world :slight_smile:

16 colours in sample, including (almost) black. Run the script from the URL below:

https://gist.githubusercontent.com/anonymous/0359b4d81f58090d5288/raw/7ddbf53b29e7757420683493e28ecb56aabf96af/editvoxelcolour


#35

Yesssssssss <3 I love you Debs.


#36

Yes Debs more colour, I was frustrated with how hard it was to dial up a particular colour when working with voxels, have to find the colour I want with Rainbow, punch the RGB params into a script and rez a coloured voxel, too slow.

So I created a palette of sorts, utilizing KevinMThomas menu script and some gradient formulas I have come up with.

Running the script produces 2 new menus, a Create, and a Remove .
Under the create there is a selection of colour gradients each will produce a bar of about 20 grades of that colour (see pic)
The pic is all 7 gradient bars,
reds, greens, blues, greys, red to green, green to blue, and blue to red.

Simply dial up a colour ramp and preselect your choice to your UI palette, then remove the palette afterwards.
Use in conjunction with editVoxels.js as posted by @DebsRegent for the extended UI palette of 16 slots.

Get the script from here
https://gist.github.com/Adrianl3d/0bf07c446d9415dcc466


#38

Hmm couldn’t post the link, try again.

Here is the link for the Colour Palette Menu in the pic above.

(I hope)
link (maybe)


#39

@debs you rock I love this!


#40

Thanks @KevinMThomas but the credit goes to @Adrian. I was doing this using the HUD initially but Adrian picked up the ball and ran with it. I believe that Arian’s colour selector rezzes inworld in HF? However I think between us we have a winner here. His picker in a HUD.

Colour picker in HUD

After looking at Adrian’s work at the Friday meeting, we discussed how to put a colour selector (like a colour wheel) into a HUD. I think we both believe this is the way to go. (Adrian?)

By the way, the HUD still needs doing - there are plenty of free Javascript colour picker scripts out there, so it’s a matter of who does it first.

We love colour!

I guess I got the stick and poked at it and Adrian ran with it … I had a bit of encouragement from @Judas (I think he just wanted to know if I really ‘could’ script :P)


#41

Yes you guys are awesome this is very useful thank you @adrian for this as well. It is great to see the new color palettes come alive.