| 02-07-2004, 08:35 PM | #1 |
As many of you know you can override globals with locals with the same name. This sort of works like that only more confusing as to how it works. For some reason when you use two or more locals with global equivalants they seem to share the same content. How this is working I'd be pressed to tell because it makes no sense to me. But heres a test trigger you can try. Create two globals a timer named t, and an integer named i also in your custom script make sure to have h2i return bug exploiter so you can verify this is doing just that. Now use this trigger: Code:
text
Events
Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
Conditions
Actions
Custom script: local timer udg_t
Custom script: local integer udg_i
Custom script: set udg_t=CreateTimer()
Custom script: call BJDebugMsg(I2S(udg_i))
Custom script: call BJDebugMsg(I2S(h2i(udg_t)))
Custom script: call DestroyTimer(udg_t) |
| 02-08-2004, 04:15 PM | #2 |
Well I know why locals override globals in functions, but that other thing is just weird heh. I'm going out on a limb here and saying there's no override when a variable hasn't been initialized. Haven't tested this or anything though. |
| 02-10-2004, 08:53 AM | #3 |
There's a bug in your code: you forgot to initialize udg_i. As is always the case in any programming language when you use a uninitialized variable: the behavior is undefined. Meaning anything can happen. Including this. |
| 02-10-2004, 06:47 PM | #4 |
Jass will allow you to use unitialized variables (doesn't it?). when you use an unitialized boolean it defaults to false, an unitalized int to zero... |
| 02-10-2004, 08:40 PM | #5 |
In AI it will make a thread crash to use any uninitialized variables so I guess it is better to stay away from doing that in Trigger too. |
| 02-10-2004, 08:59 PM | #6 |
well beside for the ethics of using unitialized variables would any of you experts care to try and derive a return bug free tommorow (perferably a global free method) with this quirk? |
| 02-10-2004, 11:05 PM | #7 |
Yes, it's true, using uninitiated integer in any way (well, atleast in a f.ex. if condition) makes the thread quit :/, a annoying bug, i never create a local anymore without initiating it, just to be safe. Cubasis |
| 02-11-2004, 01:38 PM | #8 |
Variables created using the GUI are explicitely initialized by the script, maybe that's what weadder means... |
