Some way to attach code to struct?

Trollvottel

never aging title
Reaction score
262
its seems that i cant attach code-variables to structs, because no code-array is allowed. any way to do this?
 

Sooda

Diversity enchants
Reaction score
318
Use boolexpr instead and return false in the end. It means you can' t call it as a callback from StartTimer() function. Other way would be to store exact function name as string and then use ExecuteFunc(yourFuncNameString). With ExecuteFunc name needs to be exact or Warcraft will crash.
Then there is triggeraction type what enables you to store trigger action function. But it would be same like using just ExecuteFunc() with func name string because both will create new threads.
What you are trying to do?
 

Trollvottel

never aging title
Reaction score
262
its again for the throw system. i try to throw something and if the unit collides or reaches the ground a specific function will run.
it will be called like this:

TTHROW_ThrowUnitAndDo(thrower, unittothrow,.....,function UserFunc)
 

Sooda

Diversity enchants
Reaction score
318
Check Cohadar TT System, it uses boolexpr to execute functions. They run until boolexpr function returns false, pretty clever.
It means if your unit collided with something you should return in TT System false and before you return false to indicate unit collided start new TT instance by calling boolexpr what should do effects what you want to happen. Actually TT System does already what you want to achieve here. Check his demo map where units slide. Now if unit reaches to max distance boolexpr function will return false. Before that you could call whatever new boolexpr what could for example kill unit and return in first run false. To understand me you should check TT system demo map first.
 

Trollvottel

never aging title
Reaction score
262
thank you for help, it works now not even a return needed, the function runs only once at the end of flying
 

Cohadar

master of fugue
Reaction score
209
For functions that run only once ALWAYS return true or it will desync.
 

Trollvottel

never aging title
Reaction score
262
so if i call TriggerEvaluate(trig) and the function doesnt return anything it desyncs? omg thnx
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
A particular reason for not using function interfaces?
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
Nah. Cohadar doesn't understand the beauty of //!textmacros + function interfaces. I'm assuming he doesn't like MaDOS, because of his fanatical campaign of destruction against two very useful things.
 

Vexorian

Why no custom sig?
Reaction score
187
A particular reason for not using function interfaces?

If you made the users pass a boolexpr or trigger, you would generate code that is almost exactly the same as the one generated by function interfaces...
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
And yet you could also make nice syntax sugary programming. For instance:

JASS:
function Ball_Bnc takes BounceEvent BE returns nothing
    call BE.O.Accelerate(0,0,2*BE.O.Speed.Z)
    call SetUnitVertexColor(BE.O.Unit,255,255,255,0)
endfunction


Of course, if you were going to dynamically allocate it, you don't so much need function interfaces, since you are likely using textmacros, and just defining what is happening within the bouncing, etc.
 

Trollvottel

never aging title
Reaction score
262
but why should i do it so complicated if i just can create a trigger array, add the condition and evaluate the trigger?
 

Cohadar

master of fugue
Reaction score
209
A particular reason for not using function interfaces?

Function interfaces have ugly syntax in vJass, so they kind of fail in their purpose to be syntax sugar.

but why should i do it so complicated if i just can create a trigger array, add the condition and evaluate the trigger?

You should use TT, it really does not get much simpler than that.
If I can use it for physics engine in pyramidal you can use it for your jump/throw system.
 

Trollvottel

never aging title
Reaction score
262
i used it as timer <.< sure
but i think you understand me wrong. at the end of the running I just call a userfunc and for this i really dont need TT because its just.... one call without anything else but I have to use TriggerEvaluate()
 

Cohadar

master of fugue
Reaction score
209
Oh I see.
Well then use function registration like in TT.
But instead of condition use Action and do TriggerExecute on a trigger that has userFunction as Action.
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
Is his system not dynamic (with dynamic creation/destruction)? I mean, I suppose it doesn't even matter, since I can't see a situation where you would be constantly creating and destroying these actions...
 

Trollvottel

never aging title
Reaction score
262
i can. its for my throw system. you throw the unit/projectile and when it hits the ground, this function is called. so thats a good solution for it
 

Vexorian

Why no custom sig?
Reaction score
187
For your application it would be a capital sin not to use interfaces, your users are most likely going to need to specifiy data as well, not just a function.




Function interfaces have ugly syntax in vJass, so they kind of fail in their purpose to be syntax sugar.
Not buying it.

Edit: I mean, if you were to ask a user, what's better:

"make a boolexpr and add it as an argument to my function"
"Add your function as code argument to my function"
"Type FunctionInterfaceName.functionname "

All three of them look like equal non-sense to me. But at least the function interface will save every one work, you will not have to bother creating triggers at map init your self. And you can just as easily decide between .evaluate or .execute.

I was thinking on making just functionname work, or perhaps I'll make up something like "somekeyword functionname" to make it look like Jass' code but I've been too busy.

They are just a workaround for people that don't want to use interfaces, anyway...
 

Trollvottel

never aging title
Reaction score
262
For your application it would be a capital sin not to use interfaces, your users are most likely going to need to specifiy data as well, not just a function.

i dont understand. my users get globals they can handle with for this function, i dont think there will be a problem, another reason for me not to use interfaces for me is that i never did and dont know how i should do it here
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      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