Post new topic    
Liquid Metal Slime
Send private message
Shuffle 
 PostMon Nov 01, 2010 11:21 pm
Send private message Reply with quote
To put a long problem short,
How do I change the main menu mid-game?

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?
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.
Slime Knight
Send private message
 
 PostMon Nov 01, 2010 11:28 pm
Send private message Reply with quote
I think you can just use flags for this?
Liquid Metal King Slime
Send private message
 
 PostMon Nov 01, 2010 11:34 pm
Send private message Reply with quote
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.
Liquid Metal Slime
Send private message
 
 PostMon Nov 01, 2010 11:43 pm
Send private message Reply with quote
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.
Liquid Metal King Slime
Send private message
 
 PostTue Nov 02, 2010 12:49 am
Send private message Reply with quote
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:

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.
Liquid Metal Slime
Send private message
 
 PostTue Nov 02, 2010 12:54 am
Send private message Reply with quote
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
Liquid Metal Slime
Send private message
 
 PostTue Nov 02, 2010 1:10 am
Send private message Reply with quote
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.
Super Slime
Send private message
 
 PostTue Nov 02, 2010 1:38 am
Send private message Reply with quote
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:
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.
Mega Tact v1.1
Super Penguin Chef
Wizard Blocks
Display posts from previous: