help file log .. and others

A place for discussion of making game modifications.
peddroelm
Posts: 3
Joined: Mon Feb 18, 2019 8:38 am

help file log .. and others

Postby peddroelm » Mon Feb 18, 2019 9:38 am

I would like to figure out more about various mechanics . The ability to log various parameters of interest during various game states to a text file would be most helpful.

something like this

Code: Select all

    logfile = io.open("\Mods\mylog.txt", "a")
    logfile:write(growth_text.. " " ..format("%02.2f", 100 * g/n) .. "%", "\n")
    logfile:close()   


While technically working - opening and closing a disk file for each write a 'million times a second'(exaggeration) is not really viable ..
Could put it at the beginning and end of each .lua file I need it - but I'm not certain how much better that would be or if it would even work (attempt to open/close file already opened/closed errors).

BASIC REQUEST:
Anybody knows where I would need to put the file open and file close instructions in a way that the file is only opened once and closed at game exit (once) while giving access to the logfile handle in all .lua files ?

EXTRA:
Better yet give me/modders access to writemodlog function that appends to the mod's log file file and all adds timestamp before the text (to make it more usable with multiple mods ?)

EXTRA NICE:
add an ingame log window to F2 shortcut separate to the F1 dev window in which modders could direct heir mods output without mixing with anything else .. Any viable combat log mod would need something like this.

EXTRA NICE 2:
Ability to config in a file to select what output to display in the F2 feedback window [all active mods or a smaller enumeration of mods ] ..

BUNCH OF SEPARATE FEATURE REQUESTS: ..
Separate question for modders & devs .. how hard would be to implement CTRL + A select all your ships during combat ? In big fights it can take a long time to select all your ships ..

Add undo redo functionality to combat ? working 2 minutes to make a ship selection and then losing it because of a click on missile/empty space can be quite maddening .. (undo - get your precious selection back) . The same input key issue different commands based on context is a cardinal sin [ insert mass effect 3 space omnikey memes - a single key to do revive OR sprint OR take cover OR object interaction ..] . That's how you end up shooting the target you're trying to capture and other mishaps .. Undo shortcut would help ..undoing miss clicks in long tedious battles ..
"..The "everything on SpaceBar" system is one of the most-hated and dumbest design decisions that non-writers made in ME3 .." random quote.
In this game right click for move OR shoot command is sometimes just as bad. The game will do precisely what you tell it to do - just it will sometimes NOT be what the player expects it to do .. with potentially disastrous game play consequences ..

Shortcut to eliminate missiles/fighters/vindicators/torps ..etc as viable targeting selection ? Not critical with combat undo but critical without.. Work bunch of seconds to make your ships selection .. closer sub-blob to target area .. start spreading your missile attacks ... click on a barely visible fighter/missile hovering over your target ... lose your current ship selection ... maddening ..

User avatar
sven
Site Admin
Posts: 1519
Joined: Sat Jan 31, 2015 10:24 pm
Location: British Columbia, Canada
Contact:

Re: help file log .. and others

Postby sven » Thu Feb 21, 2019 9:44 pm

peddroelm wrote:BASIC REQUEST:
Anybody knows where I would need to put the file open and file close instructions in a way that the file is only opened once and closed at game exit (once) while giving access to the logfile handle in all .lua files ?

EXTRA:
Better yet give me/modders access to writemodlog function that appends to the mod's log file file and all adds timestamp before the text (to make it more usable with multiple mods ?)


You should be able to write a yourlog.lua function an place it in the _G table -- making it accessible from anywhere. Something like

Code: Select all

function _G.mylog(text)
    logfile = io.open("\Mods\mylog.txt", "a")
    logfile:write(text)
    logfile:close()   
end


Or you could get a little fancier, and be lazy about opening it

Code: Select all

local logfile
function _G.mylog(text)
    if not logfile
       logfile = io.open("\Mods\mylog.txt", "a")
    end
    logfile:write(text)
end
function _G.close_mylog()
   if logfile
      logfile:close()
      logfile=nil
   end
end


Then it's just a question of deciding where to trigger close_mylog() from. If you're doing tactical stuff, on_action_complete() might not be a bad idea -- as that will get you a save everytime a full tactical action finishes running. Or, alternatively, you could put it in battle_writebacks(), so it would happen after any battle ended. Or if you're doing strategic stuff, you could make an "order callback", which would be triggered anytime a strategic action was taken. Something like:

Code: Select all

order_callback 'close mylog' | close_mylog

User avatar
sven
Site Admin
Posts: 1519
Joined: Sat Jan 31, 2015 10:24 pm
Location: British Columbia, Canada
Contact:

Re: help file log .. and others

Postby sven » Thu Feb 21, 2019 9:48 pm

peddroelm wrote:BUNCH OF SEPARATE FEATURE REQUESTS: ..
Separate question for modders & devs .. how hard would be to implement CTRL + A select all your ships during combat ? In big fights it can take a long time to select all your ships ..


Not that hard... It's a small quality of life thing I should probably implement myself.

peddroelm wrote: Add undo redo functionality to combat ? working 2 minutes to make a ship selection and then losing it because of a click on missile/empty space can be quite maddening .. (undo - get your precious selection back) . The same input key issue different commands based on context is a cardinal sin [ insert mass effect 3 space omnikey memes - a single key to do revive OR sprint OR take cover OR object interaction ..] . That's how you end up shooting the target you're trying to capture and other mishaps .. Undo shortcut would help ..undoing miss clicks in long tedious battles ..


CTRL+ALT+LEFT ARROW will undo in tactical combat. (CTRL+ALT+RIGHT ARROW will redo.) And CTRL+ALT+SPACE will reverse the flow of time. Um... there are some strange dev features buried in the tactical combat engine that I have yet to really decide what, if anything to do with. None of them will restore your selection state though -- that's a new feature I'd need to code up.

peddroelm
Posts: 3
Joined: Mon Feb 18, 2019 8:38 am

Re: help file log .. and others

Postby peddroelm » Fri Feb 22, 2019 9:41 am

added mylog.lua in Lua State//@@util

Code: Select all

local logfile
function _G.mylog(text)
    if not logfile
       logfile = io.open("Mods//mylog.txt", "a")
    end
    time = os.date("*t")
    logfile:write(("%02d:%02d:%02d"):format(time.hour, time.min, time.sec) .. " " .. text .. "\n")
end
function _G.close_mylog()
   if logfile
      logfile:close()
      logfile=nil
   end
end


edited some lines in boardin_actions.lua

example

Code: Select all

         local s=string.format("defender_casualties %d/attacker_hits %d/ attacker_crew %d crew hits against %s",defender_casualties,attacker_hits,attacker_crew,defender.name)
                    _G.mylog(s)
                    order_callback 'close mylog' | close_mylog


and here's an example output of mylog.txt

Code: Select all

11:23:12 defender_casualties 57/attacker_hits 100/ attacker_crew 410 crew hits against Carrier
11:23:12 attacker_casualties 23/defender_hits 48/ defender_crew 100 crew hits against Fleet Carrier
11:24:16 defender_casualties 101/attacker_hits 217/ attacker_crew 410 crew hits against Battleship
2
11:24:16 attacker_casualties 62/defender_hits 105/ defender_crew 220 crew hits against Fleet Carrier
11:24:16 defender_casualties 76/ attacker_hits 145/ attacker_crew 305 system hits against Battleship
2
11:24:16 attacker_casualties 2/defender_hits 2/ defender_crew 3 crew hits against Fleet Carrier
11:25:42 defender_casualties 53/attacker_hits 119/ attacker_crew 410 crew hits against Battleship
2
11:25:42 attacker_casualties 29/defender_hits 59/ defender_crew 119 crew hits against Fleet Carrier
11:27:09 defender_casualties 88/attacker_hits 188/ attacker_crew 352 crew hits against Battleship
1
11:27:09 attacker_casualties 48/defender_hits 96/ defender_crew 198 crew hits against Fleet Carrier
11:27:09 defender_casualties 65/ attacker_hits 135/ attacker_crew 256 system hits against Battleship
1
11:27:09 attacker_casualties 5/defender_hits 6/ defender_crew 10 crew hits against Fleet Carrier
11:28:21 defender_casualties 44/attacker_hits 104/ attacker_crew 316 crew hits against Battleship
1
11:28:21 attacker_casualties 27/defender_hits 53/ defender_crew 104 crew hits against Fleet Carrier
11:29:03 defender_casualties 20/attacker_hits 37/ attacker_crew 187 crew hits against Battleship
1
11:29:03 attacker_casualties 12/defender_hits 16/ defender_crew 37 crew hits against Battleship
3


I have no clue where the 1 2 3 lines are coming from :)

Also the deferred log file write is TERRIBLE for battle log functionality .. One needs to get the feedback line as soon as the action takes place in game NOT as a blob after the battle of 2 billion actions ends ..


Return to “Modding”

Who is online

Users browsing this forum: No registered users and 5 guests