Chaosy
Tutorial Reviewer
- Joined
- Jun 9, 2011
- Messages
- 13,183
Pred if you google that error it says that you have to remove a few lines from the wehack.lua
I have done that a few times in the past.
I have done that a few times in the past.
function foo returns nothing
endfunction
function bar takes integer i
endfunction
function baz
endfunction
struct DoublyLinkedListTest
static method onInit
local List.Doubly dll = List.Doubly.allocate()
local Object a = Object.allocate()
local Object b = Object.allocate()
local Object c = Object.allocate()
local Object d = Object.allocate()
call dll.insert(a)
call Assert.instance(dll.getHead(), a, 11)
call Assert.instance(dll.getLast(), a, 12)
local List.Iterator it = dll.createIterator()
call Assert.toBeTrue(it.hasNext(), 16)
call Assert.instance(a, it.getNext(), 17)
call Assert.toBeFalse(it.hasNext(), 18)
call dll.insert(b)
call dll.insert(c)
set it = dll.createIterator()
call Assert.instance(it.getNext(), a, 25)
call Assert.instance(it.getNext(), b, 26)
call Assert.instance(it.getNext(), c, 27)
endmethod
endstruct
local integer ahffhfh32 = 1
loop
set ahffhfh32 = 2
call DisplayTimedTestToPlayer(GetLocalPlayer(), 0, 0, 60, "meh")
set ahffhfh32 = 4
exitwhen true
endloop
call Assert.create("DoublyLinkedList").onLine(11).toBeInstance(dll.getHead(), b)
call assert("...").onLine(...).toBeInstance(...)
set i = 0
loop
exitwhen i > 10
if i == 5 then
continue
endif
call BJDebugMsg("value of i : " + I2S(i))
set i = i + 1
endloop
set i = 0
loop
exitwhen i > 10
if not (i == 5) then
call BJDebugMsg("value of i : " + I2S(i))
endif
set i = i + 1
endloop
set i = 0
loop
exitwhen i > 10
if (i == 5) then
else
call BJDebugMsg("value of i : " + I2S(i))
endif
set i = i + 1
endloop
define
, but since cjass does a pretty good job on them I've decided to delegate to it.struct Object
static integer instances
public static method allocate takes nothing returns Object
set Object.instances += 1
return Object.instances cast Object
endmethod
public method equals takes Object e returns boolean
return this == e
endmethod
public method isNull returns boolean
return this == null
endmethod
public method toString returns string
return I2S(this cast integer)
endmethod
endstruct
interface Collection
public method contains takes Object e returns boolean
public method createIterator returns List.Iterator
endinterface
struct Array extends Object implements Collection
integer size
Object array elements
integer array indexes
List.Doubly list
public method get takes integer index returns Object
return this.elements[index]
endmethod
public method add takes integer index, Object e
set this.size += 1
set this.elements[index] = e
set this.indexes[e] = index
call this.list.insert(e)
endmethod
public method remove takes Object e returns nothing
if (this.getSize() == 0) then
return
endif
local integer index = this.indexOf(e)
if (index == -1) then
return
endif
set this.size -= 1
set this.elements[index] = null
set this.indexes[e] = -1
call this.list.remove(e)
endmethod
public method contains takes Object e returns boolean
return this.indexOf(e) != -1
endmethod
public method getSize takes nothing returns integer
return this.size
endmethod
public method createIterator returns List.Iterator
return this.list.createIterator()
endmethod
public method indexOf takes Object e returns integer
local integer index = this.indexes[e]
if (this.elements[index].equals(e)) then
return index
endif
return -1
endmethod
public static method create returns Array
local Array instance = Array.allocate()
set instance.list = List.Doubly.allocate()
return instance
endmethod
endstruct
struct Stack extends Object implements Collection
Array elements
public method push takes Object e
call this.elements.add(this.elements.getSize(), e)
endmethod
public method peek returns Object
return this.elements.get(this.elements.getSize()-1)
endmethod
public method pop returns Object
local Object e = this.peek()
call this.elements.remove(e)
return e
endmethod
public method contains takes Object e returns boolean
return this.elements.contains(e)
endmethod
public method createIterator returns List.Iterator
return this.elements.createIterator()
endmethod
endstruct
struct Queue extends Object implements Collection
List.Doubly elements
public method enqueue takes Object e
call this.elements.insert(e)
endmethod
public method dequeue returns Object
local Object e = this.elements.getHead()
call this.elements.remove(e)
return e
endmethod
public method contains takes Object e returns boolean
return this.elements.contains(e)
endmethod
public method createIterator returns List.Iterator
return this.elements.createIterator()
endmethod
public static method create returns Queue
local Queue instance = Queue.allocate()
set instance.elements = List.Doubly.create()
return instance
endmethod
endstruct
library List
struct Node extends Object
Object element
Node prev
Node next
public method destroy
set this.prev.next = this.next
set this.next.prev = this.prev
endmethod
public method getElement returns Object
return this.element
endmethod
public method getPrev returns Node
return this.prev
endmethod
public method getNext returns Node
return this.next
endmethod
public static method create takes Node prev, Object element, Node next returns Node
local Node new = Node.allocate()
set new.element = element
if (prev.isNull()) then
set prev = new
endif
if (next.isNull()) then
set next = new
endif
set new.prev = prev
set new.next = next
set prev.next = new
set next.prev = new
return new
endmethod
endstruct
public struct Doubly extends Object implements Collection
Node master
Node array nodes
public method createIterator returns Iterator
return Iterator.create(this.master)
endmethod
public method getHead returns Object
return this.master.getNext().getElement()
endmethod
public method getLast returns Object
return this.master.getPrev().getElement()
endmethod
public method insertBefore takes Object before, Object e
local Node beforeNode = this.nodes[before]
if (beforeNode.isNull()) then
set beforeNode = this.master
endif
set this.nodes[e] = Node.create(beforeNode.getPrev(), e, beforeNode)
endmethod
public method insertAfter takes Object node, Object e
call this.insertBefore(this.nodes[node].getNext().getElement(), e)
endmethod
public method insert takes Object e
call this.insertAfter(this.master.getPrev().getElement(), e)
endmethod
public method remove takes Object e
call this.nodes[e].destroy()
endmethod
public method contains takes Object e returns boolean
return this.nodes[e].isNull() == false
endmethod
public static method create returns Doubly
local Doubly instance = Doubly.allocate()
set instance.master = Node.create(null, null, null)
return instance
endmethod
endstruct
public struct Iterator extends Object
Node head
Node node
public method reset
set this.node = this.head
endmethod
public method hasNext returns boolean
return this.node.equals(this.head)
endmethod
public method getNext returns Object
set this.node = this.node.getNext()
return this.node.getElement()
endmethod
public static method create takes Node node returns Iterator
local Iterator it = Iterator.allocate()
set it.head = node
set it.node = node
return it
endmethod
endstruct
endlibrary
function interface_method takes Object this, ... returns ...
if (this._type == 1) then // A
call interface_method_of_a(this, ...)
elseif (this._type == 2) then // B
call interface_method_of_b(this, ...)
elseif (this._type == 3) then //C
call interface_method_of_b(this, ...)
endif
IntegerTertiaryOp
),Hi pp, I would like to implement the continue statement for loops but I don't have a clue of how the translation (raw jass) could look like, can you help me? thanks.
local integer i
set i = 1
loop
exitwhen i > 9
if i == 3 then
continue
endif
if i == 5 then
continue
endif
call BJDebugMsg(I2S(i))
set i = i + 1
endloop
local integer i
local boolean continue
set i = 1 - 1
loop
set continue = false
loop
set i = i + 1
exitwhen i > 9
if i == 3 then
set continue = true
exitwhen true
endif
if i == 5 then
set continue = true
exitwhen true
endif
call BJDebugMsg(I2S(i))
endloop
exitwhen not continue
endloop
call TimerStart(CreateTimer(), 2, true, function
call BJDebugMsg("yay!")
endfunction)
local code foo = function
call BJDebugMsg("i work too!")
endfunction
call TimerStart(CreateTimer(), 3, true, foo)
struct foo
public method hi
call BJDebugMsg("hi from foo")
endmethod
endstruct
struct bar extends foo
public method hi
call BJDebugMsg("hi from bar")
endmethod
endstruct
local foo instance = bar.create()
call instance.hi() // will display hi from foo, it should be bar
("a" + 1) + 2
which would give something like "cannot convert from string to integer" and then "cannot convert from null to integer", or something like that.that error is not unrecoverable tho, you just skip that statement and go to the next one
Even then, they are still a nuisance because of the name mangling.I have to save many many times until finally pjass is called which lists more than one error.
//! import <you can write anything here> "TimerUtils.j" <here too>
and library A uses B C D E F G
(no commas).interface foo
public method hi
endinterface
struct a implements foo
public method hi
call BJDebugMsg("Hi from A")
endmethod
endstruct
struct b extends a
public method hi
call BJDebugMsg("Hi from B")
endmethod
endstruct
local foo instance = b.allocate()
call instance.hi() // prints Hi from B
call (instance cast a).hi() // prints Hi from A
abstract struct foo
public method mustBeImplemented
public static method onInit
call BJDebugMsg("foo rulz, and i force any child class to implement my method >:3")
end
end
struct bar extends foo
public method mustBeImplemented
end
public static method onInit
call BJDebugMsg("that foo bastard")
end
end