Data Realms Fan Forums
http://45.55.195.193/

Lua Scripted Actors and Abilities Topic
http://45.55.195.193/viewtopic.php?f=73&t=17187
Page 1 of 1

Author:  Delta [ Sun Nov 22, 2009 8:41 pm ]
Post subject:  Lua Scripted Actors and Abilities Topic

i think this could be a good idea for the Undead Contest but i have got it after the contest,
a Vampire script, to use it just copy this and paste in a lua file.
______________________________________________________________________
function Create(self)
healTimer = Timer();
healInterval = 10;
self.healnum = 0;
end

function Update(self)
if healTimer:IsPastSimMS(healInterval) then
for actor in MovableMan.Actors do
--If the actor is on the enemy team, has more than 0 (death) health and is not the vampire, continue with code.
if actor.Team ~= self.Team and actor.Health > 0 and actor.ID ~= self.ID then
local avgx = actor.Pos.X - self.Pos.X;
local avgy = actor.Pos.Y - self.Pos.Y;
local dist = math.sqrt(avgx ^ 2 + avgy ^ 2);
if dist < 100 then
--If the actor is fairly close, take his life !
actor.Health = actor.Health - 1;
--Every (number) health taked, put a little icon above the actor's head (NOT USED but if you need)
if self.healnum == 0 then
--Create the particle (NOT USED but if you need)
local part = CreateMOSParticle("Particle Heal Effect");
--Set the particle's position to just over the actor's head (NOT USED but if you need)
part.Pos = actor.AboveHUDPos + Vector(0,4);
--Add the particle to the world.
MovableMan:AddParticle(part);
end
end
end
end
healTimer:Reset();
self.healnum = self.healnum - 1;
if self.healnum > 8 then
self.healnum = 0;
end
end
end
______________________________________________________________________
NOTE: this is just a modified copy of the medic script. But work. I haven't heavy modified the script but i have got idea.

If you have any script (for actors) just post here
Please (if possible) post only complete scripts, for help new modders

Author:  CaveCricket48 [ Sun Nov 22, 2009 8:44 pm ]
Post subject:  Re: Lua Scripted Actors and Abilities Topic

There's already a Lua Tricks Topic, this would fit in.
http://www.datarealms.com/forum/viewtopic.php?f=73&t=16260

Author:  Delta [ Sun Nov 22, 2009 8:54 pm ]
Post subject:  Re: Lua Scripted Actors and Abilities Topic

yes thanks, but in the Lua Tricks topic there aren't any complete script, just parts.
And in this topic will be posted (i think) only actors scripts

Thank Grif, these scripts aren't for me (i'm not going to use these scripts for my mods) but for public use

Author:  Grif [ Sun Nov 22, 2009 9:15 pm ]
Post subject:  Re: Lua Scripted Actors and Abilities Topic

Your script uses global variables, inefficient distance checks, and you haven't even updated and/or deleted the comments. Also, the reason the other thread involves incomplete code is because it's meant to be inserted into mods when you need to accomplish something.

This is quite literally just a useless lua script that you spent about four seconds modifying from some other example. There's no need for a thread like this, at all, because Lua Scripting is not the "post .lua files from actual mods so that Delta can change four variables and use them for himself" forum.

Author:  Delta [ Mon Nov 23, 2009 7:13 pm ]
Post subject:  Re: Lua Scripted Actors and Abilities Topic

A camo script. Press [Z] to change team and [X] to return to original

function Create(self)
self.curteam = self.Team
self.shottimer = Timer();
end

function Update(self)
if self:GetController() and UInputMan:KeyPressed(26) then
self:FlashWhite(500)
self.Team = 1 - self.curteam
end
if self:GetController() and UInputMan:KeyPressed(24) then
self.Team = self.curteam
self.shottimer:Reset()
end
if self.Health <= .5 then
self.Team = self.curteam
end
end

function Destroy(self)
self.Team = self.curteam
end

NOTE: If the actor die and it's in the opposite team, the game crash
If you change actor when he is of the opposite team he don't return to normal status, but you can reselect him.


if you have any improvement please post it

Author:  Daman [ Sat Dec 05, 2009 3:29 am ]
Post subject:  Re: Lua Scripted Actors and Abilities Topic

yeah here's an improvement --

learn how to post

Author:  DrLuke [ Sun Dec 06, 2009 5:14 pm ]
Post subject:  Re: Lua Scripted Actors and Abilities Topic

Stop
Using
Global
Variables
Thanks

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/