Saving mod user data on file

Everything about mods can be found here.

Moderator: Morax

Saving mod user data on file

Postby Franck83 » 27 Oct 2017, 22:00

HI,

Maybe someone can help.

it seems that FA lua doesn't support such lua standard :

Code: Select all
local file ,err = io.open(filename, "wb")

WARNING: Error running OnRelease script in <deleted object>: ...lliance\mods\heroes_reloaded\modules\datamanager.lua(136): access to nonexistent global variable "io"


So, how can we open access to files ?

Really annoying for my mod because i need to save players templates on local file. Somebody got experience on loading/saving data on file with FA ?
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: Saving mod user data on file

Postby Myxir » 27 Oct 2017, 22:08

you can write to game.prefs, e.g.
https://github.com/Bra1nwash3d/FAF-stuf ... fs.lua#L75
dunno if it's possible to write to other files at all
Unhappy with balance http://i.imgur.com/q5G2BlM.png
User avatar
Myxir
Evaluator
 
Posts: 791
Joined: 09 Apr 2012, 14:01
Has liked: 94 times
Been liked: 306 times
FAF User Name: Washy (irc)

Re: Saving mod user data on file

Postby Sprouto » 27 Oct 2017, 22:09

GPG intentionally removed most direct file operations from their subset of LUA in order to prevent misuse.
Sprouto
Priest
 
Posts: 366
Joined: 08 Sep 2012, 05:40
Has liked: 54 times
Been liked: 74 times
FAF User Name: Sprouto

Re: Saving mod user data on file

Postby Franck83 » 27 Oct 2017, 22:14

Ty for your replies

Really really annoying, i have a complete template table to save...

i will take a look at game.prefs. Maybe if i serialize my tables to game.prefs...

Hope there are not small limits with game.prefs....
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: Saving mod user data on file

Postby Franck83 » 28 Oct 2017, 22:18

Myxir wrote:you can write to game.prefs, e.g.
https://github.com/Bra1nwash3d/FAF-stuf ... fs.lua#L75
dunno if it's possible to write to other files at all


For the topic purpose and for exposing my happiness, just wanna say it's working and its so simple to do :) (less than 10 lines of code) !

Code: Select all
local Prefs = import('/lua/user/prefs.lua')

function SaveTemplates(table)
   Prefs.SetToCurrentProfile('Templates', table)
end

function GetTemplates()
   return Prefs.GetFromCurrentProfile('Templates')
end


It saves a complete database ;) and because it's internal -> cheats safe ^^
Alliance of Heroes Mod is out ! Try it ! It's in the Mod Vault !
User avatar
Franck83
Evaluator
 
Posts: 538
Joined: 30 Dec 2016, 11:59
Location: France
Has liked: 114 times
Been liked: 122 times
FAF User Name: Franck83

Re: Saving mod user data on file

Postby Domino » 25 Mar 2018, 23:20

Hi,

although most of the (lua) functions in game are disabled that allow you to extract data from the game and indeed add new data to a game be it running in the sim or UI side (while in game or not), there is actually away to get data in and out of the game.. however it does involve a 3rd party program to be running that connects to the game...
Domino
Priest
 
Posts: 315
Joined: 14 Mar 2012, 21:07
Has liked: 3 times
Been liked: 75 times

Re: Saving mod user data on file

Postby nine2 » 26 Mar 2018, 03:06

how do u do that domino?
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Re: Saving mod user data on file

Postby Domino » 26 Mar 2018, 03:27

Anihilnine wrote:how do u do that domino?


like this --> https://www.youtube.com/watch?v=Jt7Qy9jUJ9U

i did say you need a 3rd party program... which ZEP kindly written/gave to me years ago, i just added more functions to the external program/script to make it do what i wanted... :)

i can post it if you want.. it's a python script.. so you will have to know python to get what you want from it..
Domino
Priest
 
Posts: 315
Joined: 14 Mar 2012, 21:07
Has liked: 3 times
Been liked: 75 times

Re: Saving mod user data on file

Postby speed2 » 26 Mar 2018, 08:21

If I understand it correctly...
it starts a server and launches the game, then it listens to GPGNetSend calls from the game and saves whatever is needed.
User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2

Re: Saving mod user data on file

Postby nine2 » 26 Mar 2018, 10:15

a proxy that intercepts requests and does stuff?
nine2
Councillor - Promotion
 
Posts: 2416
Joined: 16 Apr 2013, 10:10
Has liked: 285 times
Been liked: 515 times
FAF User Name: Anihilnine

Next

Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest