Discussion Aesthetically beautiful structs in structs

Nestharus

o-o
Reaction score
84
Been playing with aesthetics and what not

JASS:
scope Test
    public struct Hi extends array
        public method say takes nothing returns nothing
            call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, "Hi " + GetPlayerName(GetLocalPlayer()))
        endmethod
    endstruct

    struct Message extends array
        public method operator Hi takes nothing returns Hi
            return this
        endmethod

        public method say takes string s returns nothing
            call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, s + " " + GetPlayerName(GetLocalPlayer()))
        endmethod
    endstruct
endscope

struct Tester extends array
    local Message message = Message.create()
    call message.say("boo")
    call message.Hi.say()
endstruct


Makes it look like you did this
JASS:
struct Message extends array
    public struct Hi extends array
    endstruct
endstruct


^_^

I would make the Hi struct private, but doing that makes it so Hi can't be used, even through the Message struct : |.
 

SanKakU

Member
Reaction score
21
were you asking a question or what? anyway, i do not understand much about structs or your code.
 

tooltiperror

Super Moderator
Reaction score
231
I love the concept of struct programming.

JASS:
//firefox JASS
 struct Human
     method say takes string str returns nothing
        call BJDebugMsg(str)
     endmethod
 endstruct

 function onInit takes nothing returns nothing
    local Human Kenneth=Human.create()
    call Kenneth.say("The end of the world.")
 endfunction


Edit: Hell, I love structs so much you could create an entire custom language with them.

[ljass]//======[/ljass]

Step one: Create Methods and Destroy Methods.

JASS:
//firefox JASS
  struct Unit
     unit unit
       static method create takes x, y, type returns thistype
         //blablabla createunit(x,y,thistype,Player(0))
       endmethod
  endstruct

  function onInit takes nothing returns nothing
     local Unit Footman=Unit.create(x,y,'hfoo')
  endfunction
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
library ThreeDArray
    
    struct ThirdArray
        method operator [] takes integer index returns integer
            return index
        endmethod 
        method operator []= takes integer index, integer data returns nothing
        endmethod
    endstruct
    
    struct SecondArray
        method operator [] takes integer index returns ThirdArray
            return index
        endmethod
    endstruct
    
    struct ThreeDArray
        static method operator [] takes integer index returns SecondArray
            return index
        endmethod
    endstruct
    
endlibrary

3d array. :D

JASS:
function test takes nothing returns nothing
    set ThreeDArray[1][1][1] = 2
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top