Bob!RynthidZerzelikyrAyanAerlintheNeftetgearknightsdarkisleSanctuary

Mag-Tools Idea: Write a line to file (moved from VT General)

Plugin/Utility Releases and Community Support. Do not release software without the author's consent.
mmod2
Posts: 6

Mag-Tools Idea: Write a line to file (moved from VT General)

Post#1 » December 8th, 2016, 1:19 am

DecalDevForums version of this thread here
So I had an idea that would extend what we can do in metas
I was talking about it in /vcg and Magnus wanted me to post it here
I decided to flesh the idea out a little bit

I moved this topic from the VTank forum since it pertains primarily to magtools

If we had a simple plugin that could write a line to file and delete, we could have permanent variables

Maybe limit the file operations to a single folder if safety is a concern (or make enabling the command an option in mag tools (my preference)

Code: Select all

/mt delete C:\permvars.txt
/mt write C:\permvars.txt /vt mexec setvar[permvar, Value]


Then when you load the meta later:

Code: Select all

/loadfile permvars.txt


If you wanted get fancy maybe add a replace line function so the file doesn't have to be completely rewritten each time that would replace the first line that matches the whole string (doesn't have to be whole line match, but replaces whole line). I think this would be useful for statistics gathering metas if you didn't want to make a command that rewrote everything at the end of your session.

Code: Select all

/mt writereplace C:\permvars.txt "/vt mexec setvar[permvar," "/vt mexec setvar[permvar, NewValue]"


If the line doesn't exist, an info message is printed and the text is written to a new line.
In the meta you could write values like... (If I'm escaping characters that I don't need to, I apologize.)

Code: Select all

ExprChat: \/mt write C\:\\permvars.txt \/vt mexec setvar\[permvar\,+getvar[permvar]+\]


Of course permavars are not the only potential use for this idea but its certainly a great one. if i had my way about the implementation of these commands. I would keep them as open as possible so people can think up new ways to use them later on.

Personally. I think it would be great if we could get this and other basic file operations so we can do things like copying over mag-tools auto trade profiles with meta triggers (maybe a file extension whitelist? user configurable). I realize with public metas there are potential security implications, but think that making it opt in (along with a very visible warning when the person/meta tries to use it when not enabled) along with warning when it is enabled should be enough. and if someone does it anyway... you can't say they weren't warned. It would take 5 seconds for an experienced user (who has enabled the option) to open a suspect met file and do a search for the offending commands

Code: Select all

regex: \\?\/\\?m\\?t\\?.\\?((d\\?e\\?l\\?e\\?t\\?e)|(c\\?o\\?p\\?y))
0 x

mmod2
Posts: 6

Re: Mag-Tools Idea: Write a line to file (moved from VT General)

Post#2 » December 8th, 2016, 2:06 am

So reading some comments on /vcg i get the feeling that security is a big reason this hasn't been implemented yet.

so, going for the other way a bit, how about this?
a command that writes a line to a file, stored in a sequestered folder in the magtools configuration directory, with no delete command

Code: Select all

/mt write textfile line


a command that reads the last written line from a text file and is output as if typed into the chat window

Code: Select all

/mt read textfile


a command that deletes every line in a specified file with the exception of the last one, or moves it somewhere else (if the previous command can be accomplished without loading all of the text file's lines into memory, This command is unnecessary.)

Code: Select all

/mt archive textfile


in this way, you can still accomplish logging by viewing the files manually, you can still achieve permavars with a file for each variable and the possible damage from bad metas is limited. if the rate at which the command could be issued could be limited by the plugin to once every second or so I don't really see much potential for abuse, but im interested to hear if anyone else thinks so.
0 x

Joeblow8579
Posts: 67

Re: Mag-Tools Idea: Write a line to file (moved from VT General)

Post#3 » December 8th, 2016, 11:37 am

What is/are the use cases for where you need permanent variables?

This all seems like a heavy trade off in terms of security and reliability for not that much gain in terms of having permanent variables. How would you use them?
0 x

Dmdtt
Moderator
Posts: 271

Re: Mag-Tools Idea: Write a line to file (moved from VT General)

Post#4 » December 8th, 2016, 12:20 pm

one idea I have that we can use this for is creating a set of permanent variables 1 per monster that would set an auto attack power setting for each monster that is updated continuously based on hit/miss rate. its easy enough to create it on a temporary basis I wrote a meta that saves all monsters encountered by an archer into a variable then gives it a value of 0-1 based on what accuracy is needed to hit that monster, if I get 10 hits in a row it reduces accuracy by .02 and for every miss it adds .05 to attack speed. saved in variables named after each monster

on selecting a target it checks testvar[wobjectgetname[wobjectgetselection[]]==1 if true then it loads a new attack speed. and sets a new selected target variable.

if we had permanent variables this would mean we could very easily automatically make an entire file dedicated to accuracy for every single monster in game and just load it into vtank each session.
0 x

Joeblow8579
Posts: 67

Re: Mag-Tools Idea: Write a line to file (moved from VT General)

Post#5 » December 8th, 2016, 3:42 pm

Couldn't you just do that already? I mean you could log all the hit/miss activity for a particular character and build a hard-coded best accuracy setting from that. I mean most archers are all going to have the same or similar buffed level of skill anyway, right? All mine do.

It certainly wouldn't be as flexible as a dynamically-created list but it isn't impossible given the current constraints.
0 x

mmod2
Posts: 6

Re: Mag-Tools Idea: Write a line to file (moved from VT General)

Post#6 » December 8th, 2016, 11:29 pm

I mean sure you can do it manually, but what if you want to gather the data over multiple sessions? for a larger dataset that sounds like a ton of mindless work.

Maybe there are security concerns with the idea as I originally put it. But once you jail the command inside a folder with a set extension I see little difference from between being able to write a line to file and save/loading metas. You can overwrite other peoples metas, you can even blank them out (with the template). You can load a very large meta on 20+ characters at the same time and watch your computer take a dump trying to keep up. Combine that with the fact that /loadfile already exists as a builtin function I’m wondering why this cat has been kept in the bag for so long.

I would use this command primarily for debugging/ logging. (yes I am aware of /log) If we can get some way to get the time into an expression. The permavars would just be a bonus for me.

Another thought: this idea also allows metas using the /mf lnc commands to pass data between characters; Immortalbob’s stipend meta could be done without having to have any character names pre-coded in. with additional meta conditions (like say file changed) I see something like this being useful in passing information between running accounts.

I think the main thing permavars are going to enable are statistic gathering functions in metas (like Dmdtt’s idea). Most everything else I can think of could be hardcoded into the meta itself.
0 x

Return to “Utilities and Plugins”

Who is online

Users browsing this forum: No registered users and 2 guests

cron

Login  •  Register