Jump to content

MarieDigby

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by MarieDigby

  1. If you haven't tried switch(select(rand(1,x)) then I recommend you to use.or you can follow Pooring Scripter's way

    On 2/17/2023 at 12:33 PM, pajodex said:

    Yes, should be possible.
     

    try this :

    // This script just shuffles the menu.. not related to the original post
    function	script	F_ShuffleNumbers	{
    	deletearray getarg(2);
    	.@static = getarg(0);
    	.@range = getarg(1) +1 - .@static;
    	.@count = getarg(3, .@range);
    	if (.@range <= 0 || .@count <= 0)
    		return 0;
    	if (.@count > .@range)
    		.@count = .@range;
    	for (.@i = 0; .@i < .@range; ++.@i)
    		.@temparray[.@i] = .@i;
    	for (.@i = 0; .@i < .@count; ++.@i) {
    		.@rand = rand(.@range);
    		set getelementofarray( getarg(2), .@i ), .@temparray[.@rand] + .@static;
    		.@temparray[.@rand] = .@temparray[--.@range];
    	}
    	return .@count;
    }
    
    prontera,150,180,0	script	Test	100,{
    	setarray .@s$, "Menu 1", "Menu 2", "Menu 3", "Menu 4";
    	callfunc "F_ShuffleNumbers", 0, getarraysize(.@s$)-1, .@r;
    	for ( .@i = 0; .@i < getarraysize(.@s$); .@i++ ) {
    		.@sel$[.@i] = .@s$[.@r];
    		.@menu$ += .@s$[.@r] + ":";
    	}
    	.@i = select(.@menu$)-1;
    	if ( .@sel$[.@i] == "Menu 1" ) {
    		mes "this happens 1";
    	} else if ( .@sel$[.@i] == "Menu 2" ) {
    		mes "this happens 2";
    	} else if ( .@sel$[.@i] == "Menu3" ) {
    		mes "this happens 3";
    	} else if ( .@sel$[.@i] == "Menu 4" ) {
    		mes "this happens 4";
    	}
    	close;
    }


    This is untested.. didnt have time to think thoroughly because im about to head to work but your question is quite interesting so I had to answer /swt

     

    EDIT: I noticed some mistakes but will correct it later after work.. [fixed]

    EDIT 2:  upon re-reading your question, it made more sense.. this is the correct one.. I will leave my initial answer here if someone needs it..cuphead

     

×
×
  • Create New...