6 posts / 0 new
Last post
H1ms3lf
H1ms3lf's picture
Trusted Poster
Offline
Last seen: 1 hour 15 min ago
Joined: 04/11/2017 - 13:44
Karma: 116
Some advanced questions =D

Heya!

Some things I should ask to those who know it better, before trying to finding out via whacky means or time consuming trials.

1 - About timers, is it possible to run differently named timers in the same script at the same time? And to run one with + seconds and the other with - ? (so long they are addressed correctly and/or structured separately)

2 - Is there a limit of "nesting" that can be placed in scrips?? For example, an IF that follows with 10 conditions, under another IF holding 20 conditions, under it yet another IF with 30 conditions, etc etc, is there a limit for nesting??

3 -  Complementing the previous question and regarding CPU usage via scripts, if I place an IF and ask it to check 500 conditions (absurd, but for the sake of this example), will the engine/script stop at the first check that doesn't return valid, or will it keep running all the (499) extra checks?? I know it sounds illogical and a waste of resources to keep checking, but one never knows... Just to see how practical I should aim to be when scripting stuff.

4 - The "Begin GameMode" seems pretty intensive so I should avoid using it whenever possible, is this the complete list of begins or are there extra ones introduced by NVSE or something else?? Also are there some checks that I should avoid using? (The previous game I messed with was unpractical to check for inventory items, could cause severe lag)

5 - Lastly, I had to use a script to make a NPC say something, however the NPC should not talk on top (as interrupting) himself, so I had the script to fire only if the character should be silently, to check this silence I used the GetCurrentAIProcedure, more specific the numbers 4 and 5, for future reference, can someone comment on the difference between 4 and 5, and possibly number 6 too? To my meager understanding, number 4 should already cover any type of talking.

Quote:

if CG02.WallyPipboy == 0 && CG02ButchREF.GetisCurrentPackage CG02ButchTalkToWally == 0 && CG02WallYMackREF.GetDistance Player < 80

if CG02WallyMackREF.GetCurrentAIProcedure != 4 && CG02WallyMackREF.GetCurrentAIProcedure != 5

SayTo Player Hello

Set CG02.WallyPipboy to 1

endif

endif

TTW Version Compatibility: 

v2.9

Rating: 

0
Your rating: None
0
No votes yet
Edited by: RoyBatty on 06/07/2017 - 17:45
H1ms3lf
H1ms3lf's picture
Trusted Poster
Offline
Last seen: 1 hour 15 min ago
Joined: 04/11/2017 - 13:44
Karma: 116
Okay, seems I still don't

Okay, seems I still don't know how to post scripts... I tried using code inside the [] and then /code inside the same [], but meh didn't work ^^

Compulsive post editor and CEO for the ENDLESS WAVES OF BAD DOGGIE WEREWOLF MONSTERS THAT CHEW YOUR TOES WHILE YOU SLEEP!!

RoyBatty
RoyBatty's picture
Administrator
Offline
Last seen: 49 min 2 sec ago
Joined: 04/27/2014 - 03:26
Karma: 4973
Donor
Try SayToDone instead of

Try SayToDone instead of SayTo

Mystical Panda
Mystical Panda's picture
Offline
Last seen: 5 hours 59 min ago
Joined: 03/30/2016 - 07:02
Karma: 238
Since timers are used as

Since timers are used as conditional counters , you can have as many counters in a single script as you want to keep track of. though larger scripts and more demanding function calculations, over time in let's say a very tight loop, can take it's toll.

> start script when game starts.

> get current elasped time.

> timer 1 check.

> timer 2 check.

> timer 3 check.

> timer 3 > max

reset timer1

> etc.,.

I'd use game driven events first (if possible), since the pipeline is already in place for that instead of constantly running loops to check things; ie, things only get "fired" off when needed by an "event" rather than constantly taking up the virtual-cpu time unnecessarily. When I was playing around with my first mod, I treated quests as a "thread" so to speak. Fire it off to do a specific task at a high priority, then when it's done, exit it out. That way, when, on demand, things needs hard heavy processing, it did it, but during the course of normal game-play I put the priority back to a more normal value.

Gribbleshnibit8
Gribbleshnibit8's picture
Administrator
Offline
Last seen: 5 days 5 hours ago
Joined: 11/03/2012 - 19:06
Karma: 613
H1ms3lf wrote:

H1ms3lf wrote:

1 - About timers, is it possible to run differently named timers in the same script at the same time? And to run one with + seconds and the other with - ? (so long they are addressed correctly and/or structured separately)

Yes, timers are just variables, they will all need different names.

H1ms3lf wrote:

2 - Is there a limit of "nesting" that can be placed in scrips?? For example, an IF that follows with 10 conditions, under another IF holding 20 conditions, under it yet another IF with 30 conditions, etc etc, is there a limit for nesting??

Nesting in IF statements will go 10 deep, and then fail. Absolutely no more than 10, no matter what you do. That is, you cannot nest more than 10 if statements, you can have multiple conditions per statement, up to the line limit of iirc 255 characters.

H1ms3lf wrote:

3 -  Complementing the previous question and regarding CPU usage via scripts, if I place an IF and ask it to check 500 conditions (absurd, but for the sake of this example), will the engine/script stop at the first check that doesn't return valid, or will it keep running all the (499) extra checks?? I know it sounds illogical and a waste of resources to keep checking, but one never knows... Just to see how practical I should aim to be when scripting stuff.

Well, you would be unable to have that many conditions on a single IF anyway, but while I have not done extensive testing, the wiki says that the game does not do this. What you are asking is called short-circuit evaluation, read the notes here.

To do what you want here, your best bet is to use a UDF, or User Defined Function (read the wiki for more info) as a conditional function that you can write, that allows you to run many conditional checks in the order of most likely to fail, allowing you to effectively short-circuit the checks by exiting when you meet your first fail condition.

H1ms3lf wrote:

4 - The "Begin GameMode" seems pretty intensive so I should avoid using it whenever possible, is this the complete list of begins or are there extra ones introduced by NVSE or something else?? Also are there some checks that I should avoid using? (The previous game I messed with was unpractical to check for inventory items, could cause severe lag)

It's not so much the blocktype, but what you are doing in it. Looping, or heavy math calculations will cause much more issue than a constantly running script (the game processes all valid scripts every frame), so long as you take care to be remotely efficient.

Block types can be seen here, which is also the 'new' wiki we made to bypass some annoyances with the official one. We update that much more frequently these days (official one can suck it :P ) For things that are or are not good, will be trial and error and depend on your use cases. Ask around, post on forums, or hit us up on the Discord server (linked in the sidebar) where we have a channel specifically for asking these kinds of questions.

H1ms3lf
H1ms3lf's picture
Trusted Poster
Offline
Last seen: 1 hour 15 min ago
Joined: 04/11/2017 - 13:44
Karma: 116
Thanks a lot peeps!!

Thanks a lot peeps!!

I know that being practical and precise is the key here, just wanted to get a handling of how the engine works.
That link probably could answer all my questions, but I often don't get the terms/explanations, not a programmer 

Quote:

Nesting in IF statements will go 10 deep, and then fail.


Does this also include other places we can insert conditions, like dialog or packages, or just for scripting?
 

Quote:

the wiki says that the game does not do this. What you are asking is called 
short-circuit evaluation, read the notes here.

This is very useful info! Thought it was the other way around, that the checks would stop at the first invalid response. Gotta wisely plan each statement line then, to avoid extra checks or entering into the next line without need. That UDF seems pretty interesting, if too advanced for me, at least now I'm advised to take special care when meeting a script with begins function only ^^

Compulsive post editor and CEO for the ENDLESS WAVES OF BAD DOGGIE WEREWOLF MONSTERS THAT CHEW YOUR TOES WHILE YOU SLEEP!!