Shuffle

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
Baconlabs
Liquid Metal Slime
Posts: 1067
Joined: Mon Nov 02, 2009 6:29 am
Location: Middlin, TN

Shuffle

Post by Baconlabs »

To put a long problem short,
How do I change the main menu mid-game?

[s]I have two custom menus - I'll be using Menu One (which disables items) in one chapter, and Menu Two (which enables items) in the other.
During a plotscript between the two chapters, I'll need to switch which one is brought up with Escape/Alt/whatever. How should I go about this?[/s] Mystery solved, use tags to switch individual options on/off.


On a similar note, because I am clumsy with choreography in plotscripts, I want to replace the "Order" option in the menu with a "Shuffle" option, which should be a plotscript that detects how many heroes are in the party and rearranges them accordingly.
In a 2-hero party, Shuffle would reverse the heroes' locations.
In a 3-hero party, Shuffle would make formation [1, 2, 3] become [2, 3, 1] then [3, 1, 2] and back to [1, 2, 3] again.
I'm sure I can pull this off, but if anyone has a pre-existing script for this sort of thing, I'd love to see it.
Last edited by Baconlabs on Mon Nov 01, 2010 11:47 pm, edited 2 times in total.
User avatar
Ichiro
Slime Knight
Posts: 238
Joined: Sat Sep 11, 2010 1:20 am
Location: john madden

Post by Ichiro »

I think you can just use flags for this?
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Right. Although you can indeed write a script to catch ESC keypresses on every dang map and use that to determine which of two menus you open, it would be way easier to just edit your regular menu and make the Items option require a tag to be enabled.
User avatar
Baconlabs
Liquid Metal Slime
Posts: 1067
Joined: Mon Nov 02, 2009 6:29 am
Location: Middlin, TN

Post by Baconlabs »

James Paige wrote:it would be way easier to just edit your regular menu and make the Items option require a tag to be enabled.
Oh-oh-ohhhh, that's what
Right
I got it. And I can't believe how simple it is! Just switch a tag on to make the option selectable. I think I can apply this to future menu-thingies I've been planning, too.
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

I have a question about your shuffle plans.

You mentioned that your motivation for doing this is that you want to be clumsy with choreography in plotscripts. Are you doing that just because you want to make sure that the party is always in the first slots, so you are never organized like [A, B, Empty, B] or [Empty, A, B, C]?

If that is the reason, then I have an alternate suggestion. Call the standard order menu from a script, and then force them all to the front afterwards.

Something like this

Code: Select all

plotscript, gapless order menu, begin
  order menu
  variable(who, other)
  who := 0
  while(true) do(
    if(hero by slot(who) == -1) then(
      # found a gap
      other := who + 1
      while(true) do(
        if(other >= 4) then(break)
        if(hero by slot(other) >= 0) then(
          #found another hero!
          swap by position(who, other)
          break
        )
        other += 1
      )
    )else(
      # no gap here, continue
      who += 1
      if(who >= 4) then(break)
    )
  )
end
Let me know if this works for you. I haven't tested it in a game yet.
User avatar
JSH357
Liquid Metal Slime
Posts: 1341
Joined: Mon Oct 15, 2007 7:38 pm
Location: Columbia, SC
Contact:

Post by JSH357 »

Fun fact: When I read "Shuffle" I thought you meant as in randomizing a group of variables, and it made me cry because this was such a hassle to code in Motrya (The script I used to randomize the position of 9 cards took an obscene amount of code that I can barely read because the slice commands have such long names).
My website, the home of Motrya:
http://www.jshgaming.com
User avatar
Baconlabs
Liquid Metal Slime
Posts: 1067
Joined: Mon Nov 02, 2009 6:29 am
Location: Middlin, TN

Post by Baconlabs »

James Paige wrote:Are you doing that just because you want to make sure that the party is always in the first slots, so you are never organized like [A, B, Empty, B] or [Empty, A, B, C]?
Yes, that's exactly why.
I noticed when testing an earlier build that the player could switch characters around, and this interfered with all of my scripted movements, making dumb scenarios where invisible heroes ran around killing a dragon with their bare hands or whatever.

I'll test your code as soon as I can.
User avatar
Mogri
Super Slime
Posts: 4668
Joined: Mon Oct 15, 2007 6:38 pm
Location: Austin, TX
Contact:

Post by Mogri »

JSH357 wrote:Fun fact: When I read "Shuffle" I thought you meant as in randomizing a group of variables, and it made me cry because this was such a hassle to code in Motrya (The script I used to randomize the position of 9 cards took an obscene amount of code that I can barely read because the slice commands have such long names).
The lazy coder's shuffle:

Code: Select all

for(i, 0, BIG_NUMBER) do (
  swap(random card 1, random card 2)
)
Actually, this is pretty much the non-lazy coder's shuffle as well.
Post Reply