Scripts / Do I need an array/list/table?

Author
Message
lordjulian
10
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 27th Jun 2020 00:26
Hi guys,

I've been struggling with this for several hours, chiefly because my scripting is terrible and I don't know what I'm doing.

I have an object that gets launched into the sky (it's like a clay pigeon). I have several instances of the entity. I want each one to get launched at a slightly different time. One option is to give each instance a unique script with different variable names. That's what I've been doing up until now but it's tedious and a real pain so I was looking for a way to make the variables of the script only affect the entity instance to which it is attached. In this case I am interested in my random timer.

Below is a snippet of my latest appalling attempt; very messy and crude. It doesn't work; all the entities move at exactly the same time. I would much appreciate some help.


Julian - increasingly disillusioned and jaded
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 27th Jun 2020 14:25
so you want them to trigger when the player gets close to one but they should all fire with a slightly different timing?
this should probably do what you're attempting to do if so (just add your movement code where indicated as it wasn't in your snippet)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
lordjulian
10
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 27th Jun 2020 17:29
Thank you very much smallg. However, the entities are still moving at the same time and I don't think the timer is being used at all. I am sure I must have implemented your script snippet wrong. Here is the latest version of the script in its entirity:

Julian - increasingly disillusioned and jaded
PM
GubbyBlips
5
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 27th Jun 2020 18:15
Maybe first describe a little better what it is you are trying to do-- more details.
So, the player steps up to the line, and then the clay pigeons go off
one after the other- in random increments??

Use a global time marker with local flags.
PM
lordjulian
10
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 27th Jun 2020 18:25 Edited at: 27th Jun 2020 18:31
Quote: "So, the player steps up to the line, and then the clay pigeons go off
one after the other- in random increments??"


Yes. Exactly. The clay pigeons start off at roughly the same position on the ground. They don't need to start moving in any particular order; I just don't want them all firing off at the same time which is what they currently do.

I am not quite sure how to implement your suggestion.
Julian - increasingly disillusioned and jaded
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 27th Jun 2020 19:58
Try that
Been there, done that, got all the T-Shirts!

Attachments

Login to view attachments
PM
lordjulian
10
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 28th Jun 2020 03:17
@amenmoses, thanks so much for your help! You must have spent some time on that script. I had to make some adjustments but my entities now fly into the sky at random intervals like I wanted.

They do behave oddly if they are placed too far from the player. They start juddering upward until reaching a certain height and then fly off smoothly. I'm not sure what causes the juddering. If I place them close to the player they mostly work fine but some seem to get stuck for a few seconds. Unless you have any suggestions about that I can probably just alter their positions until they all work properly.

I have been testing the level and finding it quite addictive. You have to hit 20 targets before running out of time to win the level. So far I managed 19 a couple of times. With it being 3am I think that's enough testing for today.

Cheers, mate.
Julian - increasingly disillusioned and jaded
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 28th Jun 2020 09:44
Are they set to be always active?
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 28th Jun 2020 13:59
Quote: "You must have spent some time on that script. I"


About 15 minutes.

Been there, done that, got all the T-Shirts!
PM
lordjulian
10
Years of Service
User Offline
Joined: 10th Jan 2014
Location:
Posted: 28th Jun 2020 16:51
Efficient then!
Julian - increasingly disillusioned and jaded
PM
AmenMoses
GameGuru Master
8
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 28th Jun 2020 18:08
Lots of practice.
Been there, done that, got all the T-Shirts!
PM

Login to post a reply

Server time is: 2024-12-22 03:08:25
Your offset time is: 2024-12-22 03:08:25