Frictional Games Forum (read-only)
Elven scripting tutorials - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Articles (https://www.frictionalgames.com/forum/forum-40.html)
+---- Thread: Elven scripting tutorials (/thread-10017.html)

Pages: 1 2 3


RE: Elven scripting tutorials - Elven - 08-28-2011

Thanks Kyle Big Grin! I'll make special video about it next time then Smile! Very good idea Smile! My plan is to give all the basic and important stuff for scripter and to make them understand the scripting, not copy paste everything.

Can you explain that little bit more tho, just for myself: for (x = 1; x > 5 && x < 0; x++) { AddTimer("timer"x, x * 1.5, "TimerFunction01") }

Especially the beginning part Wink


RE: Elven scripting tutorials - Juby - 08-28-2011

(08-28-2011, 05:36 PM)Elven Wrote: Thanks Kyle Big Grin! I'll make special video about it next time then Smile! Very good idea Smile! My plan is to give all the basic and important stuff for scripter and to make them understand the scripting, not copy paste everything.

Can you explain that little bit more tho, just for myself: for (x = 1; x > 5 && x < 0; x++) { AddTimer("timer"x, x * 1.5, "TimerFunction01") }

Especially the beginning part Wink

for(int x = 1; x (greater than) 5 (and) x (less than) 0; x(adds 1)) { AddTimer("timer"+x, x (times) 1.5, "TimerFunction01") }

the information in the parenthesis explain what each part does.


RE: Elven scripting tutorials - Kyle - 08-28-2011

First, let me strech this out, so to say...

void OnStart()
{
for (int x = 1; x > 5 && x < 0; x++)
{
AddTimer("timer"+x, x * 1.5, "TimerFunction01");
}
}

Sorry about this, but it appears I was running too quick through this when typing it out those few months ago. The bolded parts are the areas where I should have put something. Tongue

Now the explanation.

A "for" loop is used to do something under certain conditions. It is mostly used with numbers that can be used multiple times to shorten your script. The parameters, or the things between the parentheses, "(" and ")", are seperated between a simicolon ( ; ). The first parameter, is the counter, which is the counting variable with it's inital value. The second one is the condition(s), this is where it loops when the conditions are true. The last parameter determines the change in the value of the variable, which is usually + 1 of it's current value (repesented by the variable++ (x++ in this case)).

When the loop is initiated, it creates multiple instances of the variable. Like any other AddTimer command function, there is it's local name, it's name before initiated, and then the name of the timer function.

With the code above in mind, I will create another piece of code which does the exact same thing, and as you can see, the code is much more repeated in a sense.

Code:
void OnStart()
{
     AddTimer("timer1", 1.5, "TimerFunction01");
     AddTimer("timer2", 3, "TimerFunction01");
     AddTimer("timer3", 4.5, "TimerFunction01");
     AddTimer("timer4", 6, "TimerFunction01");
}

Go here for more information:

http://wiki.frictionalgames.com/hpl2/tutorials/forloop


RE: Elven scripting tutorials - Elven - 08-28-2011

Thank you Kyle Smile! I am not much smarter as well Big Grin!


RE: Elven scripting tutorials - Elven - 10-04-2011

Hey. IT has been a while. School started and I was little bit busy. But I got part 3 up. This time title is "timers" Smile!



RE: Elven scripting tutorials - Elven - 10-19-2011

Added Piano Scare tutorial Smile



RE: Elven scripting tutorials - Elven - 10-20-2011

Many people had problems with adding credits. So I created quick tutorial just for credits. How to add credits Smile



RE: Elven scripting tutorials - Elven - 10-20-2011

Feels so weird posting all alone. But here is something what was requested:

Setting up development mode!



RE: Elven scripting tutorials - Elven - 02-05-2012

Added this: Make your life easier: Notepad++ with plugin & Debugging!



RE: Elven scripting tutorials - trollox - 02-05-2012

Smile i might sound retarded Elven but could you make a tortorial about installing that extra thingy to the
c++ ? i can't get it to work! I'm it's annoying me :C Would be awesome.
Trollox.
That test installation just confused me Big Grin