Help - Search - Members - Calendar
Full Version: WRITE_ASCII and variables
The Black Wyrm's Lair - Forums > Mod development resources & discussion > Modder's Workshop
Galactygon
This piece of code is supposed to patch all .spl files to have their animation overlays (such as Fireshield Red) be played inside an external .eff file rather than the .spl file itself.

It looks pretty good until I get to the WRITE_ASCII 0x30 ~%resource%~ part. Instead of writing the string stored inside the variable, it writes "%RESOURC" instead. Is there any way to fix this?

CODE
COPY_EXISTING_REGEXP GLOB ~^.+\.spl$~ ~override~
PATCH_IF (SOURCE_SIZE > 0x71) BEGIN     // Protects against invalid files
    READ_LONG  0x64 ext_off
    READ_SHORT 0x68 ext_num
    READ_LONG  0x6a fb_off
    SET graphicsduration = 0
    FOR (outerloops = 0; outerloops < ext_num; outerloops += 1) BEGIN
        READ_SHORT ( outerloops * 0x28 + ext_off + 0x1e ) eff_num
        READ_SHORT ( outerloops * 0x28 + ext_off + 0x20 ) eff_off
        FOR (innerloops = 0; innerloops < eff_num; innerloops += 1) BEGIN
            SET "tot_off" = ("%fb_off%" + ("%eff_off%" + "%innerloops%") * 0x30)
                 READ_SHORT    "%tot_off%"         opcode    // Reads opcode
                 READ_LONG     "%tot_off%" + 0x04  param1    // Reads parameter 1
                 READ_LONG     "%tot_off%" + 0x08  param2    // Reads parameter 2
                   READ_LONG     "%tot_off%" + 0x0e duration // Reads duration
                 READ_ASCII    "%tot_off%" + 0x14 resource    // Reads resource
            PATCH_IF ( opcode = 215 AND param2 = 1 AND duration > 5 ) BEGIN
                     WRITE_SHORT    "%tot_off%"  272        // Apply Effect on Condition [Opcode 272]
                     WRITE_LONG     "%tot_off%" + 0x04  1    // Frequency [Parameter 1]
                     WRITE_LONG     "%tot_off%" + 0x08  3    // Type [Parameter 2]
                PATCH_IF !( FILE_EXISTS_IN_GAME ~%resource%.eff~ ) BEGIN
                    INNER_ACTION BEGIN
                        COPY_EXISTING ~BOLTELEM.eff~ ~override\%resource%.eff~
                              WRITE_LONG 0x10 215            // Play 3D Effect [Opcode 215]
                              WRITE_LONG 0x14 1                // Set target type to self
                              WRITE_LONG 0x1c 0             // Undetermined [Parameter 1]
                              WRITE_LONG 0x20 1             // Effect State: Play over target [Parameter 2]
                              WRITE_ASCII 0x30 ~%resource%~    (8)    // Resource played
                              WRITE_LONG 0x38 0             // Dice Thrown
                              WRITE_LONG 0x3c 0             // Dice Sides
                    END
                END
            END
        END
    END
END
BUT_ONLY_IF_IT_CHANGES


-Galactygon
Baronius
Did you try it with "%resource%" ? (Yes, the quotation marks are literal, I use them instead of tildes ~).
Galactygon
Yes, they yield the same results.

-Galactygon
Baronius
What about:

READ_ASCII "%tot_off%" + 0x14 "resource" // Reads resource

That is, enclose resource in quotation marks.
Galactygon
I am starting to think this is a WeiDU bug, so I made a post over there.

-Galactygon
Baronius
I followed the link you gave, you got a reply there. It's WRITE_EVALUATED_ASCII. It seems it has consequences that I haven't written anything special in TP2 for a long time. smile.gif
Galactygon
And I even started to develop a Weiego!

-Galactygon
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.