• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[vJASS] Question about structs

Status
Not open for further replies.
Level 11
Joined
Sep 12, 2008
Messages
657
Hi, i was wonder if its possible to do this:
JASS:
struct strExtension
      string data = ""
      public method operator = takes string data returns nothing
            set .data = data
            //Here lies the problem btw, theres no method operator =
      endmethod
      public method operator == takes strExtension s returns boolean
            return .data == s.data
      endmethod
endstruct

library X initializer onInit
      private function onInit takes nothing returns nothing
            local strExtension s = "Hello"
            if s == "Hello" then
                  //Actions #1
            else
                  //Actions #2
            endif
      endfunction
endlibrary
so basicly, the struct gives you the value in the variable called data, instead of the integer.
is it possible?
Sorry if you dont understand, i'm bad at explaining things..

Thanks in advance..
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
539
Nope, only possible with integers like ARGB.

That's possible because structs are implemented as integer. I mean you could do some hacks
with StringHash but you would still need an explicit constructor.
Then better use a regular struct with an regular constructor.
 
Status
Not open for further replies.
Top