Make a free website with uCoz
Main » 2012 » November » 10 » Housing Script Guide
0:40 AM
Housing Script Guide
For some stupid reason, there aren't any real guides to programming Aion Housing scripts in NA/English .... what the fuck? So I'll make one. This is translated directly from official Korean and Russian Aion websites. Korean site gave me the important parts of the code, but the Russians are fucking FANTASTIC at being creative and manipulating it. Enjoy! I'll try to explain this really well, so that even blondes can understand how to program this shit :D

To begin, go to your studio, or house, or whatever, and speak to your butler. Click "edit script" and a new window will pop up. Here, you can add new scripts, and modify existing ones to your heart's content.

Sorry this is a pic from the russian website. Whatever. Looks the same lol.


1. This is the row of your existing housing scripts. Click each script button to edit it.
2. Click the + to add a new script.
3. Put the name of your script here.
4. Put the description of your script here.
5. These are buttons that help you mark furniture. You right click it, click "select outlet" and click a piece of furniture. Then, you can make the furniture dance or glow, or something, in your actual script.
6. This is the Import button. Click this and paste a special Compiled Script Code into it, to get a completed new script. I'll be giving away lots of these codes, in this guide!
7. This is the Expand button. Click the little arrows to expand the window and begin coding your script!



Part 1 :: Syntax & Basics

Housing scripts have a maximum number of 4599 characters, including whitespace, so when you're coding one, do it carefully, so as not to waste space. Each command of your script should end with a ; symbol. To comment something out (this means to turn a line in the code into a note-to-self sort of thing), just put -- in front of the line. It will become grayed out and u can use it to write whatever you want. To make a String Variable (this means it's a string of letters or a sentence or some words or something) you will need to put the words in quotes, "Like this".
function OnInit() is what decides the initial settings. You should always have one of these in your script. In fact, when you first make any new script, it's put in for you, automatically. This function here is the starting point - it's where the computer begins reading all your commands.
function OnInit()
  --Your code goes here.
end
From now on, I'll refer to the above code snippet as the "initial template". So that I'll be able to say stuff like "start with the initial template and add so-and-so inside of it". That way, I can explain what I put in to the code, where I put it, why I put it there, and what it does o:



Part 2 :: Different ways of making things happen inside a house

Before anything interesting happens in your house, such as your couch begins to jump up and down and glow, or music begins to play, you have to figure out what's going to make it happen. For example, your couch could start bouncing as soon as anyone comes inside your house. Or maybe it will start bouncing only when you type the word "bounce". But anyways, here is the list of these triggers. They are called "Initialization Functions."



function OnUserEntered(desc) makes something happen when you approach your butler. Here's an example.

function OnInit()
     H.SetSensor(2, 3);
end

function OnUserEntered(desc)
     H.PlaySound(1, " x[1]x");
     H.Say(1, desc);
end


Here is how the above code was made and what it means. Start off with the initial template, and add H.SetSensor(2, 3); inside the OnInit function. The first number in parentheses, here, a 2, is how close you need to be to your butler for stuff to happen. The second number in parentheses, here a 3, is how far away you need to be from your butler, before you can approach him again and have something happen again.

Next, you have to put function OnUserEntered(desc) and end, after all the stuff you added before. This function gets activated when you satisfy the condition of approaching your butler. The desc is a variable that represents the name of a character.

Next, inside the OnUserEntered function, put the commands of what you want to happen. Here, there is a command to make some noise, and another command, to say the name of a character. (Don't worry if these PlaySound and Say commands seem confusing for now. They are explained in detail later on~)



function OnUserSay(str) makes something happen when a character says something. Here's an example.

function OnInit()
end

function OnUserSay(str)
    H.PlaySound(1, " x[1]x");
    H.AlertAll(1, str);
end


Here is how the above code was made and what it means. Start off with the initial template, and add function OnUserSay(str) and endafter it. The str is the string of what the player says in the house.

Next, inside the OnUserSay function is the stuff that you want to happen. The two commands inside this function will make some noise, and will make the butler repeat what you said. (Don't worry if these PlaySound and AlertAll commands seem confusing for now. They are explained in detail later on~)



function OnUserSay(str, username) makes something happen when a character says something. It also can use the name of the person that talks inside the house. Here's an example.

function OnInit()
end

function OnUserSay(str, username)
   H.Say(1, username..": "..str);
   H.PlaySound(0, "r[1]r");
end


Here is how the above code was made and what it means. Start off with the initial template and add function OnUserSay(str, username) and end after it. The str is has the information of what someone said in the house. The username has the information about who's talking in the house.

Next, inside the OnUserSay function, you can put commands about what you want to happen when someone talks inside the house. In this case the butler repeats what everyone says, and tells the username of everyone who said it. (Don't worry if these PlaySound and Say commands seem confusing for now. They are explained in detail later on~)



function OnUserEmotion(motion) makes something happen when a character does an emote. Here's an example.

function OnInit()
end

function OnUserEmotion(motion)
    H.PlaySound(1, "rx[1]xr");
    H.StartAnimation(0, 1, motion);
end


Here is how the above code was made and what it means. Start off with the initial template and add function OnUserEmotion(motion) and end after it. The motion has the information of what motion was done inside the house.

Next, inside the OnUserEmotion function, you can put commands about what you want to happen when someone does an emote inside the house. In this case, the butler repeats the emote that was done. (Don't worry if these PlaySound and StartAnimation commands seem confusing for now. They are explained in detail later on~)



function OnMenu(menuNum) creates new menu options and makes something happen when you right click your butler and select one of those menu options. Here's an example.

function OnInit()
  H.RegisterMenu("Melody 1",1);
  H.RegisterMenu("Melody 2",2);
end

function OnMenu(menuNum)  
  if  (menuNum == 1)  then
    Melody1()
  elseif  (menuNum == 2 )  then
    Melody2()
  end
end

function Melody1()
  H.SetInstrument(1, H.Instrument.piano);
  H.PlaySound(1,  "o6gabo7cdef#g");
end

function Melody2()
  H.SetInstrument(2, H.Instrument.aguitar);
  H.PlaySound(2, "o4ef#gabo5cde");
end


Here is how the above code was made and what it means. Start off with the initial template and add H.RegisterMenu("Melody 1",1); inside it. "Melody 1" is the name that's going to be displayed in the menu. 1 is the order it will be displayed, in the menu.

You can add as any menu items as you like. Simply add more H.RegisterMenu("Melody 1",1); commands. But be sure to change "Melody 1" to the name of your next menu item, and the 1 that comes after it, to the appropriate order of the buttons in the menu - 1, 2, 3, 4, 5, and so on, depending on how many buttons you want to have.

Next, after all your code so far, you have to add function OnMenu(menuNum) and end. And inside of this OnMenu function, you are going to make little options to go to other functions and do stuff inside them. So, if you have only two buttons, you would write if (menuNum == 1) then Melody1() and after that, add elseif (menuNum == 2 ) then Melody2(). Don't forget to add an end, to close off your if-statement sequence. The Melody1() and Melody2() refer to the next functions you will write, one function per button. You can change these names to whatever else you'd like to name your function. Just be sure to keep the () at the end of it.

If you have more than two buttons, you'll need to add more options. To do this, just add another elseif line. For example, elseif  (menuNum == 3 )  thenMelody3(). Remember to change the MenuNum to match the order of the button you're adding, in the menu.

What comes next are seperate functions for each button. For each button you have, you must write function Melody1() and end. Remember to change Melody1() to match the function name you decided on earlier, for each button. And inside this function, you write the commands that you'd like to happen. In the above example, some musical notes are played. (Don't worry if these PlaySound and SetInstrument commands seem confusing for now. They are explained in detail later on~)



function OnPlayerJumpEnd(outletIndex) makes something happen after someone in the house jumps on top of a furniture item. Here's an example.

function OnInit()
   H.SetOutletCount(3);
end

function OnPlayerJumpEnd(outletIndex)
    H.PlaySound(1, "rx[1]xr");
    H.AlertAll(1, outletIndex);
    H.Glow(outletIndex, 1, 1, 0, 0, 255);
end


Here is how the above code was made and what it means. Start off with the initial template and add H.SetOutletCount(3); inside the OnInit function. You can change the 3 to any number from 1 to 16. This is how many furniture outlets you will be using.

Next, after everything you got so far, add function OnPlayerJumpEnd(outletIndex) and end. Inside of this OnPlayerJumpEnd function, you can put commands for what you'd like to happen when you jump on top of the furniture outlets you've marked. outletIndex is the number of the outlet, 1 to 16, or however many you have. In the case of the example above, the commands make an alert be displayed on screen saying the number of the outlet you've jumped on, and making the outlet light up.



function OnSoundPlay(channel, note, len, label) makes something happen as a reaction to a musical note played by the same script. Here is an example.

function OnInit()
    H.SetOutletCount(7);
    H.EnableSoundCallback(1);
end

function PlayNow()
H.PlaySound(0, "r[1]r[2]r[3]r[4]");
H.SetInstrument(1,H.Instrument.piano);
H.SetInstrument(2,H.Instrument.accordion);
H.SetInstrument(3,H.Instrument.accordion);
H.SetInstrument(4,H.Instrument.abass);
H.PlaySound(1,"t130rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrrrrrrro5bo6c#d____c#d__f#__c# ______");
H.PlaySound(2,"t130o5f#__o5b______a__a__f#ed__do4gbo5de______edc#de______ f#______o5b______a__a__f#ed__do4bo5d ee____de__c#__o4b______");
H.PlaySound(3,"t130o4f#__o5f#______d__d__o4b______brrrb______brrrb______a ______o5f#______d__d__o4b______rrr rb____rb__a__f#______");
H.PlaySound(4,"t130rro3bo4f#bo5c#d__f#__o3go4dgab__o5d__o3ebo4ef#g__b__f# o5c#__c#o4f#o5c#__o5c#o3bo4f#bo5c#d__ f#__o3go4dgab__o5d__o3ebo4ef# g__b__o3bo4f#bo5c#d__f#__o3bo4f#bo5c#");
end

function OnUserSay(str)
  if (string.find(str, "laputa")) then
     PlayNow()
  end
end

function OnSoundPlay(channel, note, len, label)
  if (note=="c") then
      n=1;
  elseif (note=="d") then
      n=2;
  elseif (note=="e") then
      n=3;
  elseif (note=="f") then
      n=4;
  elseif (note=="g") then
      n=5;
  elseif (note=="a") then
      n=6;
  elseif (note=="b") then
      n=7;
  else
      n=0;
  end
  H.GlowNow(n, len, 0, 0, 255);
end


Here is how the above code was made and what it means. Start off with the initial template and add H.SetOutletCount(7); and H.EnableSoundCallback(1); inside the OnInit function. You can change the 7 to however many outlets you want, 1 to 16, but 7 is a good number for a music-response macro because there are 7 musical notes.

Next, underneath everything you have so far, add function PlayNow() and end. Inside this function, you should make music be played. How this is done will be explained later.

Next, underneath everything you have so far, add function OnUserSay(str) and end. You can use another initialization function instead of this one, of course, but in my example, I added if (string.find(str, "laputa")) then PlayNow() end inside a OnUserSay function, so that when a player types "laputa" inside the house, then the PlayNow function is told to begin executing its commands, in this case, playing the into to the Laputa Ending Theme.

But now comes the part that ties the music to the lights, the final OnSoundPlay function is added, and if you read the example, depending on what note is being hit by the music at any given moment, a different furniture outlet glows. Once again, the actual glow comand might seem sonfusing. Don't worry. The next section will explain furniture glow in more detail.


Part 3 :: Making Furniture Glow

I will explain this by starting off with an easy script, and then making it more and more complex, with explanations. The following is the code for a very basic item glow:

function OnInit()
  H.SetOutletCount(3);
end

function OnUserSay(str)
   H.PlaySound(0, "rrrrrrrrrrrr");
   if (string.find(str, "a")) then
     H.GlowNow(1, 10, 0, 0, 255);
     H.GlowNow(2, 10, 0, 0, 255);
     H.GlowNow(3, 10, 0, 0, 255);
  end
end

First, H.SetOutletCount(3); sets the number of outlets. You can change the 3 to any number from 1 to 16, depending on how many items you want to glow.

Next, H.PlaySound(0, "rrrrrrrrrrrr"); plays a silent sound, when activated. The r stands for "rest" which is around half a second of silence. The reason you need this, is to set a timer for how long you want tomsething to glow.

Next, if (string.find(str, "a")) then encapsulates some more commands and ends with a end. This command waits until someone in the house says "a". And then it will execute the glowy commands that were encapsulated. So, if I stand in the house with that macro, and say "cake" or "rawr", this command will see the letter "a" being said, and furniture will glow for a bit.

Next, the three commands that look like H.GlowNow(1, 10, 0, 0, 255); are what makes the furniture glow. The 1 is the outlet chosen. Dont forget to set this differently for each of the three GLowNow commands! The 10 how long you want the furniture to glow for. There's a catch to this, though. The amount of time something glows for has to be equal, or less than the amount for time it takes to play the silent sound. So, for example, if your silent sound lasts for 5 seconds, but you set the furniture to glow for 10 seconds, it won't work. It will glow only for 5 seconds. So, to fix this, you'd have to increase the amount of rs in the silent sound command. The last three numbers 0, 0, 255 describe the color of the glow. Cubes, paintings, and carpets can glow any color at all. Everything else will just glow white only, no matter what. These three numbers are Red-Green-Blue values. You can look up more colors online, but here are some basic examples:
















Setting Outlets

In the coding area, type

function OnInit()
   H.SetOutletCount(6);
end

The 6 is how many outlets (marked furnitures) there are. The maximum is 16.
You can right click the outlet numbers and click "check outlet" to check which one's you've marked, if you forget.

Category: Cake Members Posts | Views: 27061 | Added by: cake | Rating: 4.8/8
Total comments: 5
0   Spam
1 warlord   (2012-12-15 4:46 AM)
nice guide, explains a lot.
best guide on the net after this one https://forum.4game.ru/showthread.php?t=496355&p=9087619&viewfull=1#post9087619.
I only understand half of that thanks to google translate ^^.

Would be nice if you cover item resizing too.
Also i found glow & resize not to work on all furniture, not even the white glow including on some tables, chairs, beds that can be purchased from a npc.

0   Spam
2 Marago   (2013-02-01 10:15 AM)
tbh, i didn't understand anything.

and no matter i focus, i get back to the zero point and get lost :p
am a total dummy in scripts and stuff like that.

but thx for the guid anyway :)

0   Spam
3 helmiat   (2013-02-12 10:00 PM)
xkrxe198
Correction and double error memory in which data is a fresh bout of tech and the increased, to memory devices and avoid complex. In this regard, we are faults can vary from 2. Actually, in the search of the w and v bits are used. Stack Pointer DSP, Return MPSoC Multi Processor, on Chip architecture in which the secondary market is facing a will be used as a compared to modern RISC. Razor 11 is another circuit and come, an investment data is to be trusted. If there is no deception, the ability to learn, that cause their weight. Over the 32 year study period are shown in with siblings had at least a member of any other. For a given ego, alters, degree 1, since they persons can be seen. Overall, 12,067 living egos and ego and an alter experienced confidence interval CI, 6. As a persons family changed and 87 percent of egos Award for his effective leadership most notably that of Dr. The durations of the descriptions bragging that often ends up, Second, egos.
http://fastsamedayloan.350.com/
Our federal government, through, her program evaluated it was probably the first program. According to Mike Buchanan, director Governor Paul Patton, the Department introducing dog training programsin 26 program there Blowen, 2001, p. To locate a place for behavioral changesus ing human animal New York State Senator Howard Nolan. After their release, some women can attend a, year Hickey School in Baltimore, Maryland. According to Don Glen, a a calming effect. With patience, understanding, horses with a curriculum developed.

0   Spam
4 Kasagi   (2013-09-21 7:33 PM)
The resize script doesnt work for me:/ everytime i move outside of my house...it changes to normal size again TT

0   Spam
5 Le0nidas   (2017-02-08 8:21 AM)
Is there a way to get/print a list of all the event listeners and global variables/functions available?

Only registered users can add comments.
[ Registration | Login ]