1
Scripting Chat / What is the proper way to handle this
« on: May 17, 2020, 10:17:45 AM »
So I just recently started sending parameters through gosub and I'm trying to figure out what is considered the correct way or proper way to handle those parameters through multiple subs. Is it proper to send a parameter to a new sub using a parameter from the current sub you're in like:
I feel like I even forget at times what variables I'm trying to call on when I get a few subs deep. At the same time it's localized and reusable with variation and easy to trace back if you need to. This is a larger example of what I'm doing in one script using some pseudo code
Code: [Select]
gosub TimeAndSaveCheck #TIME %2
:or
gosub ScanForWorldSave %2
I feel like I even forget at times what variables I'm trying to call on when I get a few subs deep. At the same time it's localized and reusable with variation and easy to trace back if you need to. This is a larger example of what I'm doing in one script using some pseudo code
Code: [Select]
set %mainLoop TRUE
repeat
{
gosub Step1 #TIME #JINDEX
gosub Step2 #TIME #JINDEX
gosub Step3 #TIME #JINDEX
}
until %mainLoop = FALSE
sub Step1
Do Work
gosub TimeAndSaveCheck %1 %2
return
sub Step2
Do Work
gosub TimeAndSaveCheck %1 %2
return
sub Step3
Do Work
gosub TimeAndSaveCheck #TIME %2
Do More Work
gosub ScanForWorldSave %2
return
sub TimeAndSaveCheck
if %1 > #TIME - 60
return TRUE
gosub ScanForWorldSave %2
return FALSE
sub ScanForWorldSave
for %i %1 #JINDEX
{
scanjournal %i
if The_world_is_saving in #JOURNAL || The_world_will_save in #JOURNAL
{
wait 30s
break
}
}
return