View unanswered posts | View active topics It is currently Fri Dec 27, 2024 10:48 pm



Reply to topic  [ 5 posts ] 
 Gibbing A Destroyer Cannon Shot 
Author Message
User avatar

Joined: Fri Mar 13, 2009 2:31 am
Posts: 217
Location: Earth... I think
Reply with quote
Post 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!)


Tue Sep 08, 2009 10:12 pm
Profile
User avatar

Joined: Thu Mar 06, 2008 10:54 pm
Posts: 1360
Location: USA
Reply with quote
Post 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 :)


Tue Sep 08, 2009 11:06 pm
Profile
User avatar

Joined: Fri Mar 13, 2009 2:31 am
Posts: 217
Location: Earth... I think
Reply with quote
Post 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.


Wed Sep 09, 2009 11:34 pm
Profile
User avatar

Joined: Sun Jul 13, 2008 9:57 am
Posts: 4886
Location: some compy
Reply with quote
Post 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


Wed Sep 09, 2009 11:53 pm
Profile WWW
User avatar

Joined: Fri Mar 13, 2009 2:31 am
Posts: 217
Location: Earth... I think
Reply with quote
Post 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.


Thu Sep 10, 2009 3:00 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.025s | 15 Queries | GZIP : Off ]