• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] LUA: Ascii typecasting on ObjectMerger

Status
Not open for further replies.

Zwiebelchen

Hosted Project GR
Level 35
Joined
Sep 17, 2009
Messages
7,236
So... I was using LUA to auto-generate levels for a channel ability. The problem comes with two object data fields that are kind of unique in their implementation for the channel ability:

'Ncl3' and 'Ncl2'; better known as "options" and "target type".
These fields have checkboxes in GUI, allowing to select stuff like "visible" or "physical spell", or target types like "point target" or "self cast".

If you use Ctrl+D to display the raw data for these fields, these options simply get reduced to integers, which should in theory make it easy to write into these fields with the ObjectMerger, right?
Wrong!

It seems that these fields are the only fields in the object editor that are not strings typecasted as integers, but actual integers.

If I use object merger like this, to write the value 0 into the field:
//! i makechange(current, "Ncl3", "1", "0")
It actually writes 48, which is the ascii equivalent of the character "0".

If I do this:
//! i makechange(current, "Ncl3", "1", 0)
then the same thing happens.

It seems that whatever I put into the field, object merger will typecast it to a string (and then back to integer), offsetting the input value by the ascii equivalent. Is there a way to prevent this? Or a clever exploit to trick the calculation into putting actual zero into the data field?
Can I use hex like 0x00 in object merger?
 
Level 4
Joined
Jun 19, 2010
Messages
49
Nice workarround! But wait!

I have identical problem with builder unit 'hpea' with object editor field "uaen". When I generate with following LUA code, this field is set to value 48:
JASS:
scope GenCustomObjectData

//! runtextmacro GENERATE_OBJECTS()

//! textmacro GENERATE_OBJECTS
//! externalblock extension=lua ObjectMerger $FILENAME$

//! i function set(field, value)
//! i     makechange(current, field, value)
//! i end

//! i setobjecttype("units")
//! i createobject("hpea", "1d1A");   resetobject(current);   createobject("hpea", "1d1A"); set("uaen", 0);

//! endexternalblock
//! endtextmacro GENERATE_OBJECTS

endscope
also for:
JASS:
...
//! i createobject("hpea", "1d1A");   resetobject(current);   createobject("hpea", "1d1A"); set("uaen", "0");
...

That was already expected, so when I use your workarround like:
JASS:
//! i createobject("hpea", "1d1A");   resetobject(current);   createobject("hpea", "1d1A"); set("uaen", string.char("0"));
It only works temporary!
What that means?!
- i activate LUA object generation in trigger, save map & close world editor
- start world editor, load map & deactivate LUA object generation in trigger => when i look into object editor & select '1d1A', it correctly shows 0 under field "uaen"
- save map => now when i look into object editor & de- & reselect '1d1A', it shows default value under field "uaen" which is 3 for units based on 'hpea'!
- even when i close map & WE and reload WE & map, the field stays on default value... so still i have no fix for this :-(

Zwiebelchen said:
Hah! Zwiebelchen vs. Object editor 1:0!
Hmmm... Zwiebelchen vs. Object editor 1:1!
 
Last edited:
Level 26
Joined
Aug 18, 2009
Messages
4,097
The //! i are for lines inside an //! externalblock. jasshelper writes them to a file and passes the file to the specified tool. Since mostly only the grimext tools are shipped as external tools in JNGP, which use Lua as an interface, you will most likely only see Lua there.
 
Level 4
Joined
Jun 19, 2010
Messages
49
@ IcemanBo, Zwiebelchen:
The ObjectMerger Hotfix from PitzerMike for the Channel ability?
Wc3C.net - View Single Post - Grim Extension Pack
Well, I'm already using the hotfix, and it also works for the channel ability, but sadly not for the worker unit 'hpea' under field "uaen"...

I replied in the thread "Lua Object Generation" from PurgeandFire for reporting this bug & for getting help in understanding ObjectMerger source code:

Lua Object Generation
 
Status
Not open for further replies.
Top