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
  49610

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
  49610

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
  49610

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
  49610

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
   

Post Reply



 



Advertisement

Worth A Click