Jump to content
  • 0

Setting Variable to Option select


Question

Posted

Having a hard time with this... Probably due to inexperience...

I have a quest that changes its objectives depending on the players level... What I did was assign a variable a certain value (1, 2 or 3) depending on the level the player was when he accepted the quest.

The NPC also has a dialogue mid-way through the quest to remind the player what his/her objective list is...

So I wanted to have the NPC show the objective list assigned to each difficulty quest (variable == 1, 2 or 3), but having a hard time scripting that into one line.

For now I'm using the following:

if (questlevel == 1) {
	mes "Objective List 1";
	}
if (questlevel == 2) {
	mes "Objective List 2";
	}
if (questlevel == 3) {
	mes "Objective List 3";
	}

Is there an easier way to do this in a single line of code, or in a simpler way?

 

Thank you.

5 answers to this question

Recommended Posts

  • 0
Posted (edited)
15 minutes ago, Jey said:

// Using Switch
switch(.@questlevel) {
  case 1:
	mes "Obj 1";
	break;
  case 2:
	mes "Obj 2";
	break;
  case 3:
	mes "Obj 3";
	break;
}

// Using an array of objectives (i.e. ItemIDs)
setarray .@objectives[0],607,608,609;
set .@Need_Objective = .@objectives[.@questlevel];
mes "Collect: "+getitemname(.@Need_Objective);

 

 

That's the best way to do this, i'll explain a little better, but all credits to @Jey <3

switch(questlevel) {
case 1: // in case that the variable questlevel = 1;
	mes "Your Quest";
	break;
case 2:
	mes "Your Quest";
	break;
case 3:
	mes "Your Quest";
	break;
default:
	mes "Woops! there's something wrong in the source script!"; // This line will excecute when the variable questlevel haves a different value.
	close;
}

 

If you want to add another one, just add another "case <value>:"

Edited by Promise
  • Upvote 1
  • 2
Posted
// Using Switch
switch(.@questlevel) {
  case 1:
	mes "Obj 1";
	break;
  case 2:
	mes "Obj 2";
	break;
  case 3:
	mes "Obj 3";
	break;
}

// Using an array of objectives (i.e. ItemIDs)
setarray .@objectives[0],607,608,609;
set .@Need_Objective = .@objectives[.@questlevel];
mes "Collect: "+getitemname(.@Need_Objective);

 

  • 1
Posted (edited)

Maybe something like this?

	if( questlevel == 1 ) goto questlevel_1;
	if( questlevel == 2 ) goto questlevel_2;
	if( questlevel == 3 ) goto questlevel_3;

	questlevel_1:
		mes "Your Quest";
		close;
	}

	questlevel_2:
		mes "Your Quest";
		close;
	}

	questlevel_3:
		mes "Your Quest";
		close;
	}
Edited by Kaze
  • 0
Posted (edited)

Hey, thanks Kaze.

Yeah, I thought about that, but in the end, that's pretty much what I had before, just throwing the code somewhere else... I was thinking of something like the questlevel taking directly to a menu, but I think that's the way to go...

Thanks mate.

 

Edited by BMythes
  • 0
Posted
On May 17, 2017 at 3:50 AM, Kaze said:

Maybe something like this?


	if( questlevel == 1 ) goto questlevel_1;
	if( questlevel == 2 ) goto questlevel_2;
	if( questlevel == 3 ) goto questlevel_3;

	questlevel_1:
		mes "Your Quest";
		close;
	}

	questlevel_2:
		mes "Your Quest";
		close;
	}

	questlevel_3:
		mes "Your Quest";
		close;
	}

Unnecessary goto's usage.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...