| 06-01-2006, 06:12 PM | #1 |
Ok, as the thread name says, im trying to find out how to store a Code variable into a gamecache, im not sure if its classed as a string or a other variable, wether to use H2I on it etc. Any ideas? |
| 06-01-2006, 06:20 PM | #2 |
What good is it to save code into a variable? Why not just call the function as necessary or setup events and just make a local trigger? If you have some real reason, then by all means, but I just can't see the usefulness of it. >_> |
| 06-01-2006, 06:29 PM | #3 |
Believe me, i really need to know how lol, because, if youv seen my tiny casual functions system, iv started making a spell, and using the system. I need to know how to store a code in a gamecache because i updated my functions, when the projectile finds its target, or its point, its going to run a function only if needed, a callback IS needed in a projectile, otherwise nobody will know when the projectile reached its target, thus disabling the advantage of using Jass, both the functions return nothing. I was going to use the code as a string and use ExecuteFunc, but i need the code to be able to attach variables to it like i timer. (I have a feeling this makes no sense because i kept adding things to it) Theres 2 functions from the projectile, so i need to store 1 in the cache to reload it in the other. |
| 06-01-2006, 06:33 PM | #4 | |
Quote:
So you know which function you want to run ahead of time. JASS:call MyFunction(myUnit, myOtherthing) If you're desperately in need for it still, try this sort of typecasting. I have no idea if it will work in game, but you would probably need it. JASS:function S2C takes string s returns code return s return null endfunction But really though, there are other ways to do it. |
| 06-01-2006, 06:39 PM | #5 |
I'm not really sure on the specifics of the 'code' type. One method of 'storing' it to run at a set time, however, would be to create a timer, call TimerStart with a duration of 0 and your required code parameter and then pause the timer. Attach this timer to whatever you were going to attach the code to, then when you need the code to run, you can call ResumeTimer on the timer and the code would be executed. (This would, unfortunately, require you cleaning up the timer afterwards) Edit: In response to your post below, you could attach anything you needed to, to the timer. |
| 06-01-2006, 06:40 PM | #6 | |
Well, i thought about most of that, especially the S2C and H2I/H2S/C2S/C2H But i doubt it will work, i cant really just type it in like call SomeFunc(), because i need to attach variables to it, i need to attach a unit (the credit from the projectile) to the code, so i can find out who did the damage in the function the code will run EDIT: Quote:
Hmm, that might just work, il go test it out and reply my finding later, thanks |
| 06-01-2006, 06:43 PM | #7 |
So use arguments. JASS:call MyFunction(unitCredit, unitProjectile, dmgAmount) And doing it as Blu suggested is one of the other ways I was referring to. You really don't have to 'store' the code. |
| 06-01-2006, 06:47 PM | #8 |
Code functions can't take arguements. I also assume he wants the 'code function' that will be run to be 'dynamically specified'. It he had only one, preset function that he wanted to be executed, he wouldn't be using the code type. |
| 06-01-2006, 06:48 PM | #9 |
@ Rising_Dusk - Your really not getting this, i DO have to store the code, a need to store a unit to the code (the creditable unit), then i needed to store the code to a timer, which blu just pointed out slightly the obvious in doing. This is the basis is what i want: Im making a spell, its like the Shadow Strike spell in every way, initial damage then damage over time. But, its going to target the ground, when the projectile hits its going to hit all enemy units in radius with this initial damage and damage over time. Im using 3 functions to do this. I have a bunch of constants that refer detailed things such as damage function DoTimedDamage function DoInitalDamageAndStartTimer function BeginSpellAndLaunchTheProjectile (takes x, takes y, takes credit) Now in this function, its going to wait until the projectile has hit the ground. To do this i need the projectile to run DoInitalDamageAndStartTimer, but, it takes nothing and returns nothing, so i needed the code variable to store the unit, X and Y so i can use it again. And i cant run DoInitalDamageAndStartTimer until the projectiles finished, so i cant use call in the BeginSpell function @ blu - wont a timer of 0. instantly expire before i pause it? or does 0. have a different value in time? |
| 06-01-2006, 06:53 PM | #10 |
Well Ok. :/ I think I understand what you're saying, just don't understand WHY. I hate it when people insinuate I'm an idiot as though what you're saying should be obvious. |
| 06-01-2006, 06:56 PM | #11 |
Using return bug to convert to string should never be done, if you actually wants to use the string, it is not good. 'code' is not a handle-derrived type, but it works with the return bug. Just use C2I and I2C functions: JASS:function C2I takes code c returns integer return c return 0 endfunction function I2C takes integer i returns code return i return null endfunction That should work, just store the integer in the cache. |
| 06-01-2006, 06:57 PM | #12 |
Returns a unique integer? Useful to know. |
| 06-01-2006, 07:07 PM | #13 |
Great, solves all my problems, i think =/. Il see what i can do now i know code can be converted to integer EDIT: Whats blank for code? null? |
| 06-01-2006, 07:12 PM | #14 |
Likely. |
| 06-01-2006, 07:13 PM | #15 |
Since when can you store code types to anything? I once tried local code blabla = function DoNothing that gave me errors, so I just assumed that returns code also didnt work. But does it? |
