• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

lua loadObjectEditorData

Status
Not open for further replies.
Level 24
Joined
Aug 1, 2013
Messages
4,657
Hi all.

I have a map where I create custom abilities using lua.
I do that using a textmacro that runs the objectmerger.
JASS:
//! textmacro AbilityGenerator takes RAWCODE1, RAWCODE2, ICONPATH, X, Y

//! externalblock extension=lua ObjectMerger $FILENAME$
//! i   setobjecttype("abilities")
//! i   createobject("AHhb", "$RAWCODE2$")
//! i   makechange(current, "aart", "$ICONPATH$")
//! i   makechange(current, "abpx", "$X$")
//! i   makechange(current, "abpy", "$Y$")
//! endexternalblock

//! endtextmacro

As you can see, a very simple ability based of the Holy Light ability.
But this one with the given icon and position.

Now as you can see, I have given two RAWCODEs.
The second one will be the rawcode of the ability that will be created.
The first one should be the one that the second one is kind of based of.
I want the new ability to have the same icon and buttonposition as the first one. But I dont want to have to find it in the object editor and copy and paste it over to the trigger editor.
I want to have instead of this script something like the following:
JASS:
//! textmacro AbilityGenerator takes RAWCODE1, RAWCODE2

//! externalblock extension=lua ObjectMerger $FILENAME$
//! i   setobjecttype("abilities")
//! i   createobject("ANss", "$RAWCODE2$")
//! i   makechange(current, "aart", loadObjectEditorData($RAWCODE1$, "aart"))
//! i   makechange(current, "abpx", loadObjectEditorData($RAWCODE1$, "abpx"))
//! i   makechange(current, "abpy", loadObjectEditorData($RAWCODE1$, "abpy"))
//! endexternalblock

//! endtextmacro
Now this looks exactly like I want to have... with one exception that loadObjectEditorData() doesnt exist.
But you get what I mean.

Is there ANYTHING like this so I can make an ability just like that with one simple runtextmacro for my spell?

I know about tools like the Object Data Extractor but those create JASS functions to access that data. I need LUA functions to access that data because this has to be done compiletime.
Also if you think that I shouldnt be lazy and just write those damned icons... I have to tell you that this is not exactly the script that I need, but I need that loadObjectEditorData() function.
In the actual script, it would save me like... 22 parameters... for like 300 runtextmacros... which is a rough 6600 times copy and pasting... I am lazy, but in this case, I would need this function even if I weren't.
 
Currently, there is no other way but to manually track all the data you need to access again, as you can not "read" existing object editor data once written.

In theory, this shouldn't be a problem though:
Just remove all "manual labor" object data and create *everything* with LUA, then you can simply memorize all important data fields in LUA variables.

That's how I set up my talent system in Gaias:
I just created a large list of entries (with all required object data fields) to generate, then simply commented it out.
If I ever wanted to change something retroactive, I just remove the comments and run the entire ObjectMerger query again (overwriting all data).


This seems convoluted and impractical at first, but it actually isn't when you think about it.
So if you want to auto-generate objects B based on an existing object A, why not just auto-generate object A aswell? Basicly, that's the whole idea.
So you want to have an item that shares some object data with a unit? Just remove the unit and generate both objects.

Nowadays I create almost everything with LUA. The only headache is object data that was not initially created with LUA, which must be entered by hand.
 
idk if i mentioned this in my tutorial or not, but when you have this:
JASS:
//! i   createobject("AHhb", "$RAWCODE2$")

It is essentially of the format createobject("Base", "New") where "Base" is the base ability to inherit from.

Try rewriting that as:
JASS:
//! i   createobject("$RAWCODE1$", "$RAWCODE2$")

Again, this doesn't do exactly what you want (loading object data is currently not supported in Grimex's Lua implementation), but it might work for your specific situation.

If you need more power to programmatically control objects, use GMSI or Wurst.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
@Zwiebelchen
I could indeed make everything via LUA but that would force everyone else to do the same.

@PurgeandFire
That is not what I asked for is it?
I only want to copy and paste the icon and position, the base ability will be the same for all abilities that I use this on.
As you can see in my script, I have a static base ability.
 
if $RAWCODE2$ is based off of AHhb and $RAWCODE1$ is based off of AHhb then you can base $RAWCODE1$ off $RAWCODE2$ (iirc).

i.e. Original case:
AHhb -> Rawcode 2
AHhb -> Rawcode 1

If you want to inherit some stuff (e.g. icon) from rawcode 2 then you would want your inheritance graph to look like:
AHhb -> Rawcode 2 -> Rawcode 1

if $RAWCODE2$ isn't based off of it then yeah it doesn't help you.

also i haven't tested this so idk if it works
 
Status
Not open for further replies.
Top