View unanswered posts | View active topics It is currently Thu Nov 28, 2024 8:08 am



Reply to topic  [ 3 posts ] 
 Attaching a turret to an actor 
Author Message

Joined: Wed Feb 07, 2018 2:20 pm
Posts: 3
Reply with quote
Post Attaching a turret to an actor
My lua isn't very good

I've been using this code



This error keeps happening, any thoughts?

ERROR: MySaMs.rte/Actors/Tank/DragoonTank.lua:20: attempt to get length of field 'Turret' (a userdata value)


Fri Feb 09, 2018 1:25 am
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Attaching a turret to an actor



Fixed script. I tested with a "Crab" instead of "Dragoon MG Mount"


Issues:

- self.Turret is an actual existing variable, and you were trying to replace it with a table. No can do.

- You can't add custom variables to MOs (MovableObjects, which include actors, particles, etc.). " self.Turret[5].Offset " is no good.

- I don't know why you're starting at index 5 when adding the crab to the table



Things that worked but were changed:

- " MovableMan:IsParticle(self.turretPart[i]) " returns true, and "MovableMan:IsParticle(self.turretPart[i]) == true" also returns true. You don't need "X == true", just "X".


Fri Feb 09, 2018 3:28 am
Profile

Joined: Wed Feb 07, 2018 2:20 pm
Posts: 3
Reply with quote
Post Re: Attaching a turret to an actor
Attachment:
Tank.jpg [15.53 KiB]
Not downloaded yet
Aww sweet thanks. lua isn't my strong point.

I was changing the variables testing to see if that would fix it, but it needed code for an actor, not a craft.

Thanks it lives


Fri Feb 09, 2018 4:33 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.027s | 14 Queries | GZIP : Off ]