| 09-13-2002, 02:49 AM | #1 |
Guest | I started this tread because I can't find any info about writting custom text triggers. So EVERYBODY, ask all the questions have about custom text. I'll even go first. |
| 09-13-2002, 02:50 AM | #2 |
Guest | Does anybody have any custom text resources? |
| 09-13-2002, 02:52 AM | #3 |
You may want to explain a little more. custom text codeing? |
| 09-13-2002, 03:00 AM | #4 |
Guest | Custom Text triggers are triggers written in custom text format. Not in the WE standard format. It's like a mini scripting language. It is slightly more useful than the standard method. |
| 09-13-2002, 05:15 AM | #5 |
No one has written anything for it yet...although GoldenUrg and Weaaddar know enough about it to sink a small ship. As for myself, I haven't had to use it alot, but here are some basic things to know about JASS: -JASS is wierd and decides to put conditions in their own seperate functions that return as true or false. This just adds to load times, not sure why it's done. -All variables made in WE have udg_ in front of them, so "sheepunit" in WE would be "udg_sheepunit" in custom text. -If you download SuperIKI's dialog system it contains a way to get WE to save valid custom text code that it just happens to arbitrarily disagree with :P -If you're going to convert to custom text, make a copy of the trigger first and disable it so you still have a WE copy. This will save you headaches :) |
| 09-13-2002, 09:00 AM | #6 |
Guest | The best way to start learning it is to take make some triggers in WE that you know, convert it to custom text and then look at it and figure out exactly what's going one. Study it line by line until you know what it all does. Then when you don't know how you would write something, create a trigger and convert it to custom text and see how it's done. Once you get a bit comfortable, export the script of your map and see how it's all put together, explore Blizzard.j and see some other functions and ways of doing things that the editor won't allow you to do through the GUI. |
| 09-13-2002, 09:16 AM | #7 |
Custom Text Triggers. First of all to make one. You make a new Trigger. Then go to the Edit Menu, then select Convert to Custom Text. This is where it starts to get fun. Okay I will first say some nice ways to learn and then go into some things it can and can not do. This will not be a Full post on everything I know. That would take to long. Custom Trigger are basicly Writing triggers without the Graphical Interface. Their are some things that can't be done with the GUI. To me it is a more comfortable place to program in. Although I did grow up on dos. (No I am not old, 18) LEARNING Some nice ways to learn is to convert already done triggers to Custom Text Trigger. Make sure you saved the map before this, could get very harry if not. Then you see how the stuff you know how to do GUI is in Custom. Then you can tweak. The Blizzard.j and Common.j file will be your best friend if you do custom. I always have them open. Searching for functions I need. Read them you can learn to do some awesome stuff. Look at other people who have done custom triggers. I will be releasing a map with one soon. Now when you look at their stuff don't steal, Give them Credit for what you did Post their name as a comment by their part. If they say don't mess with my code. Learn it and then make your own, but better. TIPS In a Custom Trigger You can't declare Globals in it so you do them in the Trigger editor. The only way to declare a variable in custom triggers is to use this format local <Var Type> <Var Name> and for arrays local <Var Type> array <Var Name> You always have to have your integers at the begining of the function. Enabling or saving your map causes it to validate your script, make sure their is nothing wrong with it, if so it gives you the line a error reason and disables the trigger. I enable and disable after almsot everyline or as close as I can get to that. Making sure I got it all right. There are variable types for everything. From playercolor to integer. Whenever you want to display something for example call DisplayTimedTextToPlayer(GetTriggerPlayer(), 0, 0, 60, "Miss typed the command") You can have it display a lot of stuff. but they either have to be functions that return a string. Or a String compatible variable. For example i can't put a integer to display without using the converters. , I2S(TotalCreamSodas ) this is a Integer to String converter. I don't know how basic or advance you want to know. Please ask questions and I will add on to this post. You can ask all the Variable types. About anything holler. LOL even how to parse a string. |
| 09-13-2002, 12:59 PM | #8 | |
Quote:
I don't quite get you, but I think you think, that the WorldEditor does not always work with my engine. ARBITRARILY? No. I'll explain how you can use functions in any trigger that are defined in another. This allows you to write powerful programs for your map with multiple triggers using functions from the same library. That's how the dialog engine works. If you understand that, you'll be able to use it better. Here's how: Normally functions cannot be called from other triggers. So if you make a function in trigger a, it can't be called from trigger b. That's CRAP. If you make 2 functions - one in trigger a and one in trigger b - that have the same name, then your map will not save. It'll deactivate your triggers, because of the double function. BUT: Every trigger for itself can be deactivated and reactivated. So the "Activation Compile" that is run on activating a trigger does only compile the single trigger. So make it that way: First of all, create a trigger and define a function. When the map is saved, this trigger will be on top of the other triggers in the .j file. This is necessary, because you want to use its functions. Now, write your trigger that wants to call the function. If you just use the function it won't work. You won't be able to enable the trigger (remember: only the single trigger gets compiled on activation). The function you want to use is in the other trigger. And here comes the trick *drumroll*: Define a dummy function exactly named after the function you want to use. Make it return a dummy value (IMPORTANT! WE will crash if you don't return a value here. This did bug me as well!). With the dummy function the trigger can be activated. Now: DO NOT SAVE YOUR MAP WITH THE DUMMY ACTIVATED, because the dummy and your actual function together are 2 functions with the same name -> not good. Instead: After having the trigger activated, comment out the dummy function (using //) and save the map. That's it. Maybe you didn't get what I meant, but just download the Dialog Engine v2.0 and you'll see. Or you just ask me here. |
| 09-13-2002, 07:37 PM | #9 |
Just a small boat? Jass is addictive, Its not very hard to learn either. Just take some time to get its quirks, however you'll realize jass is a pretty crippled language when you start trying to create conversions, I'd be intrested on learning how to do Includes or headers (so you don't have to rely superkis trick) but eh what can one do. I've found atleast 2 bugged functions other then the ones mentioned as not working and 1 or 2 that are just named confusingly (which is why they ussually are renamed in blizz.j as dumby functions Like RemoveItemHero which isn't remove an item from a hero but drop it is renamed to DropItemBj in blizz.j or something to that extent.) Also Jass is picky about capitals I'm not sure how many times I've comes across this but I aciddently write my variable udg_DB[Indexer(x,y)] as udg_db[indexer(x,y)] or somehting to that extent will create 3000+ errors. The compiler is utterly useless and the fact that Jass compiles trigger seperetly is even more bothersome. If you have taken a programming class in high school and were brainwashed to use varaible names with relevence and use different variable for each value then I suggest you goto your school and slap your teacher that is a terrible practice and should be avoided. ALWAYS use Arrays if you have more then 1 of a data type. Also I find it better to name it simmilar to the data type with arrays (i.e. if its an array of integers call it int[x]). There are no long integers in Jass as far as I know, so you can define something like 99999999999999 to an integer and still be alright. Also there is no garbage collect function, so when you get a chance destroy or recycle. Try to avoid having more then 12 dialogs as they seem to be very memory extensive. 2d arrays are relatively simple, but to make it even easier I suggest creating a function to do it for you. function indexer takes integer x, integer y returns integer return(x*sizeofydimesion+y) endfunction !NOTE you must know the size of the Y dimesion the X dimesion can length then to use it you will use your array varaible like so..array[indexer(x,y)]. This will make your life alot easier if your working on a varaible intensive project. I was able to take about 28 vars down to 6 with this little trick Also if you wanna make your map completely unreadable do everything in 1 trigger its not a very suggested practice but you won't get the error that superiki or the problem he was having. Always if possible work in variableID (type) as those are just integers so you can plug it in to 1 integer array and save more vars that way. To avoid alot of loading take a second and copy the creating unit section and make them all start at different increments of 0.01 second, you'll be amazed at what this does for lag and loading. Then save the .j and add it to your map (Only really suggested on above a 100 preplaced units). To use arrays in events copy the events of your trigger which don't work (cuz they have arrays) then paste it into where you define the varaibles (I.e. after set udg_d_player[x]= dialogcreate()) (ussually your melee initlization trigger). Get rid of the events at the not working trigger. Just the event not the add action. It should work I'll paste a working example here. Code:
set udg_d_Player[1] = DialogCreate()
set udg_d_Player[2] = DialogCreate()
set udg_d_Player[3] = DialogCreate()
set udg_d_Player[4] = DialogCreate()
call TriggerRegisterDialogEventBJ( gg_trg_Response, udg_d_Player[1] )
call TriggerRegisterDialogEventBJ( gg_trg_Response, udg_d_Player[2] )
call TriggerRegisterDialogEventBJ( gg_trg_Response, udg_d_Player[3] )
call TriggerRegisterDialogEventBJ( gg_trg_Response, udg_d_Player[4] ) |
| 09-13-2002, 08:03 PM | #10 |
Guest | ^Bump^ :P:rolleyes: |
| 09-13-2002, 08:59 PM | #11 |
Also never trust code generated by worldedit its ussually sloppy and memory eating don't use multiple functions for ifs justs do 1 if (x+10=11 and y=true) then or whatever your condtions are and don't even bother with returning a boolean just do it the easy way (My way!). Loop like a fiend if neccesary. I have a point where I'm using 2 loops. Loops are good not bad. Nesting is a perk of Jass scripting over worldedit. |
| 09-13-2002, 09:09 PM | #12 |
Guest | Weaaddar, your comment about using arrays as much as possible in place of as many variables as possible...I see your point, but come on, be realistic. What's more intuitive, having three variables named thusly: integer PlayerGoldAmount integer ComputerGoldAmount integer NeutralGoldAmount Or representing them like this: integer int[0] integer int[1] integer int[2] The answer is obvious, of course. While it may be indicative of one's more excellent mental prowess to be able to assign, categorize, and recollect what array index goes with what variable, it befalls the more mundane programmers among us to make use of a multitude of intuitively named variables. :) And rightfully so! Programming is supposed to be us talking to the computer getting it to do things for us more efficiently. And I prefer to talk to my computer in English. Ok, ok, enough of me rambling. So tell me, what is with the obsession to reduce variable counts? Personally I don't see the big deal. Care. |
| 09-13-2002, 09:34 PM | #13 |
well if you have values of Player1gold Player2gold (Computer) and player3gold (Nuetral) wouldn't you find it easier to just name it thus Goldofplayer[1] Goldofplayer[2]...Now You can even check there amount of gold quicker by going For integer a 1-3 if goldofplayer[integera] > 900 do action else do nothing. Also comments work to help identify and if you really are having problems you can always cheat and set a local value equal to your variable. I just find that people are too obsessed with this quintity over quality. I perfer 5 vars to 50 variables. Call me sick in the head...But i hate the varaible window defining 50 different types of variables sounds more painful then going to the dentist to get all my teeth pulled. I'm saying in most cases varaibles are ussually related. Even in your example there gold. And once in array form you can run a for loop through it. And in most cases if there not related ussually you keep something consistant (Ie player count) so the first 12 values of your integer array is gold the next 12 is the type of unit you control and the third 12 is your current str. Which just goes on with the 2d array. So you'd set up indexer as X*12+y... then just remember to set 1 if you want to check gold 2 if you want to check unit type 3 if you want strength and the player number of the player you want. All of this can apear as a comment somewhere for you with bad memories. it also helps becuase if you make your varaibles as SIMPLE as possible you have almost NO CHANCE in hell of making a spelling mistake. |
| 09-13-2002, 09:43 PM | #14 |
Guest | This is great and all, but us people use to pointing and clicking to make our triggers and don't know anything about programming have no clue what you all are saying. Most of the stuff seems very advacned, any tips on us people for getting started? Resources of any kind? |
| 09-13-2002, 09:56 PM | #15 |
Read everyone elses comments except mine and superiki there more based for the programmer trying to pull off some tricks. DOMs Dataangel and everyones elses all give guides and tricks to help those learning Jass. Jass is a VERY easy to learn programing language but seems to have a very steep learning curve that plateus once you get the basic. |
