Tuesday, 13 December 2011

Mini-game update!

I have decided to change the mini-game slightly:

Firstly it will now be a timed game, the player has 30 seconds to shoot as many targets as they can. This proved a more viable game to make using everything we have covered in the weeks tasks and not trying to over complicate the first real game I have programmed.

Week 7 - Chat and e-mail!

This weeks tasks were all about chat and email. Its quite strange to have objects that can email other objects or avatars and then even RL email accounts. But it does seem like a smart feature to LSL.


First task was to create an object so that when touched would run a sensor for avatars in a 96m range(being max). Then another script that would send an email to an address with the information we had asked for.


I got the script to scan the area for avatars working just fine, but for the rest I really had no Idea how to do it. After spending a while researching why my code wouldnt work I gave up. I will come back to this at a later day. Here is what I have for now:




But it doesnt seem to do what I want it to.



Week 6 - HUDs (Head up displays)

I have really been looking forward to this part of the module, as I have quite a passion for game development and this is one of the focus points in which I want to excel. I found the scripting on this part relatively easy for once clicked will shout a word over a obscure channel and be listened by another script on another prim and then depending on the word shouted, changed the position of the prim.


Once I got that working, my next task was to once clicked to attach to avatar, then to be able to use it as a very basic UI. The llAttachToAvatar function is quite annoying to use but is needed for this bit of my mini-game so here it is:


The scripting was actually less of a challenge than getting the textures to display properly, but there you go. Two working buttons that control the height of that ball you see floating. I am proud and quite enjoy working with llShout and llListen to cross-communicate objects. Nice system they have.

Monday, 12 December 2011

Week 5 - Datalists and notecards

For this weeks tasks, we looked at lists and notecards. In LSL there is no arrays, so list takes over... But not all the functions are the same.


The first task was to create a script that once a collision was detected, to store the avatar name, avatar KEY and speed at which the avatar/object collided with the prim containing the script. 


The second task was to display this data to the owner of the script on touch of the object. So I thought I would save some time and just put them together. When I tried this task, it wasnt that difficult at first but then I couldnt get the list organised well using the code I had got. Here it is and the output:



Output


I then researched some stuff about list organisation and ease of reading in second life. And re-coded the list and here is the final out: 




From this exercise so far, it has shown me some of the magical powers of loops and lists. These are a powerful tool when used together. 


I had a good bash at the third task but couldnt get it all working. I did manage to get the script to read from the notecard but then not really do much else after that. 





Wednesday, 7 December 2011

My mini-game idea so far!

Right, the concept of my game is:

There are 2 cannons, that 1 player will control each cannon. Once clicked on the cannon, both players will have to select start game, then the HUD will show up.

On the HUD there will be 5 buttons, rotate the cannon left or right, raise it up or down and fire.

The players will have to aim the cannons at a target and fire. If the player hits the target, their score will raise by 1. Once a player destroys the target, they will move to a different location to be aimed at once more and shot at. Rinse and repeat until game is done. At this point, I'm not too sure on what the points should go up to.

Once the game has ended, a scoreboard will appear with both players names, score, hit%(maybe) and whether they want to rematch or leave the game.

Monday, 5 December 2011

Week 4 - Moving and Rotating objects.

This weeks tasks were to move an object around using scripting. The first thing I did was make a prim and make it move along up the Z-Axis 2 meters. This was for a non-physical object.


After I got the basics down, I decided to go for a script that would move a physical object. I used a different script on this one, I found a what seems like easier set of instructions but not as efficient no doubt.


What this does is stores the position of the starting and end positions of the prim in vectors, then a while loop will keep looping over, if the vector distance is more than 0.001 between the 2 locations, it will move this object towards it.

The last bit for this weeks tasks was to set up a rotation script. I really do not have a clue how the script works at the moment, but will have to come back to it.

Thursday, 1 December 2011

Week 3 - Rezzing objects!

For this weeks task, we had to wing it and to cover rezzing objects by doing the research and applying different techniques. This turned out to be very good programming practise for me. Anyway, on to the task!

Firstly, I created a prim that once touched, rezzed another prim just above it. After a few clicks I realised these blocks just stay there... 


So, I went researching for a way to make them de-rez after a little while. Sure enough I found it, the llDie function. I then added a script to the bullet to make it delete itself after a certain amount of time. I will need this. This can be changed at a later date to fulfill my assignment needs.

Then I raised the velocity and the direction so that once clicked it shot a projectile.


For my assignment, I would like a cannon that once touched, fires.
This will mean that I need to find a way how to make the bullet fire from the end of the cannon, whichever way it is facing. So that will be interesting.

Wednesday, 30 November 2011

Week 2 - Touches, collisions and sensors.

This weeks tasks got a little bit more challenging compared to last weeks. But thats the whole point and its fun. We focused on collisions and sensors(scanning of objects or scripts). 


Task 1 was creating a script that upon touch, says avatar name and displays a message according to the time of day from England. The llGetGMTclock function was used, this returns the time past 00.00. This was then stored as an integer. Depending on the number of the integer, using if-else and nested if-else statements it was quite easy to work out the time of day.





For task 2 I had to create a script that would on collision with, say the name of the avatar or object and say the speed that it was travelling upon collision. It should also say the owner the of the object. This took a little bit of searching to get it down but in the end it worked! I used functions llVecMag and llDetectedVel to work out how fast the collision object was travelling. To work out the ownership of the avatar or object was done by llKey2Name and then llGetOwner. I must say I am starting to dislike scripting, but only because of all the mind-games it plays with me. Anyway, onward!





Task 3 was definitely the most difficult task for this weeks exercises. :( It was to create a script so that if touched, by the owner of the object, it scanned a 50m radius for avatars. But if it was not the owner of the object to only scan 25m. 


The difficult part was not checking to see if it was the owner that had clicked or not, that was easy. A simple If-else statement was put in. The difficult part was displaying all the avatars found in a reasonable way. The only way I could do this was to create a while loop that would go through each detected name and then print to screen.



Tuesday, 29 November 2011

Week 1 - Introduction to the LSL

In week 1, all we were doing were the very basics of scripting within Second Life. 

For the first task, I had to create a prim that could be interacted with upon touched. What the script had to do was display the avatars name once clicked and then count to 10. To do this I used the llDetectedName function and a do-while loop for the counter. Whilst browsing the LSL Tutorials, one page mentioned that a do-while loop is more efficient than a for or while loop. So here is me implementing that. 


I could show my code on here, but there is really no point for this exercise. 

For the second of this weeks tasks, which was actually a lot easier than I first thought it would be, was to create a script that keeps track of how many times it has been touched(clicked).

All I had to do for this task was add one line of code before the llSay function of the previous script and remove the loop. I also added the llSetText function so that it had hovering text above the prim. Here is it in action! 


I struggled with the second task a little bit because I was trying to over complicate things with for loops and what not! Then I realised this was only week one and I better go over it again. Im glad I did. >.>