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

[Lua] Anyway to delete an object?

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,337
Hi,

So is there any function in Lua object generation that will delete a custom made object by its rawcode?

e.g.

JASS:
// i delete('H000')

This is the problem, however

JASS:
		//! i setobjecttype("units")
		//! i createobject(baseId, id)
		//! i makechange(current, "uclr", red)
		//! i makechange(current, "uclg", green)
		//! i makechange(current, "uclb", blue)

So I've made some object whose rawcode is "id" (whatever that is). Now later on I decide I don't want to change the tint of this object. So I recompile the function as

JASS:
		//! i setobjecttype("units")
		//! i createobject(baseId, id)

But, unexpectedly, instead of deleting the previous object with rawcode "id." it simply finds the entry, and changes its fields.

This means, the tint changes still exist, even though the original baseId object had normal tint.

The two solutions I've known are just to manually delete the object in the object editor, or manually make the changes, e.g.

JASS:
		//! i setobjecttype("units")
		//! i createobject(baseId, id)
		//! i makechange(current, "uclr", "255")
		//! i makechange(current, "uclg", "255")
		//! i makechange(current, "uclb", "255")

Both are these bulky and impossible to automate.

So instead, it would be easier if there was a delete object function. It would be like this

JASS:
     //! i deleteobject(id)
		//! i setobjecttype("units")
		//! i createobject(baseId, id)

Now the new object won't have the tint changes of the previous one.

So does this function exist? Or any way to do it?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
That's the Object Merger from grimext tools. Lua is a standalone language. The author just lets you command the tool via lua inputs.

The Object Merger is not exactly rich in functions and the external calls you make are executed serially, which is why rather than temp-saving data, you keep repeating reading from the map and writing to it and the individual scripts do not know of each other. If you want more control by seeing all the calls, you should merge them, respectively do not call the Object Merger initially but buffer the inputs via an own tool and transfer it to the Object Merger in the end.

Anyway, from your posts around the forum, you seem to use the Object Merger a lot. And that's why I want to mention that it's not exactly effective to spam mass objects and vJass external calls are quite slow.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
That's the Object Merger from grimext tools. Lua is a standalone language. The author just lets you command the tool via lua inputs.

The Object Merger is not exactly rich in functions and the external calls you make are executed serially, which is why rather than temp-saving data, you keep repeating reading from the map and writing to it and the individual scripts do not know of each other. If you want more control by seeing all the calls, you should merge them, respectively do not call the Object Merger initially but buffer the inputs via an own tool and transfer it to the Object Merger in the end.

Anyway, from your posts around the forum, you seem to use the Object Merger a lot. And that's why I want to mention that it's not exactly effective to spam mass objects and vJass external calls are quite slow.

not slow in external blocks, but people need to learn how to utilize them.

Looking at the documentation, there is no way to delete the files, but you may specify:

m merge changes for objects with the same rawcode, this is the default (Extensions\Merge Object Editor Data)
r replace existing objects with the imported objects in case of equal rawcodes (Extensions\Replace Object Editor Data)
i a clean import, that generates new ids for imported objects if their id is already used (Extensions\Import Object Editor Data)
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
If you want more control by seeing all the calls, you should merge them, respectively do not call the Object Merger initially but buffer the inputs via an own tool and transfer it to the Object Merger in the end.

For folks who can't write their own stuff, there doesn't seem to be a way around using the object merger via lua?

Let's suppose I would write my own tool (in Python let's say). How would I make calls to the Object Merger?

Anyway, from your posts around the forum, you seem to use the Object Merger a lot. And that's why I want to mention that it's not exactly effective to spam mass objects and vJass external calls are quite slow.

Not sure why speed would matter, since it's all technically done in constant time anyway? I mean making 10k objects by hand? Now that is slower than any automation. And what other alternative is there, besides rolling your own way to generate object data?

r replace existing objects with the imported objects in case of equal rawcodes (Extensions\Replace Object Editor Data)

This makes sense, thanks for bringing this up edo. That is why they would merge before, because of the default call. Now, how do I make it to do "replace" instead of merge, by default?

Here's an example script, where it should replace the object if there is already one with the same rawcode, rather than merge with it.

JASS:
//! externalblock extension=lua ObjectMerger $FILENAME$
    //base id for the attachment ability
    //we'll use armor bonus +1
    //! i ARMOR_ID = "AId1"
    //! i DUMMY_ID = "AT00"
    //! i upoi = 0
    //****************************
    //Dummy attachment ability
    //****************************
    //! i setobjecttype("abilities")
    //! i createobject(ARMOR_ID, DUMMY_ID)
    //! i makechange(current, "Idef", "1", "0")
    //! i makechange(current, "aite", "0")
    //! i makechange(current, "ansf", "Dummy")
    //! i makechange(current, "anam", "Attachment")
    //****************************
    //SkeletonMask attachment ability
    //****************************
    //! i setobjecttype("abilities")
    //! i createobject(DUMMY_ID, "AT01")
    //! i makechange(current, "anam", "SkeletonMaskAttachment")
    //! i makechange(current, "atat", "SkeletonMask.mdx")
    //! i makechange(current, "ata0", "head")
    //! i makechange(current, "atac", "1")
//! endexternalblock
 
Status
Not open for further replies.
Top