The Daily Click ::. Forums ::. Klik Coding Help ::. Two things
 

Post Reply  Post Oekaki 
 

Posted By Message

eski



Registered
  20/09/2009
Points
  39
28th September, 2009 at 20:23:39 -

Hi there, i'm new here and i have two newbie questions.


How do i make MMF pick 10 things out of 100 and never pick the same thing twice ?

And in the same loop i want to print out the name of the object which is in alterable text to a string object like so.

Thing 1
Thing 2
Thing 3

Always a new line for each item.

Currently i'm trying to use qualifier. Every object that is selected is marked with alterable value A as 1, then i know what item was chosen but MMF sometimes picks the same ojbect twice. Then it prints out in the string box text like

Thing 1Thing 2Thing3 ...

Thanks
Sigurgeir
eski@internet.is

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
28th September, 2009 at 20:34:04 -

I've never used it myself but I believe the MagicDeque object can pick different things without picking the same one twice. I think it was created to be used for card games and stuff but the idea's the same.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
28th September, 2009 at 23:29:43 -

well, if you know how to use spread values and loops it's pretty simple.
spread value 0 in alterable value a of active (or group, if you want it over a variety of object types)

run loop 'testloop' 10 times

if loop index of 'testloop' = value a of active (or group, if you want it over a variety of object types); then add " object name" to alterable string on string object. ofc,if you're using the group you wanna hold the object name in one of the objects variable strings for ease.

that'll pick the first 10 of the 100. however, it'll be the same 10 each time, if you want 10 RANDOM choices, it's a bit more difficult.

you still spread and start the loop, and as you thought, you use a qualifier. Now this one will work if you are using a single object type, if multiple types then you need to use a group, and the methods become more complex,and an add on might be more worthwhile using.

on loop
+ if active's qualifier AV = 0(i.e.hasn't been picked)
+ pick active at random
then set qualifier AV to 1(has been picked, you can encode more detail into that, such as recording the order it was picked into the value)
and print out the object's name.

Now, for multiple object types you will need to remove the random object selection, as in the loop, it'll look only through the first object type randomly picked, due to how mmf's context works. (not a problem with 1 type of active).

So to do this you want to select x separate, random values(where x is the amount of object selctions you want, in this case 10) between 1 and y (where x is the amount of objects you want,in this case 100). First would be to keep adding numbers, checking for duplicates, and keep adding until you have just 10.but if you want to say, select 99 randoms in a list of 100, this will take a while due to the duplicates.

I think magicdeque can fix this though, I'm pretty sure you can add numbers to an array in it (say 1-100), shuffle the order, then pop the top ten entries and compare to their spread value.

here's a quick example of a single object type implementation

the object's name is basically the object type held in it's first alt string + it's spread value

http://www.mediafire.com/download.php?l2anybyxwow

 
n/a

eski



Registered
  20/09/2009
Points
  39
29th September, 2009 at 02:35:24 -

Alright i totally understand how to do this now with single object but i still dont understand how to do it with multiple objects.
I dont understand how you use magicdeque with this.. Is there some example like the other one with multiple objects ?



 
n/a

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
29th September, 2009 at 16:15:49 -

OK, so, you have say, 100 objects, different types, all part of the same group qualifier

you do spread value 0 on the whole group, will number them 0-99

you push(add on to) the values 0-99 onto magicdeque, then call a shuffle on the current array.gives us 100 randomly organised values

this is where i have a problem. I tried this and went about using a line like

if spreadID of group = value in array at position(loop index)
then print out data etc.

but, this simply didn't work.So i tried to copy the value to check onto a counter and compare that instead. And, works perfectly, here it is...
http://www.mediafire.com/download.php?mlwmltmnmyy

(I screwed the triggered animation up a bit (edited graphics of the user anim 1 instead of walking, and i swapped from one to the other at one point fo some ease), but the code isfine)


Edited by MrMcFlurry

 
n/a

eski



Registered
  20/09/2009
Points
  39
29th September, 2009 at 20:06:40 -

Ok.. finally i got it to work.. thanks alot ! its great.

But one more thing if you can ?

Lets say when you can push the items that have AV B=1 the will be destroyed, how can you make the text in the string box disappear also ?
Can you put the name of each item to a new paragraph, if so can you display many paragraphs at once in the stringbox or is there something else that is used ?


I'm making a really easy hog game, so you get the idea what i'm doing.

Cheers



 
n/a

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
29th September, 2009 at 21:38:31 -

So, you have 10randomly selected objects out of 100, and want specific selections of those ten to be destroyed, and the list of objects to reflect this change?

not too experienced with formatting strings in mmf, shouldn't be too hard to look into

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
29th September, 2009 at 21:54:08 -

I'll make you an example.

 
n/a

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
29th September, 2009 at 21:54:55 -

Well,for greater control on text, the formatted text object is an option.

But generally I assumed you would need tome special symbol for a carriage return (new line), typical example being /n, but no, it seems as though it's simpler,you just need to make a newline in the expression editor. Slight problem with that,is if you hit enter in the expression editor, it tries to complete the expression, so I copy and pasted a new line into it and it worked fine.

However, your idea of the separate paragraphs being displayed together could be done well enough.you simply have one string object that holds each in a separate paragraph, and a second string that collates them for display with a small loop whenever a change is made. im not too certain on what you're aiming for.

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
29th September, 2009 at 22:23:40 -

Fully commented and uses no extensions.

http://www.jsoftgames.com/pickfromgroup.zip

If you have any questions feel free to ask!

 
n/a

eski



Registered
  20/09/2009
Points
  39
29th September, 2009 at 22:40:34 -

Yeah, almost like that.

The basic idea that i am trying to achieve is....

Hidden object game.

I have a scene where there are alot of items scattered around. Lets say there are 100 items (none the same) and the goal is to find 10 items that are randomly chosen each time you start the game. You will know what items they are because there is a list where they are named. Alright so when you find a item and click it the item will disappear and also the name of it in the string box. Just like in a normal hidden object game. I'm having trouble to get it all to work together. There is always some problem.

Also, i dont understand how loopindex work. There is so little help in the help file that comes with mmf.

Cheers

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
29th September, 2009 at 22:44:33 -

loopindex is basically the # of the current loop, and it is only useful from within a loop.

So if you run a loop (say "monkisgreat") and you call the loopindex function within that loop and it returns 11 then that means that the loop has run 12(it starts at 0) times!


EDIT: My example is what you want, but instead just remove the repositioning code. The list and the random selection code is perfect for what you want to achieve. If you want I can update the example.

Edited by UrbanMonk

 
n/a

eski



Registered
  20/09/2009
Points
  39
29th September, 2009 at 23:18:46 -

Ok, understanding loopindex better now.

Yes, that would be sweet if you could update the example.. ?



 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
29th September, 2009 at 23:34:29 -

The engine of your game is basically done. All it needs is polish and a scoring mechanism. Just replace the graphics I used and to add more objects just clone the existing ones and change the graphic.

http://www.jsoftgames.com/pickfromgroup2.zip

 
n/a

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
29th September, 2009 at 23:38:00 -

Your example is broken for me urban, it only picks objects from the first object type it comes across, not from every type (i.e.it's only grabbing blue objects, not the other colors) This is why I made use of the magicdeque add on to get around the issue.

Either way, this is my implementation of what you want eski.
http://www.mediafire.com/download.php?mjyznextmei

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
29th September, 2009 at 23:43:12 -

Update mmf2, it works perfectly on R249

 
n/a

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
29th September, 2009 at 23:51:22 -

Mm, im on 247.

But, either way, your example seems to replace removed objects,which i wouldn't see being a likely application in the game, but, whatever, 2 examples there for him to use.
/brofist

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
29th September, 2009 at 23:57:21 -

Ahh, I think you missed the second example. Anyway here are both the examples I made.

Here is the original example:
http://www.jsoftgames.com/pickfromgroup.zip

Here is the updated one for the game:
http://www.jsoftgames.com/pickfromgroup2.zip

Also I fixed the 1st example by removing the spread value part, that was the part that was causing your confusion MrMcFlurry because it gave the illusion that the objects were being selected "as they were come across" when infact they were just being arranged in order after they were selected.

 
n/a

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
30th September, 2009 at 00:20:25 -

Well, what i see in the first example (for some reason i cant install the update automatically...will try manually) is that it only picks from the blue objects, the rest are ignored.

your update halfway fixes this, but still, it only picks one sort. it'll pick either 10 yellow, 10blue, 10 purple, 10 green or 10red. not a mix

still, this might be related to the update.....but the latest download on the clickteam site is 246 =/ annoying

Edited by MrMcFlurry

 
n/a

eski



Registered
  20/09/2009
Points
  39
30th September, 2009 at 04:12:15 -

Ok, i dont have the newest update so there is somewhat buggy in the program from urban. i tried your stuff flurry and it worked almost.
The source that you had before worked well but after the alter there is something wrong..

i copied the code to my file with the items that i am using but there is something wrong.
It always picks the same object as the first item and sometimes it picks it twice, so when you click it there are two items that disappear from the stringbox. The item that it picks is the fruit basket

i uploaded the file.

http://www.mediafire.com/?mtgj2kz1mjn

I deleted all of the background images to ease up the size...

 
n/a

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
30th September, 2009 at 09:27:10 -

double click the magicdeque object, set it to 0-based.

it defaults to 1-based. that is, the first array entry should be entry0, but atm, it's one. so looking for entry0 returns 0, i.e. the first object.

 
n/a

eski



Registered
  20/09/2009
Points
  39
30th September, 2009 at 10:47:02 -

Brilliant, its working perfectly now.
Thanks alot, both of you guys

Cheers

 
n/a

eski



Registered
  20/09/2009
Points
  39
30th September, 2009 at 18:02:24 -

hmm.. i posted a reply and i dont know where it went.. anyways..

you most be getting tired of this but you know.. beginners are like children with the questions.

So i am working with the same file. I have now added fade out transitions to the items. When i click a item of the list the item fades out and then its destroyed but the description text doesn't go because by the time the fade out is done the loop find10 has already repeated and thinks that the item is still there because it hasn't been fully destroyed. Can i delay the loop so the item can disappear before it starts again ?

I don't fully understand the timer object.
Is the set timer a global timer ?
If i set the timer to like 5 sec on the start of frame. Then put a new condition that the timer is equal to 0 then a active item is destroyed.
Or do i need to connect the timer to a counter ?

Hope you understand this mumble.

 
n/a

MrMcFlurry



Registered
  03/08/2009
Points
  89

360 Owner
30th September, 2009 at 23:27:04 -

Eh, that's because when you make it fade out, the object stays in existence, effectively adding a disappearing animation, the object isn't destroyed until after the fade.

The counter is just there to delay the object removal until the object is gone...here, an alternate, can fix it with a qualifier. The fix also removed the need for the delay counter all together, that was really just a quick fix for the problem. It works by using AValueC to tag whether an object is destroyed or not, if it is, the loop ignores it.
http://www.mediafire.com/download.php?4bdndcntg3i


 
n/a

eski



Registered
  20/09/2009
Points
  39
1st October, 2009 at 00:36:04 -

brilliant.. !!

thanks A lot!!

 
n/a
   

Post Reply



 



Advertisement

Worth A Click