• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Lua] Editor crash upon saving a certain section of code.

Status
Not open for further replies.
Level 2
Joined
Sep 5, 2015
Messages
10
Hey all, I've asked questions a couple of times around here and now I'm back again.

Recently I've been working on some systems that have been... difficult to wrap my head around, but it seems that some changes I'm doing for some reason crashes the editor when I try to save them. I was hoping this was a problem that some of you have encountered as well.

It seems to be this specific section because if I paste this in from Visual Studio Code it crashes the editor upon saving.

Lua:
function UpdateItemDesc(i)
    local it = GetItemTypeId(i)
    local s = "|c00ffff00Class:|r " .. Item_Type[it].name
    for x = 1, STAT_COUNT, 1 do
        if Item_Bonus_Stats[x][i] > 0 then
            s = string.format(s .. "\n|cffffffff%%d %%s%%s|r", math.floor(Item_Bonus_Stats[x][i] + 0.5), Stats[x].color, Stats[x].name)
        end
        if Item_Multipliers[x][i] > 0 then
            s = string.format(s .. "\n|cffffffff%%.1f%%%% %%s%%s|r", (Item_Multipliers[x][i] * 100), Stats[x].color, Stats[x].name)
        end
    end

    if Item_Custom_Description[it] ~= nil then
        s = string.format(s .. "\n%s", Item_Custom_Description[it])
    end

    for x = 1, STAT_COUNT, 1 do
        if Item_Minor_Stats[x][i] > 0 then
            s = string.format(s .. "\n|c00808080+%%.1f%%%% %%s|r", Item_Minor_Stats[x][i], Stats[x].name)
        end
    end

    BlzSetItemExtendedTooltip(i, s)
    BlzSetItemDescription(i, s)
end
 
World Editor's Trigger Editor does not like single % use %% like you most times did.
Lua:
if Item_Custom_Description[it] ~= nil then
        s = string.format(s .. "\n%s", Item_Custom_Description[it])
end
"\n%s"

The resulting map script does have single % again, it is just trigger editor that expects something after %.
 
Level 2
Joined
Sep 5, 2015
Messages
10
World Editor's Trigger Editor does not like single % use %% like you most times did.
Lua:
if Item_Custom_Description[it] ~= nil then
        s = string.format(s .. "\n%s", Item_Custom_Description[it])
end
"\n%s"

The resulting map script does have single % again, it is just trigger editor that expects something after %.
Thanks, but yet I have another question after fixing the crash problem.

Upon running the seemingly fixed code, why does this error appear?

upload_2021-1-16_19-30-2.png



Lua:
s = string.format(s .. "\n|cffffffff%d %s%s|r", math.floor(Item_Bonus_Stats[x][i] + 0.5), Stats[x].color, Stats[x].name)
That is the line it refers to within the war3map.lua

And the code put into the editor is in the original post.

EDIT:
Oddly enough, if I remove the '%%%%' from the original code on the ninth line the code works, but I miss out on having the percent signs.

Lua:
s = string.format(s .. "\n%%.1f", (Item_Multipliers[x][i] * 100))
s = string.format(s .. "%%%%")
s = string.format(s .. " %%s%%s|r", Stats[x].color, Stats[x].name)
And if I change the lines to be separate instead the error turns to:
upload_2021-1-16_19-55-34.png


Here's some proof the code working if the percent signs removed:
upload_2021-1-16_20-0-9.png


Additionally, this line of code seems to work for some reason, but the other does not?
Lua:
s = string.format(s .. "\n|c00808080+%%.1f%%%% %%s|r", Item_Minor_Stats[x][i] * 100, Stats[x].name)
 
Last edited:
Status
Not open for further replies.
Top