Jump to content
  • 0

R> Minimize or simplify my script


Question

Posted (edited)

hye, i need to request on how can i minimize my current script, @Akkarin did teach me using function but it seems a bit diffrent from my previus request of HERE

this script have a need of lots of tools or tool type, reapting the script over and over again might not be a wise way, but i really had no idea how to simplfy or minimize this script, could someone help me?

Spoiler
-	script	Work Table	FAKE_NPC,{
	.@wrkb_id = atoi(strnpcinfo(2));

	if($wrkb_crafting_state[.@wrkb_id] == 1) {
		soundeffect "menu.wav",0;
		mes "Please wait until the process is finished. ";
		close;
	}

	if($wrkb_crafting_state[.@wrkb_id] == 2) {
		soundeffect "menu.wav",0;
		mes "Here are your crafted items.";
		for(.@i = 0; .@i < getarraysize(getd("$wrkb_" + .@wrkb_id + "_products")); .@i += 2)
			getitem(getd("$wrkb_" + .@wrkb_id + "_products[" + .@i + "]"), getd("$wrkb_" + .@wrkb_id + "_products[" + (.@i + 1) + "]"));

		delwaitingroom;
		$wrkb_crafting_state[.@wrkb_id] = 0;
		close;
	}
	
	soundeffect "menu.wav",0;
	mes "==============================";
	mes "^ff0000 Any item created unattended by using the Work Table can be stolen by other players !! ";
	mes "==============================";
	mes "Private Work Table are shared with those who have acsess only !!^000000";
	mes "==============================";
	next;
	soundeffect "menu.wav",0;
	mes "Select";
	switch(select("- Processing:- Weapons Crafting:- Cancel")) {
		case 1:
			next;
			soundeffect "menu.wav",0;
			mes "Select";
			switch(select("- Material Processing:- Parts Processing:- Cancel")) {
				case 1:
					next;
					soundeffect "menu.wav",0;
					mes "Select";
					switch(select("- Ore Powder:- Cancel")) {
						case 1:
							goto ore_powder;
						case 2:
							goto cancel;
					}
				case 2:
					next;
					soundeffect "menu.wav",0;
					mes "Select";
					switch(select("- Fine Rope:- Fine Handle:- Bone Knife Head:- Bone Tang:- Sturdy Handle:- Long Rope:- Long Stick:- Fine Wooden Blade:-Craved Stone:- Leather:- Heat Resistant Barrel:- Cancel")) {
						case 1:
							goto fine_rope;
						case 2:
							next;
							soundeffect "menu.wav",0;
							mes "Select tools";
							switch(select("- Makeshift Axe:- Cancel")) {
								case 1:
									goto mkshffine_handle;
								case 2:
									goto cancel;
							}
						case 3:
							next;
							soundeffect "menu.wav",0;
							mes "Select tools";
							switch(select("- Stone Knife:- Cancel")) {
								case 1:
									goto skboneknifehead;
								case 2:
									goto cancel;
							}
						case 4:
							goto msh_bonetang;
						case 5:
							goto Sturdy_Handle;
						case 6:
							goto long_rope;
						case 7:
							goto long_stick;
						case 8:
							goto finewodblade;
						case 9:
							goto CravedStone;
						case 10:
							goto leather;
						case 11:
							goto HeatResistantBarrel;
						case 12:
							goto cancel;
					}
				case 3:
					goto cancel;
			}
		case 2:
			next;
			soundeffect "menu.wav",0;
			mes "Select Weapon:";
			switch(select("- Dagger Class:- Sword Class:- Spear Class:- Axe Class:- Hammer Class:- Staff Class:- Bow Class:- Knuckle:- Katar:- Gun:- Cancel")) {
						case 1:
							next;
							soundeffect "menu.wav",0;
							mes "Select Dagger:";
							switch(select("- Improvise Dagger:- Cancel")) {
								case 1:
									goto impro_dag;
								case 2:
									goto cancel;
							}
						case 2:
							next;
							soundeffect "menu.wav",0;
							mes "Select Sword:";
							switch(select("- Improvise Wooden Sword:- Cancel")) {
								case 1:
									goto impro_wodsword;
								case 2:
									goto cancel;
							}
						case 3:
							next;
							soundeffect "menu.wav",0;
							mes "Select Spear:";
							switch(select("- Improvise Spear:- Cancel")) {
								case 1:
									goto impro_spear;
								case 2:
									goto cancel;
							}
						case 4:
							next;
							soundeffect "menu.wav",0;
							mes "Select Axe:";
							switch(select("- Improvise Axe:- Cancel")) {
								case 1:
									goto impro_axe;
								case 2:
									goto cancel;
							}
						case 5:
							next;
							soundeffect "menu.wav",0;
							mes "Select Hammer:";
							switch(select("- Improvise Hammer:- Cancel")) {
								case 1:
									goto impro_hammer;
								case 2:
									goto cancel;
							}
						case 6:
							next;
							soundeffect "menu.wav",0;
							mes "Select Staff:";
							switch(select("- Improvise Staff:- Cancel")) {
								case 1:
									goto impro_staff;
								case 2:
									goto cancel;
							}
						case 7:
							next;
							soundeffect "menu.wav",0;
							mes "Select Bow:";
							switch(select("- Improvise Bow:- Cancel")) {
								case 1:
									goto impro_bow;
								case 2:
									goto cancel;
							}
						case 8:
							next;
							soundeffect "menu.wav",0;
							mes "Select Knuckle:";
							switch(select("- Improvise Knuckle:- Cancel")) {
								case 1:
									goto impro_Knuckle;
								case 2:
									goto cancel;
							}
						case 9:
							next;
							soundeffect "menu.wav",0;
							mes "Select Katar:";
							switch(select("- Improvise Katar:- Cancel")) {
								case 1:
									goto impro_katar;
								case 2:
									goto cancel;
							}
						case 10:
							next;
							soundeffect "menu.wav",0;
							mes "Select Gun:";
							switch(select("- Improvise Gun:- Cancel")) {
								case 1:
									goto impro_gun;
								case 2:
									goto cancel;
							}
						case 11:
							goto cancel;
					}
		case 3:
			goto cancel;
	}
	end;
//=====================================================
//		Config
//=====================================================
HeatResistantBarrel:
	if(countitem(40191) < 1 || countitem(40084) < 1 || countitem(40085) < 1){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 1 Heat Resistant Jelly";
		mes "- 1 Long Rope";
		mes "- 1 Long Stick ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 1 Heat Resistant Jelly";
		mes "- 1 Long Rope";
		mes "- 1 Long Stick ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40191, 1;
					delitem 40084, 1;
					delitem 40085, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40189, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40191, 1;
					delitem 40084, 1;
					delitem 40085, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40189, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
impro_gun:
	if(countitem(40066) < 1 || countitem(40067) < 4 || countitem(40071) < 1 || countitem(40189) < 1){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 1 Sturdy Handle";
		mes "- 4 Fine Rope";
		mes "- 1 Bone Tang";
		mes "- 1 Fine Wooden Blade ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 1 Sturdy Handle";
		mes "- 4 Fine Rope";
		mes "- 1 Bone Tang";
		mes "- 1 Heat Resistant Barrel ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40066, 1;
					delitem 40067, 4;
					delitem 40071, 1;
					delitem 40189, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40177, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40066, 1;
					delitem 40067, 4;
					delitem 40071, 1;
					delitem 40189, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40177, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
impro_katar:
	if(countitem(40066) < 1 || countitem(40067) < 4 || countitem(40071) < 1 || countitem(40110) < 1){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 1 Sturdy Handle";
		mes "- 4 Fine Rope";
		mes "- 1 Bone Tang";
		mes "- 1 Fine Wooden Blade ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 1 Sturdy Handle";
		mes "- 4 Fine Rope";
		mes "- 1 Bone Tang";
		mes "- 1 Fine Wooden Blade ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40066, 1;
					delitem 40067, 4;
					delitem 40071, 1;
					delitem 40110, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40177, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40066, 1;
					delitem 40067, 4;
					delitem 40071, 1;
					delitem 40110, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40177, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
leather:
	if(countitem(40165) < 1 || countitem(40010) < 2){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 1 Pond Water";
		mes "- 2 Monster Skin ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 1 Pond Water";
		mes "- 2 Monster Skin ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40165, 1;
					delitem 40010, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40166, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40165, 1;
					delitem 40010, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40166, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
	
//=====================================================
impro_Knuckle:
	if(countitem(40166) < 1 || countitem(40071) < 5 || countitem(40067) < 2){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 1 Leather";
		mes "- 5 Bone Tang";
		mes "- 2 Fine Rope ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 1 Sturdy Handle";
		mes "- 1 Long Stick";
		mes "- 2 Fine Rope ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40166, 1;
					delitem 40071, 5;
					delitem 40067, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40164, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40166, 1;
					delitem 40071, 5;
					delitem 40067, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40164, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
impro_staff:
	if(countitem(40066) < 1 || countitem(40085) < 1 || countitem(40067) < 2){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 1 Sturdy Handle";
		mes "- 1 Long Stick";
		mes "- 2 Fine Rope ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 1 Sturdy Handle";
		mes "- 1 Long Stick";
		mes "- 2 Fine Rope ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40066, 1;
					delitem 40085, 1;
					delitem 40067, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40153, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40066, 1;
					delitem 40085, 1;
					delitem 40067, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40153, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
CravedStone:
	if(countitem(40024) < 2){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 2 Big Boulder ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 2 Big Boulder ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40024, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40142, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40024, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40142, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
impro_hammer:
	if(countitem(40066) < 1 || countitem(40085) < 1 || countitem(40067) < 2 || countitem(40142) < 1){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 1 Sturdy Handle";
		mes "- 1 Long Stick";
		mes "- 2 Fine Rope ";
		mes "- 1 Craved Stone. ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 1 Sturdy Handle";
		mes "- 1 Long Stick";
		mes "- 2 Fine Rope ";
		mes "- 1 Craved Stone. ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40066, 1;
					delitem 40085, 1;
					delitem 40067, 2;
					delitem 40142, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40130, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40066, 1;
					delitem 40085, 1;
					delitem 40067, 2;
					delitem 40142, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40130, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
impro_axe:
	if(countitem(40066) < 1 || countitem(40085) < 1 || countitem(40067) < 2 || countitem(40070) < 1){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 1 Sturdy Handle";
		mes "- 1 Long Stick";
		mes "- 2 Fine Rope ";
		mes "- 1 Bone Knife Head. ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 1 Sturdy Handle";
		mes "- 1 Long Stick";
		mes "- 2 Fine Rope ";
		mes "- 1 Bone Knife Head. ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40066, 1;
					delitem 40085, 1;
					delitem 40067, 2;
					delitem 40070, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40130, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40066, 1;
					delitem 40085, 1;
					delitem 40067, 2;
					delitem 40070, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40130, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
impro_spear:
	if(countitem(40066) < 1 || countitem(40085) < 1 || countitem(40067) < 2 || countitem(40070) < 1){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 1 Sturdy Handle";
		mes "- 1 Long Stick";
		mes "- 2 Fine Rope ";
		mes "- 1 Bone Knife Head. ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 1 Sturdy Handle";
		mes "- 1 Long Stick";
		mes "- 2 Fine Rope ";
		mes "- 1 Bone Knife Head. ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40066, 1;
					delitem 40085, 1;
					delitem 40067, 2;
					delitem 40070, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40100, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40066, 1;
					delitem 40085, 1;
					delitem 40067, 2;
					delitem 40070, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40100, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
impro_wodsword:
	if(countitem(40110) < 2 || countitem(40066) < 1 || countitem(40067) < 2){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 2 Fine Wooden Blade";
		mes "- 1 Sturdy Handle";
		mes "- 2 Fine Rope. ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 2 Fine Wooden Blade";
		mes "- 1 Sturdy Handle";
		mes "- 2 Fine Rope. ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40110, 2;
					delitem 40066, 1;
					delitem 40067, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40098, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40110, 2;
					delitem 40066, 1;
					delitem 40067, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40098, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
finewodblade:
	if(countitem(40027) < 2){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 2 Green Tree Log. ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 2 Green Tree Log. ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40027, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40110, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40085, 2;
					delitem 40084, 2;
					delitem 40066, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40110, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
impro_bow:
	if(countitem(40085) < 2 || countitem(40084) < 2 || countitem(40066) < 2){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 2 Long Stick";
		mes "- 2 Long Rope";
		mes "- 2 Sturdy Handle. ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 2 Long Stick";
		mes "- 2 Long Rope";
		mes "- 2 Sturdy Handle. ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40085, 2;
					delitem 40084, 2;
					delitem 40066, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40096, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40085, 2;
					delitem 40084, 2;
					delitem 40066, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40096, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
long_stick:
	if(countitem(40027) < 2){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 2 Green Tree Log ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 4 Fine Rope ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40027, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40085, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40027, 2;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40085, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
long_rope:
	if(countitem(40067) < 4){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 4 Fine Rope ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 4 Fine Rope ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40067, 4;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40084, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40067, 4;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40084, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
Sturdy_Handle:
	if(countitem(40067) < 2 || countitem(40068) < 1){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 2 Fine Rope";
		mes "- 1 Fine Handle. ^000000";
		close;
	}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 2 Fine Rope";
		mes "- 1 Fine Handle. ^000000";
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40067, 2;
					delitem 40068, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"), 40066, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40067, 2;
					delitem 40068, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40066, 1);
					goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
	impro_dag:
		if(countitem(40066) < 1 || countitem(40070) < 1 || countitem(40071) < 1){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 1 Sturdy Handle";
		mes "- 1 Bone Knife Head";
		mes "- 1 Bone Tang. ^000000";
		close;
		}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 1 Sturdy Handle";
		mes "- 1 Bone Knife Head";
		mes "- 1 Bone Tang. ^000000";
		next;
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem 40066, 1;
					delitem 40070, 1;
					delitem 40071, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40072, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem 40066, 1;
					delitem 40070, 1;
					delitem 40071, 1;
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40072, 1);
					goto OnCraftingStart;
				case 2:
					goto cancel;
			}
//=====================================================
	msh_bonetang:
		if(countitem(40069) < 1){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 1 Big Bone ^000000";
		close;
		}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 1 Big Bone ^000000";
		next;
		soundeffect "menu.wav",0;
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem(40069, 1);
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40071, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem(40069, 1);
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40071, 1);
					goto OnCraftingStart;
				case 2:
					goto cancel;
			}
//=====================================================
	skboneknifehead:
		if(countitem(40069) < 1 || rentalcountitem(40005) < 1){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 1 Big Bone ";
		mes "- Stone Knife ^000000";
		close;
		}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 1 Big Bone ";
		mes "- Stone Knife ^000000";
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem(40069, 1);
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40070, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem(40069, 1);
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40070, 1);
					goto OnCraftingStart;
				case 2:
					goto cancel;
			}
//=====================================================
	mkshffine_handle:
		if(countitem(40027) < 1 || rentalcountitem(40029) < 1){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 2 Green Tree Log";
		mes "- 1 Makeshift Axe ^000000";
		close;
		}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 2 Green Tree Log";
		mes "- 1 Makeshift Axe ^000000";
			switch(select("- Start:- Cancel")) {
				case 1:
					if(countitem(40007) == 1){
					delitem(40027, 2);
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40068, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
					}
					delitem(40027, 2);
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40068, 1);
					goto OnCraftingStart;
				case 2:
					goto cancel;
			}
//=====================================================
	fine_rope:
		if(countitem(40031) < 4){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 4 Green Stalk ^000000";
		close;
		}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 4 Green Stalk ^000000";
		switch(select("- Start:- Cancel")) {
			case 1:
				if(countitem(40007) == 1){
				delitem(40031, 4);
				setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40067, 1);
				process_points += 1;
				dispbottom "Gain +1 Processing Points";
				goto OnCraftingStart;
				}
				delitem(40031, 4);
				setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40067, 1);
				goto OnCraftingStart;
			case 2:
				goto cancel;
			}
//=====================================================
	ore_powder:
		if(countitem(40032) < 1 || rentalcountitem(40042) < 1){
		next;
		soundeffect "menu.wav",0;
		mes "^ff0000 Require";
		mes "- 1 Ore";
		mes "- 1 Mortar ^000000";
		close;
		}
		next;
		soundeffect "menu.wav",0;
		mes "^8fce00 Require";
		mes "- 1 Ore";
		mes "- 1 Mortar ^000000";
			switch(select("- Start:- Cancel")) {
				case 1:
					delitem(40032, 1);
					setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40037, 1);
					process_points += 1;
					dispbottom "Gain +1 Processing Points";
					goto OnCraftingStart;
				case 2:
					goto cancel;
			}
//=====================================================
	cancel:
		next;
		soundeffect "menu.wav",0;
		mes "Process Cancel";
		close;

	OnCraftingStart:
		$wrkb_crafting_state[.@wrkb_id] = 1;
		waitingroom("CRAFTING...", 0);
		initnpctimer;
		end;

	OnTimer60000:
		$wrkb_crafting_state[atoi(strnpcinfo(2))] = 2;
		delwaitingroom;
		waitingroom("COMPLETED!", 0);
		end;

	OnInit:
		.@wrkb_id = atoi(strnpcinfo(2));
		if(.@wrkb_id < 1) end;

		if($wrkb_crafting_state[.@wrkb_id] == 1) goto OnCraftingStart;
}
//veil
//=====================================================
veil,30,195,6	duplicate(Work Table)	Public Work Table#7000	11004
veil,30,189,6	duplicate(Work Table)	Public Work Table#7001	11004
veil,30,183,6	duplicate(Work Table)	Public Work Table#7002	11004
veil,30,177,6	duplicate(Work Table)	Public Work Table#7003	11004
veil,30,171,6	duplicate(Work Table)	Public Work Table#7004	11004
veil,30,165,6	duplicate(Work Table)	Public Work Table#7005	11004
veil,30,159,6	duplicate(Work Table)	Public Work Table#7006	11004
veil,30,153,6	duplicate(Work Table)	Public Work Table#7007	11004
veil,30,147,6	duplicate(Work Table)	Public Work Table#7008	11004
veil,30,141,6	duplicate(Work Table)	Public Work Table#7009	11004
veil,30,135,6	duplicate(Work Table)	Public Work Table#7010	11004
veil,30,129,6	duplicate(Work Table)	Public Work Table#7011	11004

veil,21,195,6	duplicate(Work Table)	Public Work Table#7012	11004
veil,21,189,6	duplicate(Work Table)	Public Work Table#7013	11004
veil,21,183,6	duplicate(Work Table)	Public Work Table#7014	11004
veil,21,177,6	duplicate(Work Table)	Public Work Table#7015	11004
veil,21,171,6	duplicate(Work Table)	Public Work Table#7016	11004
veil,21,165,6	duplicate(Work Table)	Public Work Table#7017	11004
veil,21,159,6	duplicate(Work Table)	Public Work Table#7018	11004
veil,21,153,6	duplicate(Work Table)	Public Work Table#7019	11004
veil,21,147,6	duplicate(Work Table)	Public Work Table#7020	11004
veil,21,141,6	duplicate(Work Table)	Public Work Table#7021	11004
veil,21,135,6	duplicate(Work Table)	Public Work Table#7022	11004
veil,21,129,6	duplicate(Work Table)	Public Work Table#7023	11004

 

as you can see on the part crafting there are tools requirement ( Select Tools ), and each part crafting have diffrent option of tools to select, and that was the idea, but after a while i notice if im gone use a diffrent tools for the same part crafting, means i might need to repeat the same cmd over and over again for each tools, while all it needs was changing type of tools, 

example :

crafting sword require a hammer, and there are serval type of hammer ( hammer A, Hammer B, Hammer C, etc ) but at the end all the tools are rquire to craft the same sword.

please send help to minimize and simplify my current script.

thanks...

Edited by Dolphin86

2 answers to this question

Recommended Posts

  • 0
Posted (edited)

so far i can only figure out this part.. i guess?

Spoiler
function	script	1_tool_1_item	{
	.@rental_item1 = getarg(0);
	.@1st_item = getarg(1);
	clear;
	if(rentalcountitem(.@rental_item1) < 1){
		mes "You don't have a "+ getitemname(.@rental_item1) +".";
		close;
	}
	if(countitem(.@1st_item) < 1){
		mes "You don't have a "+ getitemname(.@1st_item) +".";
		close;
	}
}

 

 

Spoiler
callfunc "1_tool_1_item",40005,40023;

 

and now how to delete items and how to connect to original crafting script as below but using simpler function as above ?

 

 

configs 1:

Spoiler
	.@wrkb_id = atoi(strnpcinfo(2));

	if($wrkb_crafting_state[.@wrkb_id] == 1) {
		soundeffect "menu.wav",0;
		mes "Please wait until the process is finished. ";
		close;
	}

	if($wrkb_crafting_state[.@wrkb_id] == 2) {
		soundeffect "menu.wav",0;
		mes "Here are your crafted items.";
		for(.@i = 0; .@i < getarraysize(getd("$wrkb_" + .@wrkb_id + "_products")); .@i += 2)
			getitem(getd("$wrkb_" + .@wrkb_id + "_products[" + .@i + "]"), getd("$wrkb_" + .@wrkb_id + "_products[" + (.@i + 1) + "]"));

		delwaitingroom;
		$wrkb_crafting_state[.@wrkb_id] = 0;
		close;
	}

 

 

This part should start deleting all the requirement items, and start trigger the crafting..

Spoiler
delitem 40191, 1;
delitem 40084, 1;
delitem 40085, 1;
setarray(getd("$wrkb_" + .@wrkb_id + "_products"),40189, 1);
goto OnCraftingStart;

 

 

Configs 2:

Spoiler
	OnCraftingStart:
		$wrkb_crafting_state[.@wrkb_id] = 1;
		waitingroom("CRAFTING...", 0);
		initnpctimer;
		end;

	OnTimer60000:
		$wrkb_crafting_state[atoi(strnpcinfo(2))] = 2;
		delwaitingroom;
		waitingroom("COMPLETED!", 0);
		end;

	OnInit:
		.@wrkb_id = atoi(strnpcinfo(2));
		if(.@wrkb_id < 1) end;

		if($wrkb_crafting_state[.@wrkb_id] == 1) goto OnCraftingStart;

 

 

Edited by Dolphin86
  • 0
Posted (edited)

You could simplify your script by creating a crafting subroutine that takes your crafting product and requirements instead of having the same logic repeated for every item.
 

-	script	Work Table	FAKE_NPC,{
	// i leave out the most stuff of your npc for the clarity of this example.

soundeffect "menu.wav",0;
mes "==============================";
mes "^ff0000 Any item created unattended by using the Work Table can be stolen by other players !! ";
mes "==============================";
mes "Private Work Table are shared with those who have acsess only !!^000000";
mes "==============================";
next;
soundeffect "menu.wav",0;
mes "Select";
switch(prompt("- Heat Resistant Barrel:- Whatever:- Cancel")) {
	case 1:
		// Product ID, Product Amount, Requirement ID, Requirement Type (Normal / Rental), Requirement Amount, ...
		callsub(S_Crafting_Init, 40189, 1, 40191, 0, 1, 40084, 0, 1, 40085, 0, 1);
	case 2:
		callsub(S_Crafting_Init, 40190, 1, 40192, 0, 1, 40085, 0, 1, 40086, 0, 1);
	case 255:
		goto OnCancel;
}

S_Crafting_Init:
	.@product_id = getarg(0);
	.@product_amount = getarg(1);

	for(.@i = 2; .@i < getargcount(); .@i += 3) {
		.@next_start_index = getarraysize(.@product_requirements);

		.@product_requirements[.@next_start_index] = getarg(.@i); // ID
		.@product_requirements[.@next_start_index + 1] = getarg(.@i + 1); // Type
		.@product_requirements[.@next_start_index + 2] = getarg(.@i + 2); // Amount
	}

	next;
	soundeffect "menu.wav",0;
	mes "^ff0000 Require";
	for(.@i = 0; .@i < getarraysize(.@product_requirements); .@i += 3) {
		mes "- " + .@product_requirements[.@i + 2] + " " + getitemname(.@product_requirements[.@i]);

		if(.@product_requirements[.@i + 1] == 1) {
			.@item_amount = rentalcountitem(.@product_requirements[.@i]);
		} else {
			.@item_amount = countitem(.@product_requirements[.@i]);
		}

		if(.@item_amount < .@product_requirements[.@i + 2]) {
			.@not_enough_items = 1;
		}
	}

	if(.@not_enough_items == 1){
		close;
	}

	soundeffect "menu.wav",0;
	if(select("- Start:- Cancel") == 2) {
		goto OnCancel;
	}

	if(countitem(40007) == 1){
		process_points += 1;
		dispbottom("Gained +1 Processing Points");
	}

	for(.@i = 0; .@i < getarraysize(.@product_requirements); .@i += 3) {
			if(.@product_requirements[.@i + 1] == 0) {
				delitem(.@product_requirements[.@i], .@product_requirements[.@i + 2]);
			}
	}

	setarray(getd("$wrkb_" + .@wrkb_id + "_products"), .@product_id, .@product_amount);
	goto OnCraftingStart;

	OnCancel:
		next;
		soundeffect "menu.wav",0;
		mes "Process Cancel";
		close;
}

 

Edited by Winterfox

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...