• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Help With File Writing Using Warcraft III

Status
Not open for further replies.
Level 3
Joined
Apr 17, 2008
Messages
41
I need a way to write information in-game to your hard drive. It's exactly how File I/O works, but I need more readable results that aren't plagued with "call Preload(". If there are methods available from older patches, I'm willing to use those as well.

Instead of this (current result):
JASS:
/*-----Please start your copy + paste on this line-----." )
call Preload( ""
	*/
library MBYourTitleHere initializer onInit
	/*" )
    call Preload( ""
	*/
	//==============================================================================
	/*" )
    call Preload( ""
	*/
    globals
	/*" )
        call Preload( ""
	*/
        public multiboard Board
	/*" )
        call Preload( ""
	*/
        public integer Rows = 1
	/*" )
        call Preload( ""
	*/
        public integer Columns = 1
	/*" )
        call Preload( ""
	*/
        public string Title = "Your Title Here"
	/*" )
        call Preload( ""
	*/
        public integer TitleColor = 16777215
	/*" )
        call Preload( ""
	*/
        public boolean array ShowIcon
	/*" )
        call Preload( ""
	*/
        public boolean array ShowText
	/*" )
        call Preload( ""
	*/
        public string array ItemText
	/*" )
        call Preload( ""
	*/
        public string array ItemIcon
	/*" )
        call Preload( ""
	*/
        public integer array ItemTextRed
	/*" )
        call Preload( ""
	*/
        public integer array ItemTextGreen
	/*" )
        call Preload( ""
	*/
        public integer array ItemTextBlue
	/*" )
        call Preload( ""
	*/
    endglobals
	/*" )
    call Preload( ""
	*/
	
	/*" )
    call Preload( ""
	*/
    private function Show_Board takes nothing returns boolean
	/*" )
        call Preload( ""
	*/
        return false
	/*" )
        call Preload( ""
	*/
    endfunction
	/*" )
    call Preload( ""
	*/
	//! textmacro MB_YourTitleHere_initializer
	/*" )
    call Preload( ""
	*/
    local trigger t = CreateTrigger()
	/*" )
    call Preload( ""
	*/
    call TriggerAddCondition(t,Condition(function Show_Board))
	/*" )
    call Preload( ""
	*/
    call TriggerRegisterPlayerChatEvent(t,Player(0),"-show MBYourTitleHere",true)
	/*" )
    call Preload( ""
	*/
	//! endtextmacro
	/*" )
    call Preload( ""
	*/
	
	/*" )
    call Preload( ""
	*/
	//==============================================================================
	/*" )
    call Preload( ""
	*/
    private function onInit takes nothing returns nothing
	/*" )
        call Preload( ""
	*/
	//! runtextmacro MB_YourTitleHere_initializer()
	/*" )
        call Preload( ""
	*/
    endfunction
	/*" )
    call Preload( ""
	*/
endlibrary
	/*" )
call Preload( ""
 - - - - - Please end your copy + paste on this line - - - - - .*/


I need something like this (this is an ideal result, it just needs to be more readable than the above result without manual work or help from 3rd party programs):
JASS:
/*-----Please start your copy + paste on this line-----.*/
library MBYourTitleHere initializer onInit
	//==============================================================================
    globals
        public multiboard Board
        public integer Rows = 1
        public integer Columns = 1
        public string Title = "Your Title Here"
        public integer TitleColor = 16777215
        public boolean array ShowIcon
        public boolean array ShowText
        public string array ItemText
        public string array ItemIcon
        public integer array ItemTextRed
        public integer array ItemTextGreen
        public integer array ItemTextBlue
    endglobals
    
    private function Show_Board takes nothing returns boolean
        return false
    endfunction
	//! textmacro MB_YourTitleHere_initializer
    local trigger t = CreateTrigger()
    call TriggerAddCondition(t,Condition(function Show_Board))
    call TriggerRegisterPlayerChatEvent(t,Player(0),"-show MBYourTitleHere",true)
	//! endtextmacro
	
	//==============================================================================
    private function onInit takes nothing returns nothing
	//! runtextmacro MB_YourTitleHere_initializer()
    endfunction
endlibrary
/*-----Please end your copy + paste on this line-----.*/
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
This (JASS code):
JASS:
function CreateLog takes nothing returns nothing
    call PreloadGenClear()
    call PreloadGenStart()

call Preload("\")

//Copy/paste everything below

function Hello takes nothing returns nothing
    local integer i = 0
    call RemoveUnit(Unit[i])
endfunction

//End Code")
    call PreloadGenEnd("Folder\\Testfile.txt")
endfunction

Became this (text-file):
Code:
function PreloadFiles takes nothing returns nothing

	call Preload( "")

//Copy/paste everything below

function Hello takes nothing returns nothing
    local integer i = 0
    call RemoveUnit(Unit[i])
endfunction

//End Code" )
	call PreloadEnd( 0.0 )

endfunction

So that's all you have to do: add enters.
Also, the spacing was done using the regular editor (JNGP automatically tabs it, which doesn't seem to work).

There is still some junk, but I don't know how to get rid of that.
 
Level 3
Joined
Apr 17, 2008
Messages
41
What about the WC3 string limit?

Edit: I may get extremely long text files, so that's still something to worry about.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I was thinking about the string limit too, but the only way I can see it can be avoided, is by breaking it up (which means more Preload-junk).
What are you trying to achieve here, by the way? If you're intent on creating text-files for a piece of code, there are bound to be better ways (like the trigger editor :D).
 
Level 3
Joined
Apr 17, 2008
Messages
41
I'm making a private project that heavily relies on lots of multiboard menus and systems (it's a large-ish project).

I need file writing because I've created a system to create multiboards in-game so you can always see what the board looks like. If I can, I want the system to generate the code required for each multiboard setup and save that code into a readable text file while organizing the text files (basically almost no manual work required on my part).

I'm looking into GameCaptureX now anyway since it seems like I can't do what I want (in this patch at least).
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Multiboard codes are usually quite big, so it will most likely break the string limit. I don't know any other way to save the entire code aside from breaking it up :/.

Instead of saving the entire code, wouldn't it be possible to convert it into a sort of code?
So the text would become more like "10x5-(0,0)"Players"-(0,1)"Kills"-(...)", which the code translates into "a 10 by 5 multiboard, item at column 0, row 0 is "Players", item at column 0, row 1 is "Kills" and so on".
If you've got some preset-functions (such as "Kills for Player(X)"), then you can call that "Function Kills" or something.

You could also organize it more clearly, so the players can actually create their own multiboards outside the game
Code:
function PreloadFiles takes nothing returns nothing

	call Preload( "")

//Multiboard Code

Dimensions: 10x5
Items:
    (x,0): Func PlayerName(x-1)
    (x,1): Func PlayerKills(x-1)
    (0,0): "Players:"
    (0,1): "Kills:"

//End Code" )
	call PreloadEnd( 0.0 )

endfunction
This is very hypothetical and, though it seems possible at first sight (to me at least :p), requires a lot of work to actually get done.
It might not be what you want, though :/.
 
Level 3
Joined
Apr 17, 2008
Messages
41
This is only handling the multiboard setup for each multiboard.

I was having trouble determining the required width of multiboard items for the stuff I was making, and was also unsure of how far text would stretch across the multiboard. I made this so I could immediately see how my changes affected the multiboard. After I'm satisfied with my result, I just need to have the code to create the multiboard.

My first examples were based off a simple test I was using for file writing. The actual system is going to generate the code to make the multiboard and will have documentation on the multiboard (each multiboard item will have its information documented, and the multiboard information will also be documented).

You could also organize it more clearly, so the players can actually create their own multiboards outside the game

That the opposite of what I'm trying to do =P. I still would have the same issue when creating the board with the editor (I need to test the map to see what my multiboard actually looks like, which takes too long).
 
Status
Not open for further replies.
Top