• 🏆 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!

[JASS] vJass "anystruct" type

Status
Not open for further replies.

crl

crl

Level 7
Joined
Mar 29, 2008
Messages
117
Hi! In vJass, i need a type like "Object" in java. A type which every other type (or at least struct) extend. I know i could use integer, but i need the .typeid value. I dont wanna mess with some vJass internal variable names (because they look silly, and it might not be forward compatible, breaking vJass's backwards compatibility). Well 'nuff said. Does anybody know something like that?
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Type ID is given to every struct.

JASS:
struct Object
endstruct

This would have a .typeid value. In this, you could reference the ID of Object by referencing the integer Object.typeid.
 
  • Like
Reactions: crl

crl

crl

Level 7
Joined
Mar 29, 2008
Messages
117
Well, as you probably know, some systems are pretty advanced (not interface, but internals) So i dont think people will edit the complicated internals of another system, just to use my system. My system will ofcourse probably be useful, but not the most useful one. Therefore, it would be less useful if the users have to find out the internals of another system.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
crl said:
So i dont think people will edit the complicated internals of another system,

I have no idea what you're trying to do or what you're doing it for. You haven't given me any specific information about why you are trying to do this, or what you're going to be using it for. If you aren't going to give me any real information regarding your problem then I cannot help you.

What is your system, and why does it need this? I am not even sure what you mean with compatible with all structs as you said before, please answer my questions or there's nothing I can do for you.
 

crl

crl

Level 7
Joined
Mar 29, 2008
Messages
117
Well, im trying to make some functions that mimics the "synchronized" keyword in java. It tells the program that it uses an object. No code can execute when it reaches a synchronized statement, until the other thread meets an end-synchronized statement.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Synchronization has to do with thread execution.

In WarCraft III you can only have one thread in execution at any time, so it's almost as if every function/method included in JASS is a synchronized function/method.
 

crl

crl

Level 7
Joined
Mar 29, 2008
Messages
117
Well, this system should allow people to use waits inside of the synchronized statement. I might just use the parent type solution, but you should be pretty stupid to not see that one. I thought of it, but libraries only exist for making it easier for people. But +rep to berbanog.

EDIT: JUST FOUND OUT I NEEDED THE .getType()
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
I'm pretty sure that .typeid works on a static level as well as on instances. This means that in this situation:

JASS:
local StructName dat = StructName.create()

if(dat.typeid == StructName.typeid) then
    //this will execute 100% of the time.
endif

I just tested. This is true.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
JASS:
scope DebugTest initializer init

struct A
endstruct
struct B extends A
endstruct
struct C
endstruct

public function init takes nothing returns nothing
    call BJDebugMsg(I2S(A.typeid))
    call BJDebugMsg(I2S(B.typeid))
    call BJDebugMsg(I2S(C.typeid))
endfunction
endscope

This prints the following game messages:
1
2
3

So even though B is an extension of A it still has a unique type ID.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Ah, yes. Indeed. I thought he was talking strictly about static reference. I had a pretty hard time following what the thread-author meant.

crl said:
well, lets say that you have to strucrs, A and B. B extends A. When you have a variable of type A (lets call it aa) then .typeid would return the typeid for A, while getType would give the type of the contents.

I don't know how I misinterpreted this.
 
Level 13
Joined
May 11, 2008
Messages
1,198
Well, as you probably know, some systems are pretty advanced (not interface, but internals) So i dont think people will edit the complicated internals of another system, just to use my system. My system will ofcourse probably be useful, but not the most useful one. Therefore, it would be less useful if the users have to find out the internals of another system.

that might be true, but if it's a system with customization that's good. and if there's nothing to edit in the system and there's junk for demonstration, that's really annoying to deal with. what's the point of having a system that can do whatever you want and you don't need to modify a thing if you have no idea where to begin with using it, eh? haha, i've seen that before. although oftentimes it's about waiting for the submitter to get around to finishing an example.

edit: finished reading up to my post now. :) that was a nice discussion. i learned SOMETHING new about structs today. another victory won in the ongoing war to learn more about programming.
 
Status
Not open for further replies.
Top