RandomPick

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: RandomPick

Re: Pick

by Graf Zahl » Thu Dec 25, 2014 11:01 am

Ok, good idea.

Re: Pick

by Major Cooke » Thu Dec 25, 2014 10:43 am

I suggest pulling all 2.0.04 download links in the mean time.

Re: Pick

by Graf Zahl » Thu Dec 25, 2014 10:42 am

Yeah, I'll do a 2.0.5/1.8.10 release ASAP, but I've got to do a few small fixes first.

Re: Pick

by Major Cooke » Thu Dec 25, 2014 10:32 am

I wish Pick hadn't been renamed to RandomPick, but I have no say in the matter. So now, I really wish this would've been renamed to RandomPick a lot sooner than now. I state this because GZDoom released 2.0.04, which does not contain the RandomPick change due to it being made so stealthily.

Re: Pick

by Major Cooke » Tue Dec 16, 2014 11:41 am

Okay, I just remembered something. This kind of change was one which required cleaning the solution. I've reported it over to the DRD team.

Re: Pick

by Major Cooke » Tue Dec 16, 2014 11:30 am

Yeah I see it now. Huh... I don't know what to think about this one, whether the DRD team messed something up in the process or if the code just doesn't get along with a certain configuration...

Re: Pick

by D2JK » Tue Dec 16, 2014 11:15 am

Decorate.

I used the latest (Dec 16) x64 build in here.

Actually there is an error message, the window just closed so fast I couldn't see it first: "Call to an unknown function Pick".

For example, this code can cause the error:
Spoiler:

Re: Pick

by Major Cooke » Tue Dec 16, 2014 10:47 am

Copy and paste your code, and I'll take a look at it. I only really designed this for DECORATE usage though. Whether it works in ACS or not was something I didn't have in mind for this to begin with. This is mainly because I don't want to make Graf clean up after my abysmal mess again. :oops:

If the latter, this is code I used to test it.

Code: Select all

Actor MM
{
	var int user_t;
	+NOINTERACTION
	States
	{
	Spawn:
		TNT1 A 0 NoDelay A_SetUserVar("user_t",pick(1,4,12,16))
		TNT1 A 0 A_JumpIf(user_t == 1,"s1")
		TNT1 A 0 A_JumpIf(user_t == 4,"s2")
		TNT1 A 0 A_JumpIf(user_t == 12,"s3")
		TNT1 A 0 A_JumpIf(user_t == 16,"s4")
	Err:
		TNT1 A 35 A_PrintBold("Apparently it didnt work.")
		Goto Spawn
	s1:
		TNT1 A 35 A_PrintBold("One")
		Goto Spawn
	s2:
		TNT1 A 35 A_PrintBold("Four")
		Goto Spawn
	s3:
		TNT1 A 35 A_PrintBold("Twelve")
		Goto Spawn
	s4:
		TNT1 A 35 A_PrintBold("Sixteen")
		Goto Spawn
	}
}

Re: Pick

by D2JK » Tue Dec 16, 2014 9:05 am

Perhaps a dumb question, but is this supposed to work in decorate? For me, using it in an action function makes ZDoom shut down in the startup, without any error message.

Re: Pick

by Major Cooke » Sun Dec 14, 2014 7:34 am

Aw hell. Sorry. Yeah, I still have a lot to learn.

Thanks for that though!

Re: Pick

by Graf Zahl » Sun Dec 14, 2014 5:02 am

Added, but I had to plug a memory leak. You forgot to delete the array's contents.

Re: Pick

by Major Cooke » Sun Dec 14, 2014 4:46 am

That did the trick! Thanks Graf! :D

The pull request has been updated.

Re: Pick

by Graf Zahl » Sun Dec 14, 2014 2:59 am

You try to get the size of your array by calling min.Max() when you should call min.Size(). Max() returns the amount of reserved memory, not the amount of elements in use.

Re: Pick

by Major Cooke » Sat Dec 13, 2014 6:50 pm

I'm not sure what to do about resolving with the array though. Any ideas?

Here's my code so far. Again, this is... very alien territory for me so it shouldn't be a surprise if I completely screwed the code up entirely. :?

Currently, it doesn't work. Access violation occurs in the Resolve call.
Spoiler:

Re: Pick

by Graf Zahl » Sat Dec 13, 2014 4:57 pm

Not if parsed properly. The ParseExpression functions parse an entire expression and store it as an FxExpression object. This object can be anything, ranging from a constant to some complex constructs that requires several levels of recursion to be evaluated.

Top