Data Realms Fan Forums
http://45.55.195.193/

Gibbing A Destroyer Cannon Shot
http://45.55.195.193/viewtopic.php?f=73&t=16475
Page 1 of 1

Author:  ZevN47 [ Tue Sep 08, 2009 10:12 pm ]
Post subject:  Gibbing A Destroyer Cannon Shot

Ok very simply I'm trying to make a dummy destroyer cannon round blow up at a certain height using one of three methods

1. gibs after set amount of time (for some unknown reason I can't do this even when I copy and paste the function update: gib object stuff

2. gibs at set height above the ground
I.E. 200pixels 100pixels

3. gibs as soon as it gets off screen (goes up out of the screen, gibs, then the flames/whatever fall down.

also just offhand what is the best lua documentation site and syntax help anyone can find... I've looked at the wiki and I've tried using the lua site but I just can't find anything that teaches rather than assumes you know everything basic and moves on. (and I have read all of Grif's tutorials thanks Grif!)

Author:  Mind [ Tue Sep 08, 2009 11:06 pm ]
Post subject:  Re: Gibbing A Destroyer Cannon Shot

http://www.datarealms.com/wiki/index.php/LuaDocs/Index

Well this sohuld really help. I knew no lua at the biginning of the summer and I learned it all via IRC and this forum :3

Anyways, here's how you would do those methods.

1.)

Code:
function Create(self)
self.gibTimer = Timer();
end
function Update(self)
if self.gibTimer:IsPastSimMS(desiredtimehere in MS; 1000MS = 1Second) then
self:GibThis();
end
end



2.) Not 100% sure bout this one


Code:
function Update(self)
if self:GetAltitude(self.Pos.Y, 5) > (pixels above ground) then
self:GibThis();
end
end



3.)

Code:
function Update(self)
if self.Pos.Y > SceneMan.SceneHeight then
self:GibThis();
end


Hope this helps :)

Author:  ZevN47 [ Wed Sep 09, 2009 11:34 pm ]
Post subject:  Re: Gibbing A Destroyer Cannon Shot

Thanks and I've used the wiki before but how do you add this to the "Destroyer.lua" file

Code:
function Create(self)
    print("CREATED: " .. self.PresetName);
    self.testTimer = Timer();
end

function Destroy(self)
    print("DESTROYED: " .. self.PresetName);
end

function Update(self)
    if self.testTimer:IsPastSimMS(2000) then
        self.Vel = self.Vel + Vector(0, -1);
    end
end


I've tried approx. 20 times and it just doesn't work (for me) ... though if I am consistent then it will be from some stupid little mistake.

Author:  Geti [ Wed Sep 09, 2009 11:53 pm ]
Post subject:  Re: Gibbing A Destroyer Cannon Shot

Code:
function Create(self)
    print("CREATED: " .. self.PresetName);
    self.testTimer = Timer();
self.gibTimer = Timer();
end
function Update(self)
if self.gibTimer:IsPastSimMS(desiredtimehere in MS; 1000MS = 1Second) then
self:GibThis();
end
end

function Destroy(self)
    print("DESTROYED: " .. self.PresetName);
end

function Update(self)
--asplode if higher than 200PX
if self:GetAltitude() > 200 then
self:GibThis();
end
--or if you go above the screen
if self.Pos.Y < 0 then
self:GibThis();
end
    if self.testTimer:IsPastSimMS(2000) then
        self.Vel = self.Vel + Vector(0, -1);
    end
end

:-o

Author:  ZevN47 [ Thu Sep 10, 2009 3:00 pm ]
Post subject:  Re: Gibbing A Destroyer Cannon Shot

Thanks Geti and Mind but I still need some help... I'll pm mind with an attachment when I get home from school.

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