BuscarEntrar al ChatboxPortal del foroÍndiceSpellsRegistrarseConectarseGrupos de Usuarios
Eventos Actuales
¡ Bienvenido Invitado!

Editar Perfil

Tus temas
Tus Mensajes ()

Enlaces rápidos








Comparte | .
 

 necesito ayuda con LIBRARIES

Ver el tema anterior Ver el tema siguiente Ir abajo 
AutorMensaje
CYK
Capitán
avatar


Barra de Salud : Su salud está al 100% - Este usuario no ha recibido infracciones

Mensajes Mensajes : 149
Reputación Reputación : 30
Monedas de oro : 525
Monedas de Platino : 0

Inventario :



Mensaje(#) Tema: necesito ayuda con LIBRARIES Vie Mar 10, 2017 11:25 pm

necesito saber como hacer para hacer funcionar dos libraries que tengo  los dos se llaman "Table" uno lo uso para sistema de misiones... y otro para sistema de respawn pero como es obvio no puedo tenerlos dos libraries al mismo tiempo como podria hacer... para cambiar este...

Este es el Table para sistema de misiones.. no quisiera cambiarlo

[jass]library Table /* made by Bribe, special thanks to Vexorian & Nestharus, version 4.1.0.1.
   
   One map, one hashtable. Welcome to NewTable 4.1.0.1
   
   This newest iteration of Table introduces the new HashTable struct.
   You can now instantiate HashTables which enables the use of large
   parent and large child keys, just like a standard hashtable. Previously,
   the user would have to instantiate a Table to do this on their own which -
   while doable - is something the user should not have to do if I can add it
   to this resource myself (especially if they are inexperienced).
   
   This library was originally called NewTable so it didn't conflict with
   the API of Table by Vexorian. However, the damage is done and it's too
   late to change the library name now. To help with damage control, I
   have provided an extension library called TableBC, which bridges all
   the functionality of Vexorian's Table except for 2-D string arrays &
   the ".flush(integer)" method. I use ".flush()" to flush a child hash-
   table, because I wanted the API in NewTable to reflect the API of real
   hashtables (I thought this would be more intuitive).
   
   API
   
   ------------
   struct Table
   | static method create takes nothing returns Table
   |     create a new Table
   |    
   | method destroy takes nothing returns nothing
   |     destroy it
   |    
   | method flush takes nothing returns nothing
   |     flush all stored values inside of it
   |    
   | method remove takes integer key returns nothing
   |     remove the value at index "key"
   |    
   | method operator []= takes integer key, $TYPE$ value returns nothing
   |     assign "value" to index "key"
   |    
   | method operator [] takes integer key returns $TYPE$
   |     load the value at index "key"
   |    
   | method has takes integer key returns boolean
   |     whether or not the key was assigned
   |
   ----------------
   struct TableArray
   | static method operator [] takes integer array_size returns TableArray
   |     create a new array of Tables of size "array_size"
   |
   | method destroy takes nothing returns nothing
   |     destroy it
   |
   | method flush takes nothing returns nothing
   |     flush and destroy it
   |
   | method operator size takes nothing returns integer
   |     returns the size of the TableArray
   |
   | method operator [] takes integer key returns Table
   |     returns a Table accessible exclusively to index "key"
*/
   
globals
   private integer less = 0    //Index generation for TableArrays (below 0).
   private integer more = 8190 //Index generation for Tables.
   //Configure it if you use more than 8190 "key" variables in your map (this will never happen though).
   
   private hashtable ht = InitHashtable()
   private key sizeK
   private key listK
endglobals
   
private struct dex extends array
   static method operator size takes nothing returns Table
       return sizeK
   endmethod
   static method operator list takes nothing returns Table
       return listK
   endmethod
endstruct
   
private struct handles extends array
   method has takes integer key returns boolean
       return HaveSavedHandle(ht, this, key)
   endmethod
   method remove takes integer key returns nothing
       call RemoveSavedHandle(ht, this, key)
   endmethod
endstruct
   
private struct agents extends array
   method operator []= takes integer key, agent value returns nothing
       call SaveAgentHandle(ht, this, key, value)
   endmethod
endstruct
   
//! textmacro NEW_ARRAY_BASIC takes SUPER, FUNC, TYPE
private struct $TYPE$s extends array
   method operator [] takes integer key returns $TYPE$
       return Load$FUNC$(ht, this, key)
   endmethod
   method operator []= takes integer key, $TYPE$ value returns nothing
       call Save$FUNC$(ht, this, key, value)
   endmethod
   method has takes integer key returns boolean
       return HaveSaved$SUPER$(ht, this, key)
   endmethod
   method remove takes integer key returns nothing
       call RemoveSaved$SUPER$(ht, this, key)
   endmethod
endstruct
private module $TYPE$m
   method operator $TYPE$ takes nothing returns $TYPE$s
       return this
   endmethod
endmodule
//! endtextmacro
   
//! textmacro NEW_ARRAY takes FUNC, TYPE
private struct $TYPE$s extends array
   method operator [] takes integer key returns $TYPE$
       return Load$FUNC$Handle(ht, this, key)
   endmethod
   method operator []= takes integer key, $TYPE$ value returns nothing
       call Save$FUNC$Handle(ht, this, key, value)
   endmethod
   method has takes integer key returns boolean
       return HaveSavedHandle(ht, this, key)
   endmethod
   method remove takes integer key returns nothing
       call RemoveSavedHandle(ht, this, key)
   endmethod
endstruct
private module $TYPE$m
   method operator $TYPE$ takes nothing returns $TYPE$s
       return this
   endmethod
endmodule
//! endtextmacro
   
//Run these textmacros to include the entire hashtable API as wrappers.
//Don't be intimidated by the number of macros - Vexorian's map optimizer is
//supposed to kill functions which inline (all of these functions inline).
//! runtextmacro NEW_ARRAY_BASIC("Real", "Real", "real")
//! runtextmacro NEW_ARRAY_BASIC("Boolean", "Boolean", "boolean")
//! runtextmacro NEW_ARRAY_BASIC("String", "Str", "string")
//New textmacro to allow table.integer[] syntax for compatibility with textmacros that might desire it.
//! runtextmacro NEW_ARRAY_BASIC("Integer", "Integer", "integer")
   
//! runtextmacro NEW_ARRAY("Player", "player")
//! runtextmacro NEW_ARRAY("Widget", "widget")
//! runtextmacro NEW_ARRAY("Destructable", "destructable")
//! runtextmacro NEW_ARRAY("Item", "item")
//! runtextmacro NEW_ARRAY("Unit", "unit")
//! runtextmacro NEW_ARRAY("Ability", "ability")
//! runtextmacro NEW_ARRAY("Timer", "timer")
//! runtextmacro NEW_ARRAY("Trigger", "trigger")
//! runtextmacro NEW_ARRAY("TriggerCondition", "triggercondition")
//! runtextmacro NEW_ARRAY("TriggerAction", "triggeraction")
//! runtextmacro NEW_ARRAY("TriggerEvent", "event")
//! runtextmacro NEW_ARRAY("Force", "force")
//! runtextmacro NEW_ARRAY("Group", "group")
//! runtextmacro NEW_ARRAY("Location", "location")
//! runtextmacro NEW_ARRAY("Rect", "rect")
//! runtextmacro NEW_ARRAY("BooleanExpr", "boolexpr")
//! runtextmacro NEW_ARRAY("Sound", "sound")
//! runtextmacro NEW_ARRAY("Effect", "effect")
//! runtextmacro NEW_ARRAY("UnitPool", "unitpool")
//! runtextmacro NEW_ARRAY("ItemPool", "itempool")
//! runtextmacro NEW_ARRAY("Quest", "quest")
//! runtextmacro NEW_ARRAY("QuestItem", "questitem")
//! runtextmacro NEW_ARRAY("DefeatCondition", "defeatcondition")
//! runtextmacro NEW_ARRAY("TimerDialog", "timerdialog")
//! runtextmacro NEW_ARRAY("Leaderboard", "leaderboard")
//! runtextmacro NEW_ARRAY("Multiboard", "multiboard")
//! runtextmacro NEW_ARRAY("MultiboardItem", "multiboarditem")
//! runtextmacro NEW_ARRAY("Trackable", "trackable")
//! runtextmacro NEW_ARRAY("Dialog", "dialog")
//! runtextmacro NEW_ARRAY("Button", "button")
//! runtextmacro NEW_ARRAY("TextTag", "texttag")
//! runtextmacro NEW_ARRAY("Lightning", "lightning")
//! runtextmacro NEW_ARRAY("Image", "image")
//! runtextmacro NEW_ARRAY("Ubersplat", "ubersplat")
//! runtextmacro NEW_ARRAY("Region", "region")
//! runtextmacro NEW_ARRAY("FogState", "fogstate")
//! runtextmacro NEW_ARRAY("FogModifier", "fogmodifier")
//! runtextmacro NEW_ARRAY("Hashtable", "hashtable")
   
struct Table extends array
   
   // Implement modules for intuitive syntax (tb.handle; tb.unit; etc.)
   implement realm
   implement integerm
   implement booleanm
   implement stringm
   implement playerm
   implement widgetm
   implement destructablem
   implement itemm
   implement unitm
   implement abilitym
   implement timerm
   implement triggerm
   implement triggerconditionm
   implement triggeractionm
   implement eventm
   implement forcem
   implement groupm
   implement locationm
   implement rectm
   implement boolexprm
   implement soundm
   implement effectm
   implement unitpoolm
   implement itempoolm
   implement questm
   implement questitemm
   implement defeatconditionm
   implement timerdialogm
   implement leaderboardm
   implement multiboardm
   implement multiboarditemm
   implement trackablem
   implement dialogm
   implement buttonm
   implement texttagm
   implement lightningm
   implement imagem
   implement ubersplatm
   implement regionm
   implement fogstatem
   implement fogmodifierm
   implement hashtablem
   
   method operator handle takes nothing returns handles
       return this
   endmethod
   
   method operator agent takes nothing returns agents
       return this
   endmethod
   
   //set this = tb[GetSpellAbilityId()]
   method operator [] takes integer key returns Table
       return LoadInteger(ht, this, key) //return this.integer[key]
   endmethod
   
   //set tb[389034] = 8192
   method operator []= takes integer key, Table tb returns nothing
       call SaveInteger(ht, this, key, tb) //set this.integer[key] = tb
   endmethod
   
   //set b = tb.has(2493223)
   method has takes integer key returns boolean
       return HaveSavedInteger(ht, this, key) //return this.integer.has(key)
   endmethod
   
   //call tb.remove(294080)
   method remove takes integer key returns nothing
       call RemoveSavedInteger(ht, this, key) //call this.integer.remove(key)
   endmethod
   
   //Remove all data from a Table instance
   method flush takes nothing returns nothing
       call FlushChildHashtable(ht, this)
   endmethod
   
   //local Table tb = Table.create()
   static method create takes nothing returns Table
       local Table this = dex.list[0]
       
       if this == 0 then
           set this = more + 1
           set more = this
       else
           set dex.list[0] = dex.list[this]
           call dex.list.remove(this) //Clear hashed memory
       endif
       
       debug set dex.list[this] = -1
       return this
   endmethod
   
   // Removes all data from a Table instance and recycles its index.
   //
   //     call tb.destroy()
   //
   method destroy takes nothing returns nothing
       debug if dex.list[this] != -1 then
           debug call BJDebugMsg("Table Error: Tried to double-free instance: " + I2S(this))
           debug return
       debug endif
       
       call this.flush()
       
       set dex.list[this] = dex.list[0]
       set dex.list[0] = this
   endmethod
   
   //! runtextmacro optional TABLE_BC_METHODS()
endstruct
   
//! runtextmacro optional TABLE_BC_STRUCTS()
   
struct TableArray extends array
   
   //Returns a new TableArray to do your bidding. Simply use:
   //
   //    local TableArray ta = TableArray[array_size]
   //
   static method operator [] takes integer array_size returns TableArray
       local Table tb = dex.size[array_size] //Get the unique recycle list for this array size
       local TableArray this = tb[0]         //The last-destroyed TableArray that had this array size
       
       debug if array_size <= 0 then
           debug call BJDebugMsg("TypeError: Invalid specified TableArray size: " + I2S(array_size))
           debug return 0
       debug endif
       
       if this == 0 then
           set this = less - array_size
           set less = this
       else
           set tb[0] = tb[this]  //Set the last destroyed to the last-last destroyed
           call tb.remove(this)  //Clear hashed memory
       endif
       
       set dex.size[this] = array_size //This remembers the array size
       return this
   endmethod
   
   //Returns the size of the TableArray
   method operator size takes nothing returns integer
       return dex.size[this]
   endmethod
   
   //This magic method enables two-dimensional[array][syntax] for Tables,
   //similar to the two-dimensional utility provided by hashtables them-
   //selves.
   //
   //ta[integer a].unit[integer b] = unit u
   //ta[integer a][integer c] = integer d
   //
   //Inline-friendly when not running in debug mode
   //
   method operator [] takes integer key returns Table
       static if DEBUG_MODE then
           local integer i = this.size
           if i == 0 then
               call BJDebugMsg("IndexError: Tried to get key from invalid TableArray instance: " + I2S(this))
               return 0
           elseif key < 0 or key >= i then
               call BJDebugMsg("IndexError: Tried to get key [" + I2S(key) + "] from outside TableArray bounds: " + I2S(i))
               return 0
           endif
       endif
       return this + key
   endmethod
   
   //Destroys a TableArray without flushing it; I assume you call .flush()
   //if you want it flushed too. This is a public method so that you don't
   //have to loop through all TableArray indices to flush them if you don't
   //need to (ie. if you were flushing all child-keys as you used them).
   //
   method destroy takes nothing returns nothing
       local Table tb = dex.size[this.size]
       
       debug if this.size == 0 then
           debug call BJDebugMsg("TypeError: Tried to destroy an invalid TableArray: " + I2S(this))
           debug return
       debug endif
       
       if tb == 0 then
           //Create a Table to index recycled instances with their array size
           set tb = Table.create()
           set dex.size[this.size] = tb
       endif
       
       call dex.size.remove(this) //Clear the array size from hash memory
       
       set tb[this] = tb[0]
       set tb[0] = this
   endmethod
   
   private static Table tempTable
   private static integer tempEnd
   
   //Avoids hitting the op limit
   private static method clean takes nothing returns nothing
       local Table tb = .tempTable
       local integer end = tb + 0x1000
       if end < .tempEnd then
           set .tempTable = end
           call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
       else
           set end = .tempEnd
       endif
       loop
           call tb.flush()
           set tb = tb + 1
           exitwhen tb == end
       endloop
   endmethod
   
   //Flushes the TableArray and also destroys it. Doesn't get any more
   //similar to the FlushParentHashtable native than this.
   //
   method flush takes nothing returns nothing
       debug if this.size == 0 then
           debug call BJDebugMsg("TypeError: Tried to flush an invalid TableArray instance: " + I2S(this))
           debug return
       debug endif
       set .tempTable = this
       set .tempEnd = this + this.size
       call ForForce(bj_FORCE_PLAYER[0], function thistype.clean)
       call this.destroy()
   endmethod
   
endstruct
   
//NEW: Added in Table 4.0. A fairly simple struct but allows you to do more
//than that which was previously possible.
struct HashTable extends array

   //Enables myHash[parentKey][childKey] syntax.
   //Basically, it creates a Table in the place of the parent key if
   //it didn't already get created earlier.
   method operator [] takes integer index returns Table
       local Table t = Table(this)[index]
       if t == 0 then
           set t = Table.create()
           set Table(this)[index] = t //whoops! Forgot that line. I'm out of practice!
       endif
       return t
   endmethod

   //You need to call this on each parent key that you used if you
   //intend to destroy the HashTable or simply no longer need that key.
   method remove takes integer index returns nothing
       local Table t = Table(this)[index]
       if t != 0 then
           call t.destroy()
           call Table(this).remove(index)
       endif
   endmethod
   
   //Added in version 4.1
   method has takes integer index returns boolean
       return Table(this).has(index)
   endmethod
   
   //HashTables are just fancy Table indices.
   method destroy takes nothing returns nothing
       call Table(this).destroy()
   endmethod
   
   //Like I said above...
   static method create takes nothing returns thistype
       return Table.create()
   endmethod

endstruct

endlibrary[/jass]


este es el table que usa el sistema de respawn

[jass]//TESH.scrollpos=63
http://TESH.alwaysfold=0
library Table
//***************************************************************
//* Table object 3.0
//* ------------
//*
//*   set t=Table.create() - instanceates a new table object
//*   call t.destroy()     - destroys it
//*   t[1234567]           - Get value for key 1234567
//*                          (zero if not assigned previously)
//*   set t[12341]=32      - Assigning it.
//*   call t.flush(12341)  - Flushes the stored value, so it
//*                          doesn't use any more memory
//*   t.exists(32)         - Was key 32 assigned? Notice
//*                          that flush() unassigns values.
//*   call t.reset()       - Flushes the whole contents of the
//*                          Table.
//*
//*   call t.destroy()     - Does reset() and also recycles the id.
//*
//*   If you use HandleTable instead of Table, it is the same
//* but it uses handles as keys, the same with StringTable.
//*
//*  You can use Table on structs' onInit  if the struct is
//* placed in a library that requires Table or outside a library.
//*
//*  You can also do 2D array syntax if you want to touch
//* mission keys directly, however, since this is shared space
//* you may want to prefix your mission keys accordingly:
//*
//*  set Table["thisstring"][ 7 ] = 2
//*  set Table["thisstring"][ 5 ] = Table["thisstring"][7]
//*
//***************************************************************

//=============================================================
   globals
       private constant integer MAX_INSTANCES=20000 //400000
       //Feel free to change max instances if necessary, it will only affect allocation
       //speed which shouldn't matter that much.

   //=========================================================
       private hashtable ht
   endglobals

   private struct GTable[MAX_INSTANCES]

       method reset takes nothing returns nothing
           call FlushChildHashtable(ht, integer(this) )
       endmethod

       private method onDestroy takes nothing returns nothing
           call this.reset()
       endmethod

       //=============================================================
       // initialize it all.
       //
       private static method onInit takes nothing returns nothing
           set ht = InitHashtable()
       endmethod

   endstruct

   //Hey: Don't instanciate other people's textmacros that you are not supposed to, thanks.
   //! textmacro Table__make takes name, type, key
   struct $name$ extends GTable

       method operator [] takes $type$ key returns integer
           return LoadInteger(ht, integer(this), $key$)
       endmethod

       method operator []= takes $type$ key, integer value returns nothing
           call SaveInteger(ht,  integer(this)  ,$key$, value)
       endmethod

       method flush takes $type$ key returns nothing
           call RemoveSavedInteger(ht, integer(this), $key$)
       endmethod

       method exists takes $type$ key returns boolean
           return HaveSavedInteger( ht,  integer(this)  ,$key$)
       endmethod

       static method flush2D takes string firstkey returns nothing
           call $name$(- StringHash(firstkey)).reset()
       endmethod

       static method operator [] takes string firstkey returns $name$
           return $name$(- StringHash(firstkey) )
       endmethod

   endstruct
   //! endtextmacro

   //! runtextmacro Table__make("Table","integer","key" )
   //! runtextmacro Table__make("StringTable","string", "StringHash(key)" )
   //! runtextmacro Table__make("HandleTable","handle","GetHandleId(key)" )

endlibrary[/jass]

y este es el sistema de respawn

[jass]//TESH.scrollpos=23
http://TESH.alwaysfold=0
library Respawn requires Table, TimerUtils

private struct UnitData
   private static HandleTable unit2data
   
   readonly real x
   readonly real y
   readonly real angle
   readonly integer type
   public unit u
   
   private static method onRespawnFinish takes nothing returns nothing
       local timer t = GetExpiredTimer()
       local UnitData data = GetTimerData(t)
       call SetUnitInvulnerable(data.u, false)
       call PauseUnit(data.u, false)
       call ReleaseTimer(t)
   endmethod
   
   private static method onRespawn takes nothing returns nothing
       local timer t = GetExpiredTimer()
       local UnitData data = GetTimerData(t)
       call unit2data.flush(data.u)
       set data.u = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), data.type, data.x, data.y, data.angle)
       call SetUnitInvulnerable(data.u, true)
       call PauseUnit(data.u, true)
       set unit2data[data.u] = data
       call TimerStart(t, 1, false, function UnitData.onRespawnFinish)
   endmethod
   
   private static method onDeath takes nothing returns nothing
       local timer t = NewTimer()
       local UnitData data = unit2data[GetTriggerUnit()]
       call SetTimerData(t, data)
       call TimerStart(t, 35, false, function UnitData.onRespawn)
   endmethod
   
   private static method onInitUnit takes nothing returns nothing
       if (GetOwningPlayer(GetEnumUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE)) then
           call UnitData.create(GetEnumUnit())
       endif
   endmethod
   
   private static method onInit takes nothing returns nothing
       local trigger t = CreateTrigger()
       local group g = NewGroup()
       
       set unit2data = HandleTable.create()
       call TriggerRegisterPlayerUnitEvent(t, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH, null)
       call TriggerAddAction(t, function UnitData.onDeath)
       
       call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null)
       call ForGroup(g, function UnitData.onInitUnit)
   endmethod
   
   public static method create takes unit u returns UnitData
       local UnitData this = UnitData.allocate()
       set this.x = GetUnitX(u)
       set this.y = GetUnitY(u)
       set this.angle = GetUnitFacing(u)
       set this.type = GetUnitTypeId(u)
       set unit2data[u] = this
       return this
   endmethod
   
endstruct

endlibrary[/jass]

Como podria hacer para que el sistema de respawn use el table sera cambiandole el nombre o como se podria hacer.. gracias de ante mano


sheshom Mapa en Progreso: 1HISTORIA V 1.1 ogrogafas  Ayudenme a testearlo ogredude

Volver arriba Ir abajo
Marcos_M

avatar


Barra de Salud : Su salud está al 100% - Este usuario no ha recibido infracciones

Mensajes Mensajes : 2714
Reputación Reputación : 416
Monedas de oro : 8318
Monedas de Platino : 0

Inventario :



Mensaje(#) Tema: Re: necesito ayuda con LIBRARIES Sáb Mar 11, 2017 12:32 am

Deberías usar Table 4.1 ya que es más nuevo, mucho más nuevo.

Pero no sé si la API está cambiada.

Aunque tener dos librerías con la misma utilidad es un exceso. Puedes renombrar las librerías fácilmente.
Si miras el código, dice "library" seguido del nombre de la librería
Y si miras el sistema que utiliza esta librería dice "requires" seguido del nombre de la librería que usa

La solución que requiere menos pensamiento, es renombrar una de tus dos "Table"
Volver arriba Ir abajo
CYK
Capitán
avatar


Barra de Salud : Su salud está al 100% - Este usuario no ha recibido infracciones

Mensajes Mensajes : 149
Reputación Reputación : 30
Monedas de oro : 525
Monedas de Platino : 0

Inventario :



Mensaje(#) Tema: Re: necesito ayuda con LIBRARIES Sáb Mar 11, 2017 11:34 am

si ya lo hice pero.. prove la 4.1 de y no me funciona el deto de respawn... pero ya le cambie los nombres y bno funcionaba era por q el table usa text macro... hay q cambiarlo tambien y listo.. ya funciona


sheshom Mapa en Progreso: 1HISTORIA V 1.1 ogrogafas  Ayudenme a testearlo ogredude

Volver arriba Ir abajo
Trigger.edge

avatar


Barra de Salud : Este usuario es invulnerable ¿Será que es fiel a las normas?

Mensajes Mensajes : 977
Reputación Reputación : 106
Monedas de oro : 1239
Monedas de Platino : 0

Inventario :
Cetro del Rey Armadura Mágica Daga Mística


Mensaje(#) Tema: Re: necesito ayuda con LIBRARIES Dom Mar 12, 2017 9:39 am

Solo debes reeplazar la libreria Tble de vexorian por esta
[jass]library TableBC requires Table
/*
   Backwards-compatibility add-on for scripts employing Vexorian's Table.

   Added 31 July 2015: introduced static method operator [] and
   static method flush2D for Table, HandleTable and StringTable. Now,
   almost all of the Vexorian API has been replicated (minus the .flush paradox).

   The Table library itself was unchanged to implement these
   enhancements, so you need only update this library to experience the
   improved syntax compatibility.
   
   Disclaimer:
   
   The following error does not occur with HandleTables & StringTables, only
   with the standard, integer-based Table, so you do not need to make any
   changes to StringTable/HandleTable-employing scripts.
   
   The this.flush(key) method from the original Table cannot be parsed with
   the new Table. For the scripts that use this method, they need to be up-
   dated to use the more fitting this.remove(key) method.
   
   Please don't try using StringTables/HandleTables with features exclusive
   to the new Table as they will cause syntax errors. I do not have any plan
   to endorse these types of Tables because delegation in JassHelper is not
   advanced enough for three types of Tables without copying every single
   method over again (as you can see this already generates plenty of code).
   StringTable & HandleTable are wrappers for StringHash & GetHandleId, so
   just type them out.
*/

//! textmacro TABLE_BC_METHODS
   method reset takes nothing returns nothing
       call this.flush()
   endmethod
   method exists takes integer key returns boolean
       return this.has(key)
   endmethod
   static method operator [] takes string id returns Table
       local integer index = StringHash(id)
       local Table t = Table(thistype.typeid)[index]
       if t == 0 then
           set t = Table.create()
           set Table(thistype.typeid)[index] = t
       endif
       return t
   endmethod
   static method flush2D takes string id returns nothing
       local integer index = StringHash(id)
       local Table t = Table(thistype.typeid)[index]
       if t != 0 then
           call t.destroy()
           call Table(thistype.typeid).remove(index)
       endif
   endmethod
//! endtextmacro

//! textmacro TABLE_BC_STRUCTS
struct HandleTable extends array
   static method operator [] takes string index returns thistype
       return Table[index]
   endmethod
   static method flush2D takes string index returns nothing
       call Table.flush2D(index)
   endmethod
   method operator [] takes handle key returns integer
       return Table(this)[GetHandleId(key)]
   endmethod
   method operator []= takes handle key, integer value returns nothing
       set Table(this)[GetHandleId(key)] = value
   endmethod
   method flush takes handle key returns nothing
       call Table(this).remove(GetHandleId(key))
   endmethod
   method exists takes handle key returns boolean
       return Table(this).has(GetHandleId(key))
   endmethod
   method reset takes nothing returns nothing
       call Table(this).flush()
   endmethod
   method destroy takes nothing returns nothing
       call Table(this).destroy()
   endmethod
   static method create takes nothing returns thistype
       return Table.create()
   endmethod
endstruct

struct StringTable extends array
   static method operator [] takes string index returns thistype
       return Table[index]
   endmethod
   static method flush2D takes string index returns nothing
       call Table.flush2D(index)
   endmethod
   method operator [] takes string key returns integer
       return Table(this)[StringHash(key)]
   endmethod
   method operator []= takes string key, integer value returns nothing
       set Table(this)[StringHash(key)] = value
   endmethod
   method flush takes string key returns nothing
       call Table(this).remove(StringHash(key))
   endmethod
   method exists takes string key returns boolean
       return Table(this).has(StringHash(key))
   endmethod
   method reset takes nothing returns nothing
       call Table(this).flush()
   endmethod
   method destroy takes nothing returns nothing
       call Table(this).destroy()
   endmethod
   static method create takes nothing returns thistype
       return Table.create()
   endmethod
endstruct
//! endtextmacro

endlibrary[/jass]

De este modo proporcionas compatibilidad para ambas versiones de table, lo puedes leer aqui https://www.hiveworkshop.com/threads/snippet-new-table.188084/
Wink


Volver arriba Ir abajo
Contenido patrocinado




Mensaje(#) Tema: Re: necesito ayuda con LIBRARIES

Volver arriba Ir abajo
 

necesito ayuda con LIBRARIES

Ver el tema anterior Ver el tema siguiente Volver arriba 
Página 1 de 1.

 Temas similares

-
» [Resuelto]necesito ayuda
» necesito ayuda con LIBRARIES
» NECESITO AYUDA EN METAL GEAR SOLID 2 HD COLLECTION
» Ayuda, necesito opiniones, mi novio me dejo y quiero buscarlo :'(
» Necesito ayuda con cooperativo del Far Cry 3

Permisos de este foro:No puedes responder a temas en este foro.
Warcraft III - WorldEditor :: Zona de Aprendizaje(Dudas) :: Jass (Detonadores)-