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] Trying to access array offset on null - Line: 480 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 480 errorHandler->error
Warning [2] Undefined array key "dateline" - Line: 481 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 481 errorHandler->error
Warning [2] Undefined array key "closed" - Line: 485 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 485 errorHandler->error
Warning [2] Undefined array key "pid" - Line: 505 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 505 errorHandler->error
Warning [2] Undefined array key "options" - Line: 512 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 512 errorHandler->error
Warning [2] Undefined array key "votes" - Line: 513 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 513 errorHandler->error
Warning [2] Undefined array key "question" - Line: 514 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 514 errorHandler->error
Warning [2] Undefined array key "numoptions" - Line: 519 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 519 errorHandler->error
Warning [2] Undefined array key "numoptions" - Line: 525 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 525 errorHandler->error
Warning [2] Undefined variable $alreadyvoted - Line: 611 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 611 errorHandler->error
Warning [2] Undefined variable $undovote - Line: 9 - File: showthread.php(631) : eval()'d code PHP 8.4.12 (Linux)
File Line Function
/showthread.php(631) : eval()'d code 9 errorHandler->error
/showthread.php 631 eval
Warning [2] Undefined array key "pid" - Line: 21 - File: showthread.php(631) : eval()'d code PHP 8.4.12 (Linux)
File Line Function
/showthread.php(631) : eval()'d code 21 errorHandler->error
/showthread.php 631 eval
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 array key "mybb" - Line: 2121 - File: inc/functions.php PHP 8.4.12 (Linux)
File Line Function
/inc/functions.php 2121 errorHandler->error
/inc/functions_indicators.php 41 my_set_array_cookie
/showthread.php 669 mark_thread_read
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 5429 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5438 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5442 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5443 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5539 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5544 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5688 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5717 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5729 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5760 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5783 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5785 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5787 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5803 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5839 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5851 - Line: 912 - File: showthread.php PHP 8.4.12 (Linux)
File Line Function
/showthread.php 912 errorHandler->error
Warning [2] Undefined array key 5429 - 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 "showimages" - Line: 811 - File: inc/functions_post.php PHP 8.4.12 (Linux)
File Line Function
/inc/functions_post.php 811 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




Poll:
You do not have permission to vote in this poll.
Total 0 vote(s) 0%
* You voted for this item. [Show Results]

Partially-complete gravity well script!
#1
What it does: It attracts objects to a certain point ('gravitypoint') instead of only pulling them in certain directions like default gravity.

What it has problems with:
  • When things are close to the center of gravity, they will swing around it wildly. This is because the gravity gets more strong the closer one is to the center, and it overshoots. I'm not completely sure of a really good way to fix this.
  • When things bump into other things in the way of the center of gravity, they always bounce away instead of just plowing in and coming to rest. Again, not entirely sure of a plausible fix.

Things it can't do yet but are possible with modification of the script:
  • Multiple gravity sources. This could also probably be done with multiple scripts running this code, actually...
  • Rotation of characters to always 'stand on' gravity sources, like Mario in Super Mario Galaxy.

Suggested by Void in the chat.

[lua]
gravitypoint = Vec2D(200, 0)
gravityxenabled = true

function gravitate(object)
if object.Fixed == false then
local xdist = gravitypoint.x - object.Position.x
local ydist = gravitypoint.y - object.Position.y

if gravityxenabled == true then
local velx = 10 - math.sqrt(math.abs(xdist) / 100)
if object.Position.x > gravitypoint.x then
velx = velx * -1
end
velx = velx * (object.Mass / 10)
--gravitypull.Velocity = Vec2D(velx, gravitypull.Velocity.y)
object.Velocity = Vec2D(object.Velocity.x + velx/10, object.Velocity.y)
print(object.Velocity.x)
end

local vely = 10 - math.sqrt(math.abs(ydist) / 1000)
if object.Position.y > gravitypoint.y then
vely = vely * -1
end
vely = vely * (object.Mass / 10)
--gravitypull.Velocity = Vec2D(gravitypull.Velocity.x, vely)
object.Velocity = Vec2D(object.Velocity.x, object.Velocity.y + vely/10)
print(object.Velocity.y)


end
end

function gravitateAll(object)
local stuff = object:getChildren()
for q = 1, #stuff do
if stuff[q] ~= nil then
if stuff[q].Type == "Box" or stuff[q].Type == "Circle" or stuff[q].Type == "Triangle" then
print(stuff[q].Name)
gravitate(stuff[q])
end
gravitateAll(stuff[q])
end
end
end

while true do
sleep(0.1)
gravitateAll(game.World)
end
[/lua]
[Image: iwn8gk.gif]
Reply


Messages In This Thread
Partially-complete gravity well script! - by Ghosty - 03-04-2013, 10:10 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)