• 🏆 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!

% in string in Custom Script

Level 3
Joined
Oct 14, 2023
Messages
9
After some digging it is clear that Custom Script uses a different method to translate the code from the Editor to war3map.j than Triggers do.
So in a Custom Script a single "%" gives "" except a Conversion Specifier(printf reference) followes even with spaces, same function in a Trigger no change.
Here are some exempels:
JASS:
In the Editor:
local string s = "%"
set s = "% and"
set s ="%% and"
When it was in a Custom Script in war3map.j:
local string s = ""
set s = "0x0.000000000000ap-1022nd"
set s ="% and"
When it was in a Trigger in war3map.j:
local string s = "%"
set s = "% and"
set s ="%% and"
To use "%" in Custom Script you have to use "%%" to get "%" in war3map.j.
I don't know why they behave differently, but my best guess is that Custom Scripts are added to war3map.j with printf and Triggers with some other methode.

I hope if someone else stumbles about this, this helps.
 
After some digging it is clear that Custom Script uses a different method to translate the code from the Editor to war3map.j than Triggers do.
So in a Custom Script a single "%" gives "" except a Conversion Specifier(printf reference) followes even with spaces, same function in a Trigger no change.
Here are some exempels:
JASS:
In the Editor:
local string s = "%"
set s = "% and"
set s ="%% and"
When it was in a Custom Script in war3map.j:
local string s = ""
set s = "0x0.000000000000ap-1022nd"
set s ="% and"
When it was in a Trigger in war3map.j:
local string s = "%"
set s = "% and"
set s ="%% and"
To use "%" in Custom Script you have to use "%%" to get "%" in war3map.j.
I don't know why they behave differently, but my best guess is that Custom Scripts are added to war3map.j with printf and Triggers with some other methode.

I hope if someone else stumbles about this, this helps.
This is a much bigger problem in Lua, where % is actually a part of the Lua syntax, and can cause the editor to outright crash upon saving.
 
Level 19
Joined
Jan 3, 2022
Messages
320
Top