Jump to content
  • 0

Setting Variable to Option select


BMythes

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  04/15/17
  • Last Seen:  

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.

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  386
  • Reputation:   38
  • Joined:  04/28/13
  • Last Seen:  

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
Link to comment
Share on other sites

  • 2

  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  249
  • Reputation:   72
  • Joined:  10/20/12
  • Last Seen:  

// 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);

 

Link to comment
Share on other sites

  • 1

  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.00
  • Content Count:  235
  • Reputation:   55
  • Joined:  12/02/11
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  04/15/17
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   431
  • Joined:  01/26/16
  • Last Seen:  

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.

Link to comment
Share on other sites

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.

×
×
  • Create New...