2DWorlds Forums
Scripts for a game. - Printable Version

+- 2DWorlds Forums (http://2dworlds.buildism.net/forum)
+-- Forum: 2DWorlds (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=4)
+--- Forum: Scripting (http://2dworlds.buildism.net/forum/forumdisplay.php?fid=13)
+--- Thread: Scripts for a game. (/showthread.php?tid=7708)



Scripts for a game. - Sazaho - 08-04-2011

Can someone please assist me with an upcoming game of mine by contributing a few scripts? Contributors don't need to do all of them but will be given credit for ones they do.


[?]= Maybe/less important
[s]= applicable to weapons (more specifically a sword)

Scripts I will need:

Time regen [?] -Qwertygiy
Poison/Health draining script [s]
Slow script [s]
Healing script -Qwertygiy


Scripting help I need:

The buildism Lua equivalent to 'if true do' if there is one
How change transparency via script (Box.Trasnparency? GetChild?)

Thank you those who will/have contributed.




RE: Scripts for a game. - Login - 08-04-2011

(08-04-2011, 08:03 PM)Sazaho Wrote: Trampoline Script [?]

Can't that be done with Bounciness?


RE: Scripts for a game. - Sazaho - 08-04-2011

(08-04-2011, 08:06 PM)Login Wrote:
(08-04-2011, 08:03 PM)Sazaho Wrote: Trampoline Script [?]

Can't that be done with Bounciness?

Yes but I'm a moron.


RE: Scripts for a game. - Qwertygiy - 08-04-2011

Time regen:

[lua]
local object = script.Parent --PUT THE SCRIPT IN THE REGENERATING THING
local parental = object.Parent
local keepsafe = object:clone()
local waittime = 60 --Seconds between regens

--Beginning of code
sleep(waittime)
script.Parent = game.World
object:remove()
local safekeep = keepsafe:clone()
safekeep.Parent = game.World
script:remove()
--End of code.
[/lua]

Why is there no loop? Because it reclones the regeneration script each time it regens!


RE: Scripts for a game. - Sazaho - 08-04-2011

(08-04-2011, 09:05 PM)Qwertygiy Wrote: Time regen:

[lua]
local object = script.Parent --PUT THE SCRIPT IN THE REGENERATING THING
local parental = object.Parent
local keepsafe = object:clone()
local waittime = 60 --Seconds between regens

--Beginning of code
sleep(waittime)
script.Parent = game.World
object:remove()
local safekeep = keepsafe:clone()
safekeep.Parent = game.World
script:remove()
--End of code.
[/lua]

Why is there no loop? Because it reclones the regeneration script each time it regens!

Thank you, QwertyGiy.


RE: Scripts for a game. - Qwertygiy - 08-04-2011

Here's a global healing script for you -- change the waittime and percentage values as wanted and place it in World.

[lua]
local waittime = 2 --How long between heals
local percentage = 2.5 --How much to heal

while true do --Constant!
sleep(waittime)
local players = game.Players:getChildren()
for q = 1, #players do
if players[q]:isA("Player") and players[q].Character and players[q].Character.Health > 0 then
--Making sure you're there
if players[q].Character.Health < players[q].Character.MaximumHealth then
if players[q].Character.Health <= (players[q].Character.MaximumHealth - (players[q].Character.MaximumHealth * percentage * 1/100)) then
players[q].Character.Health = players[q].Character.Health + (players[q].Character.MaximumHealth * percentage * 1/100)
else
players[q].Character.Health = players[q].Character.MaximumHealth
end end end end end
[/lua]


RE: Scripts for a game. - Sazaho - 08-11-2011

(08-04-2011, 09:39 PM)Qwertygiy Wrote: Here's a global healing script for you -- change the waittime and percentage values as wanted and place it in World.

[lua]
local waittime = 2 --How long between heals
local percentage = 2.5 --How much to heal

while true do --Constant!
sleep(waittime)
local players = game.Players:getChildren()
for q = 1, #players do
if players[q]:isA("Player") and players[q].Character and players[q].Character.Health > 0 then
--Making sure you're there
if players[q].Character.Health < players[q].Character.MaximumHealth then
if players[q].Character.Health <= (players[q].Character.MaximumHealth - (players[q].Character.MaximumHealth * percentage * 1/100)) then
players[q].Character.Health = players[q].Character.Health + (players[q].Character.MaximumHealth * percentage * 1/100)
else
players[q].Character.Health = players[q].Character.MaximumHealth
end end end end end
[/lua]

Thanks again, Qwertygiy