The following warnings occurred:
Warning [2] Undefined array key "lockoutexpiry" - Line: 94 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 94 errorHandler->error
/showthread.php 28 require_once
Warning [2] Undefined array key "lockoutexpiry" - Line: 573 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 573 errorHandler->error
/showthread.php 28 require_once
Warning [2] Undefined variable $can_access_moderationqueue - Line: 752 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 752 errorHandler->error
/showthread.php 28 require_once
Warning [2] Undefined array key "avatartype" - Line: 892 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 892 errorHandler->error
/showthread.php 28 require_once
Warning [2] Undefined array key "avatartype" - Line: 892 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 892 errorHandler->error
/showthread.php 28 require_once
Warning [2] Undefined variable $awaitingusers - Line: 34 - File: global.php(959) : eval()'d code PHP 8.4.12 (Linux)
File Line Function
/global.php(959) : eval()'d code 34 errorHandler->error
/global.php 959 eval
/showthread.php 28 require_once
Warning [2] Undefined array key "style" - Line: 1024 - File: global.php PHP 8.4.12 (Linux)
File Line Function
/global.php 1024 errorHandler->error
/showthread.php 28 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5327 - File: inc/functions.php PHP 8.4.12 (Linux)
File Line Function
/inc/functions.php 5327 errorHandler->error
/global.php 1024 build_theme_select
/showthread.php 28 require_once
Warning [2] Undefined array key 1 - Line: 1474 - File: inc/functions.php PHP 8.4.12 (Linux)
File Line Function
/inc/functions.php 1474 errorHandler->error
/inc/functions.php 1439 fetch_forum_permissions
/inc/functions.php 3077 forum_permissions
/showthread.php 661 build_forum_jump
Warning [2] Undefined variable $postsdone - Line: 906 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 906 errorHandler->error
Warning [2] Undefined array key 89758 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 89772 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 89777 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 89768 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 89782 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 89783 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 89785 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 89786 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 89787 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 89789 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 89790 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 89791 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 89793 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 89794 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 89758 - Line: 1643 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 1643 errorHandler->error
/showthread.php 924 buildtree
Warning [2] Undefined array key "profilefield" - Line: 6 - File: inc/functions_post.php(484) : eval()'d code PHP 8.4.12 (Linux)
File Line Function
/inc/functions_post.php(484) : eval()'d code 6 errorHandler->error
/inc/functions_post.php 484 eval
/showthread.php 925 build_postbit
Warning [2] Undefined array key "canonlyreplyownthreads" - Line: 672 - File: inc/functions_post.php PHP 8.4.12 (Linux)
File Line Function
/inc/functions_post.php 672 errorHandler->error
/showthread.php 925 build_postbit
Warning [2] Undefined array key "showimages" - Line: 768 - File: inc/functions_post.php PHP 8.4.12 (Linux)
File Line Function
/inc/functions_post.php 768 errorHandler->error
/showthread.php 925 build_postbit
Warning [2] Undefined array key "showvideos" - Line: 773 - File: inc/functions_post.php PHP 8.4.12 (Linux)
File Line Function
/inc/functions_post.php 773 errorHandler->error
/showthread.php 925 build_postbit
Warning [2] Undefined array key "invisible" - Line: 1568 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 1568 errorHandler->error
Warning [2] Undefined variable $threadnotesbox - Line: 33 - File: showthread.php(1600) : eval()'d code PHP 8.4.12 (Linux)
File Line Function
/showthread.php(1600) : eval()'d code 33 errorHandler->error
/showthread.php 1600 eval
Warning [2] Undefined variable $multipage - Line: 36 - File: showthread.php(1600) : eval()'d code PHP 8.4.12 (Linux)
File Line Function
/showthread.php(1600) : eval()'d code 36 errorHandler->error
/showthread.php 1600 eval
Warning [2] Undefined variable $ratethread - Line: 41 - File: showthread.php(1600) : eval()'d code PHP 8.4.12 (Linux)
File Line Function
/showthread.php(1600) : eval()'d code 41 errorHandler->error
/showthread.php 1600 eval
Warning [2] Undefined variable $multipage - Line: 68 - File: showthread.php(1600) : eval()'d code PHP 8.4.12 (Linux)
File Line Function
/showthread.php(1600) : eval()'d code 68 errorHandler->error
/showthread.php 1600 eval
Warning [2] Undefined variable $addremovesubscription - Line: 82 - File: showthread.php(1600) : eval()'d code PHP 8.4.12 (Linux)
File Line Function
/showthread.php(1600) : eval()'d code 82 errorHandler->error
/showthread.php 1600 eval
Warning [2] Undefined variable $thread_deleted - Line: 104 - File: showthread.php(1600) : eval()'d code PHP 8.4.12 (Linux)
File Line Function
/showthread.php(1600) : eval()'d code 104 errorHandler->error
/showthread.php 1600 eval




Paying bits for a script teacher
#13
Being able to change things with scripts is nice, but it's only half the fun of scripting. The second, somewhat more important half is changing things dynamically, with functions, events, and loops. I'll start with the most important.

Functions have two major uses: running the same bit of code multiple times, and running a bit of code at some other time than right at the first time the script is run.

Like variables, you need to give your functions a name. However, they're a bit more complicated to define.

A basic function will look something like this:

[lua]
function namehere()
--code
end
[/lua]

Here's an example of using a function to do something:

[lua]
local circle = create("Circle")
circle.Parent = game.World
circle.Position = Vec2D(50, 50)

function red()
circle.Color = Color(255, 0, 0)
end

function green()
circle.Color = Color(0, 255, 0)
end

function blue()
circle.Color = Color(0, 0, 255)
end

red()
sleep(2) --this important little function tells the script to pause X seconds before continuing; in this case, 2
green()
sleep(2)
blue()
[/lua]

Notice how similar the three functions are? We can make things more efficient by using something called "parameters". These are extra variables you put between the parenthesis.

[lua]
local circle = create("Circle")
circle.Parent = game.World
circle.Position = Vec2D(50, 50)
local box = create("Box")
box.Parent = game.World
box.Position = Vec2D(55, 55)

function colorize(part, thecolor) --"part" and "thecolor" are our parameters
part.Color = thecolor
end

colorize(box, Color(255, 0, 0))
--variable "box" gets sent to the function as parameter "part",
--while "Color(255, 0, 0)" gets sent to the function as parameter "thecolor"
colorize(circle, Color(100, 100, 100))
[/lua]
Reply


Messages In This Thread
Paying bits for a script teacher - by Invader - 09-04-2012, 02:15 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)