#(derban) Proper usage of subscripts in procedures

16 messages · Page 1 of 1 (latest)

latent wyvern
#

I use many subpaths and injections in my procedures to avoid nesting in if statements or while loops.
LG_Legacy told me to put those in the subscripts: script-key and I would to know how to proper use them.

As example is <player.proc[proc_player_stats.subscripts.MONEY]> a valid usage or more like object hacking?

mcve script; Demo Script to account players pocket, debt and money hardcoded as example to show why I use them
https://paste.denizenscript.com/View/134854

And yes, I have stick around some procedures where the script part never runs as like in the mcve example. So that is not a fault in the mcve script. Some of them are never called without subpath.

fair ironBOT
#

(derban) Proper usage of subscripts in procedures

fair ironBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

latent wyvern
#

Maybe a better example. For explanation, there are two data scripts as config. This part of the procedure checks if there is an item to shoot with, if both configs doesn't define the shooting_item, it returns the standard bow. So I can use this procedure with two unique identifier to get the shooting_item noted in the configs from this specific enemy OR missing values in the config

Please ignore that the sub paths are not in a subscripts: key, that is what I have to do

hallow grove
#

Object hacking is something like <list[hello|world]>hello

#

What you're doing seems just to be an overcomplicated proc with sub scripts?

#

<player.proc[proc_player_stats.subscripts.MONEY]> calls other sub scripts which add the same define everytime and determines a calculation?

#

I mean - even if these values are not hardcoded - I dont see why it needs a subscript

#

but eh, using subscript usage is mostly personal preference

latent wyvern
# hallow grove `<player.proc[proc_player_stats.subscripts.MONEY]>` calls other sub scripts whic...

Sometimes yes, but as example I've enemies which have a spawn location via flag, other have a random location in a noted area with sometimes a preferred material to spawn on.. and some didn't have either of them. Instead of using if statements I the events I decided to to de logic in a single procedure which leads to the entry in a config - or even not (standard value applied).

and instead of a single script container for each need like proc_enemy_get_spawn_location as example I combined them in a single procedure with 300+ lines and use proc_enemy.subscripts.get_spawn_location

#

so what I didn't know was that I should put those subscripts in one of the valid keys like subscripts.
Question Do I have to use those supported keys in every script container? Like in event scripts or even task scripts?

hallow grove
#

Yeah these keys are saved specifically for sub scripts

#

You A: prevent errors highlighted by vscode extension and B: dont accidentally use sub key names which get added to script containers

latent wyvern
#

ye that maybe in future a new key can be added to script container which I already use bothered my mind yesterday, so I understand why those supported keys exist. And it's still enough versatile I only have to add 4 Spaces in some hundreds lines of code, nothing special with that^^

#

thanks for help