| 05-01-2008, 02:18 AM | #1 |
Just a quick question, when using a textmacro you can't use variables to supply the text can you? Example... JASS://! textmacro SpellData takes SPELLNAME, INDEX, TYPE set Temp = $SPELLNAME$[$INDEX$].$TYPE$ //! endtextmacro function ShowCast takes unit U, string CastName returns nothing local integer Index = GetUnitUserData(U) local string Temp //! runtextmacro SpellData("CastName", "Index", "Name") call DisplayTextToForce( GetPlayersAll(), "You cast " + Temp) endfunction Just trying to find an easier way to dynamically refer to Structs based off the casted spell without a ton of If abilityid = 'a005' redundant crap. I figure that this is all done via the compiler so it just replaces the text directly on save and not during gametime but I thought I'd ask to be safe. |
| 05-01-2008, 06:24 AM | #2 |
Well you can, but it's not as dynamic as you think. The output from that texmacro would indeed be: JASS:function ShowCast takes unit U, string CastName returns nothing local integer Index = GetUnitUserData(U) local string Temp set Temp = CastName[Index].Name call DisplayTextToForce( GetPlayersAll(), "You cast " + Temp) endfunction JASS://! textmacro Something takes VALUE call BJDebugMsg(I2S($VALUE$)) //! endtextmacro function SomeFunction takes nothing returns nothing local integer Int = 4 //! runtextmacro Something("Int") endfunction JASS:function SomeFunction takes nothing returns nothing local integer Int = 4 call BJDebugMsg(I2S(Int)) endfunction JASS:function SomeFunction takes nothing returns nothing local integer Int = 4 call BJDebugMsg(I2S(4)) endfunction |
| 05-01-2008, 08:06 AM | #3 |
The main problem I'm having is I have a struct array called Meteor and I'm trying to get the ability name to comeup as so, but even trying to get around this isn't working because it comes up and says that the Variable [Index] doesn't allow for syntax. So unless there's a way to disable this check in the compiler then I think I'm screwed :( Basically it needs to end up like this, but it wont until the spell is actually cast... JASS:// This is the function call which is giving the Unit casting the spell, and the name of the spell. call ShowCast(U,GetAbilityName(GetSpellAbilityId())) JASS://! textmacro SpellData takes SPELLNAME, INDEX, TYPE set Temp = $SPELLNAME$[$INDEX$].$TYPE$ //! endtextmacro function ShowCast takes unit U, string CastName returns nothing local integer Index = GetUnitUserData(U) local string Temp //! runtextmacro SpellData("CastName", "Index", "Name") <-- This turns into... set Temp = Meteor[1].Name // ^Name of the spell being cast call DisplayTextToForce( GetPlayersAll(), "You cast " + Temp) endfunction |
| 05-01-2008, 07:03 PM | #4 |
Why are you using a text macro here? It takes up more space than just typing out the generated code. |
| 05-01-2008, 11:01 PM | #5 | |
Quote:
Because I'm trying to setup a system to use in my map. It'd take longer to type out an If Then comparison for every spell im going to use for the map then to be able to dynamically get the spell name from the casting strigger and set it from there. Example... Instead of doing.... JASS:function ShowCast takes unit U, string CastName returns nothing local integer Index = GetUnitUserData(U) local string Temp if CastName == Meteor then set Temp = Meteor[Index].Name endif if CastName == Spell2 then set Temp = Spell2[Index].Name endif if CastName == Spell3 then set Temp = Spell3[Index].Name endif if CastName == Spell4 then set Temp = Spell4[Index].Name endif if CastName == Spell5 then set Temp = Spell5[Index].Name endif //Etc etc etc call DisplayTextToForce( GetPlayersAll(), "You cast " + Temp) endfunction I'd much rather have. JASS://! textmacro SpellData takes SPELLNAME, INDEX, TYPE set Temp = $SPELLNAME$[$INDEX$].$TYPE$ //! endtextmacro function ShowCast takes unit U, string CastName returns nothing local integer Index = GetUnitUserData(U) local string Temp //! runtextmacro SpellData("CastName", "Index", "Name") call DisplayTextToForce( GetPlayersAll(), "You cast " + Temp) endfunction But It doesn't seem that it works that way, I'm not even sure that we could make jass work this way, but it'd be amazing to be able to do such things. |
| 05-01-2008, 11:13 PM | #6 |
you could do: JASS://! textmacro SpellData takes SPELLNAME, INDEX, TYPE if CastName == $SPELLNAME$ then set Temp = $SPELLNAME$[$INDEX$].$TYPE$ endif //! endtextmacro function ShowCast takes unit U, string CastName returns nothing local integer Index = GetUnitUserData(U) local string Temp //! runtextmacro SpellData("Spell1", "Index", "Name") //! runtextmacro SpellData("Spell2", "Index", "Name") //! runtextmacro SpellData("Spell3", "Index", "Name") //! runtextmacro SpellData("Spell4", "Index", "Name") call DisplayTextToForce( GetPlayersAll(), "You cast " + Temp) endfunction |
| 05-02-2008, 03:18 AM | #7 |
If what you want is a way to go from an ability to a name then text macros won't help you. I'm also guessing that doing what you want them to do is highly non-trivial (if not impossible in some cases), so it won't be implemented. What you want is a single function that takes an ability id and returns the name. How that function works is really up to you. It can be a big if-then-else block, a hash table, or whatever. |
| 05-02-2008, 04:24 AM | #8 |
If you want ID to any stored values (integer, string, effect, etc) use a gamecache. The speed of the cache will be linear no matter how many spells you add, and since you are not calling it every 0.01 seconds, it shouldn't be a problem. MissionKey is the spell ID, with some type of identifier infront/behind so it doesn't get mixed up with handles. ( "ID"+I2S(spellID) ). Use key for the different types of informant: name, cast time, description, special effect, you name it. Then all it takes is a quick gamecache call and you have all the information you need. |
| 05-02-2008, 04:41 AM | #9 |
Yes seriously use GC for this, it's probably going to be faster than anything you can come up with, not like speed matters anyway in non periodic functions. |
