View unanswered posts | View active topics It is currently Fri Dec 27, 2024 8:11 am



Reply to topic  [ 7 posts ] 
 Lua Scripted Actors and Abilities Topic 
Author Message

Joined: Sun Nov 22, 2009 3:32 pm
Posts: 5
Reply with quote
Post 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


Last edited by Delta on Mon Nov 23, 2009 7:00 pm, edited 3 times in total.



Sun Nov 22, 2009 8:41 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post 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


Sun Nov 22, 2009 8:44 pm
Profile

Joined: Sun Nov 22, 2009 3:32 pm
Posts: 5
Reply with quote
Post 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


Last edited by Delta on Sun Nov 22, 2009 9:39 pm, edited 3 times in total.



Sun Nov 22, 2009 8:54 pm
Profile
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post 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.


Sun Nov 22, 2009 9:15 pm
Profile

Joined: Sun Nov 22, 2009 3:32 pm
Posts: 5
Reply with quote
Post 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


Mon Nov 23, 2009 7:13 pm
Profile
User avatar

Joined: Fri Jan 26, 2007 3:22 am
Posts: 1451
Reply with quote
Post Re: Lua Scripted Actors and Abilities Topic
yeah here's an improvement --

learn how to post


Sat Dec 05, 2009 3:29 am
Profile

Joined: Thu Sep 03, 2009 6:01 pm
Posts: 56
Reply with quote
Post Re: Lua Scripted Actors and Abilities Topic
Stop
Using
Global
Variables
Thanks


Sun Dec 06, 2009 5:14 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.085s | 13 Queries | GZIP : Off ]