Monday, 2024-05-20, 2:43 AM


Main
Registration
Login
Welcome Guest | RSS  
[ New messages · Members · Forum rules · Search · RSS ]
  • Page 3 of 3
  • «
  • 1
  • 2
  • 3
Forum moderator: JonNny, Hanky  
Clan NgO Forums » Discussions » Flood Dimension » Little problem.
Little problem.
TheCheeseLoverDate: Monday, 2009-08-03, 4:07 AM | Message # 31
Sergeant
Group: Users
Messages: 22
Reputation: 0
Status: Offline
2: It's really weird because I corrected the mistake and it worked... (The mistake wasn't about scope.)

Added (2009-07-20, 3:14 Pm)
---------------------------------------------
Sorry for the double post. I made the same indexing system as you to understand more how it works and I would like to know if it is ok. (I changed something)

Code
library thecheeselover
       // Thanks to Fireeye
           struct CheeseStruct
           // init var
           unit caster = null
           real CheeseTLeft = 0.00
               static method create takes nothing returns CheeseStruct
                   // set var
                   local CheeseStruct cs = CheeseStruct.allocate()
                   set cs.caster = null
                   set cs.CheeseTLeft = 0.00
                   return cs
               endmethod
                      
               method onDestroy takes nothing returns nothing
                   // end var
                   local CheeseStruct cs = CheeseStruct.allocate()
                   set cs.caster = null
                   set cs.CheeseTLeft = 0.00
               endmethod
           endstruct
                  
           globals
               private CheeseStruct array GlobalCheese
               private integer CStruct = 0
               private timer CheeseTimer = CreateTimer()
           endglobals
                  
           private function CheeseEnd takes nothing returns nothing
               local CheeseStruct cs
               local integer i = 0
               loop
                   exitwhen i == CStruct
                   set cs = GlobalCheese[i]
                   if cs.CheeseTLeft < 0.03 then
                       call cs.destroy()
                       set CStruct = CStruct - 1
                       set GlobalCheese[i] = GlobalCheese[CStruct]
                   else
                       set i = i - 1
                   endif
               endloop
           endfunction
                  
           function CheeseFunc takes nothing returns nothing
               local CheeseStruct cs = CheeseStruct.create()
               set GlobalCheese[CStruct] = cs
               set CStruct = CStruct + 1
               set cs.CheeseTLeft = 0.04
               if cs.CheeseTLeft < 0.03 then
                   call TimerStart( CheeseTimer, 0.03, TRUE, function CheeseEnd)
               endif
           endfunction
endlibrary

It is not a spell indexing system but a library indexing system. I have another question too: How can we use the same cs. if we use 2 functions for the spell.

Exemple:

Struct CheeseStruct
timer t = CreateTimer()
endstruct

function test takes nothing returns nothing
?????
call DestroyTimer(cs.t)
endfunction

function testinit takes nothing returns nothing
local CheeseStruct cs = CheeseStruct.create()
call TimerStart( cs.t, 2, TRUE, function test)
endfunction

Can you awnser me plz!

Added (2009-08-03, 4:07 Am)
---------------------------------------------
I have another questio. biggrin

What is the maximum array of a struct variable?


Yay I have a signature. You suck. :D

Message edited by TheCheeseLover - Tuesday, 2009-07-21, 6:20 PM
 
FireeyeDate: Monday, 2009-08-03, 7:50 PM | Message # 32
Private
Group: Moderators
Messages: 16
Reputation: 5
Status: Offline
What is the maximum array of a struct variable? The size of an array in JASS is 8192, this means the max slot you can access is 8191.
However due Blizzard is some bitch, the last slot is bugged. When you try save/load a map with an array slot of >= 8191 in use WC3 will crash.
This means the max slot you can safely use is 8190.




Message edited by Fireeye - Monday, 2009-08-03, 7:51 PM
 
TheCheeseLoverDate: Tuesday, 2009-08-04, 3:10 AM | Message # 33
Sergeant
Group: Users
Messages: 22
Reputation: 0
Status: Offline
Thanks. biggrin

Another question: do you know why i always get a mistake when I write a library Intializer Init?

exemple:

Code
library SelectionSystemThecheeselover Initializer Init

function Main takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_SelectionSystem takes nothing returns nothing
        set gg_trg_SelectionSystem = CreateTrigger(  )
        call TriggerRegisterTimerEventSingle( gg_trg_SelectionSystem, 0.02 )
        call TriggerAddAction( gg_trg_SelectionSystem, function Main )
endfunction

endlibrary

And Ive got a special question. biggrin What is this kind of variable? keyword


Yay I have a signature. You suck. :D

Message edited by TheCheeseLover - Tuesday, 2009-08-04, 3:58 AM
 
FireeyeDate: Tuesday, 2009-08-04, 8:52 PM | Message # 34
Private
Group: Moderators
Messages: 16
Reputation: 5
Status: Offline
1. When you write an Initializer, it's this syntax : "initializer <function name> and InitTrig_SelectionSystem is not equal to Init, just write Init and that error is fixed.
2. Let's say you declare a global struct array variable before the actual struct, it'll give you a syntax error, as you have to define the struct before it's actual usage. However you can bypass that problem, with 'keyword'. It acts as 'dummy', thus the compiler won't give any error.
You can also use private/public for the 'keyword'. Its syntax is:
<Visibility> keyword <Target Class>




Message edited by Fireeye - Tuesday, 2009-08-04, 8:52 PM
 
HankyDate: Friday, 2009-08-07, 10:36 AM | Message # 35
Lieutenant colonel
Group: Moderators
Messages: 116
Reputation: 9
Status: Offline
Also don't forget to write a "private" in front of the init function. Otherwise there will be problems if you got more than one library which use the "init" function as initializer.


Made by Smoe reworked by GiR aka Darkt3mpl3r
 
Clan NgO Forums » Discussions » Flood Dimension » Little problem.
  • Page 3 of 3
  • «
  • 1
  • 2
  • 3
Search:

Clan NgO © 2024Powered by uCoz