naace in second life

Second Life for teachers

Leon Cych

Writing simple code for objects

Information

Writing simple code for objects

Want to make something change colour or talk to you when you touch it? Learn how here in very small stages...

Members: 7
Latest Activity: Jul. 11, 2007

Writing Simple Code for Objects - don't panic it's Code!!!!

So you want to Write Code - are you mad!!!

Making things do stuff

Want to make things do stuff in Second Life? Well you have come to the right place.

But you will have to learn or have someone give you (or steal), some code.

How hard is it?

Don't worry this will be painless and veeeeerrrrryyyyy slow. Click on the Flickr link below and you will be taken to a new resource on a Flickr page.

Don't worry if you don't understand it - just have a browse and then come back here - it'll make sense later.

I'll be adding three or four ways of doing this using different resources for different types of learner - in my experience people are put off using coding because it is so badly explained and with not enough imagination or attention to detail. People tend to fall at the first hurdle unless they are that way inclined.

Flickr Resource for Coding

When you get to Flickr, roll your mouse over the code box and you'll see a little explanation of each code term. I'm working on it over the next few days.

Do you need to be Geeky?

No! - You don't need to be Geeky really, just a little persistent!

The basics

I will explain basic terms first and later we'll show you how to attach this to an object in SL and make it interact with you or anyone else. If that's not your thing just give it a cursory browse and pass on.







One way of explaining it

OK How do you get across the basic ideas of coding in SL?

One way is to do it through visual metaphors - here's a first attempt at explaining States and Events using pictures to get across the ideas in a slideshare presentation. The commentry to go with each slide is below. 7 slides so far.

Scripts and Script Box

To write code in SL you need to place it in a script:

A script in Second Life is a set of instructions that can be placed inside any primitive object in the world, a "prim", but you can't place it inside an avatar. However you can cheat and place a script on a thing ON an avatar.

Editing and Compiling

Scripts are written with a built-in editor/compiler in second life a bit like the enigma machine up there. The editor allows you to put in the code and the compiler dandies it up into a form the computer can read and execute. So the little code box you see up there is what that is and it is linked to the prim cuboid you can see in the pic. The script editor comes with every object or prim.


2 Main Ideas - States and Events




"States" and "Events" are the 2 main concepts you need to understand when writing a very basic script in SL.

States



The door there in slide 3 can be "open" or "closed" and a light can be "on"



or "off".



People can also have states can't they? They can be happy or sad etc. In the real world behaviors can be modelled with "states". Well the same is true of scripts.

Default State

The most basic script will have one state, the default state.



Basically this means it sits there and is ready to spring into action when something happens to it.

Events



Events are a little trickier to understand.



Events are code language in SL that makes something happen. They are like triggers.

You cannot define or make an event in SL- they are already made for you - they are prepackaged and shrink wrapped without you having to write them.

Events happen by objects (Prims) and avatars interacting with each other in SL. One of the easiest examples of these is when you touch an object in SL.

Event Handlers

When you touch something it triggers what is called an
event handler.

To be continued....

I am not saying these are great resources - there is already some debate about the content and the tone of them but the web 2.0 functionality might be of use. Please add to them if you like or be critical - it's important and thanks for everyone who has engaged so far.

I also came across this page of videos and resources to embed code in objects from CTER. They seem very clear.

Discussion Forum

Gill Coker

Free scripts 1 Reply

Started by Gill Coker. Last reply by Gill Coker Jul. 11, 2007.

Leon Cych

Where to find the scripting box

Started by Leon Cych May. 26, 2007.

Comment Wall

Add a Comment

You need to be a member of Writing simple code for objects to add comments!

 

Members (7)

Gill Coker Leon Cych J Pearce Paul Harrington Mgt Dee Philip Rees David Wall-Jones
 
 

About

Leon Cych Leon Cych created this social network on Ning.

Create your own social network!

Badge

Loading…
 

© 2009   Created by Leon Cych on Ning.   Create Your Own Social Network

Badges  |  Report an Issue  |  Privacy  |  Terms of Service