My mod is nearing completion so now I am doing some script touch ups before I go all out, place it around the game world, and ship it. I have a couple of unrelated problems, answers to ANY of them would be appreciated.
The entire script:
(Problem 1: Bug)
I can't reproduce the bug, but just encase, I updated the script. The trigger originally only disabled it self on line 39:
if aiButton == 0 self.Disable() ;Stops player from spamming activate PlayerREF.RemoveItem(mCoin, fCost as int)
This was sufficient, but then the bug happened and I don't know why! So now I just disable the trigger immediately and manually re-enable it when necessary.
The bug only happened once and I don't know if anyone is familiar with it. The script is ran via an activatable trigger, once activated it shows either a Y/N purchasing menu, or a menu that just tells you that you can't afford it (It does this by comparing a value set in the properties). I was messing around and spamming wait, I would wait an hour at a time (Its important for the mod. It gives money every hr on update) till I had enough money to get the purchase message.
I immediately activated one of the triggers as soon as I finished waiting, and it activated the purchase message twice in a row! The first one made the purchase and took the money required for it, the second one took a completely random amount of money (it was supposed to be 5,000 gold as defined in the script properties, it only took 499) and the rest of the values set in the properties processed normally.
Did I perform the proper fix for this strange bug? Is this just a fluke that happens in the papyrus engine every once in a while? Or is there an issue with my script that I just don't see?
(Problem 2: Functions)
I am getting familiar with using functions, I don't typically make them unless I need to run/reference a particular piece of the script multiple times, or remote call a specific set of processes from another script.
"Function DeleteAll()" is the only one that has a process that runs once and doesn't need to be remote called for any reason. Is it a good idea to split up the script into blocks of functions that do specific things? Or should custom functions only be used for re-runs/remote calls?
I feel like splitting them up is cleaner then just having a stack that runs on and on like this:
Edited by smashballsx88, 31 July 2020 - 06:42 AM.