132
« on: March 07, 2008, 01:37:07 am »
Seems people seem to repeat large chunks of script as well, mind the example below is an old script I believe, but it's certainly not the only of its kind, it's just one I noticed earlier and did rewrite and figured looking at the before and after might help others make their scripts shorter and easier to follow as well:
Before:
wait 3
emote examines the item.
if (%object.vnum% == 4951)
if (%object.count(4936)% == 8)
wait 1
mjunk %object%
wait 1 s
say Thank you, %actor.name%.
say A pleasure to do business with you.
emote hands over 2 tradepoints.
nop %actor.trade(2)%
if (%actor.level% < 10)
eval a 10
elseif %actor.level% > 45
eval a 45
else
eval a %actor.level%
endif
eval b 0
eval d 0
while %b% < %a%
set %actor.exp(4000)%
eval d %d%+4000
eval b %b%+1
global b
global d
done
%send% %actor% You have just gained %d% exp!
else
wait 1 s
say I can only take full containers! This is wholesale, not retail.
say All vegetables in it have to be of the right kind too!
wait 2 s
give %object% %actor.name%
drop %object%
say You go and get it right, and then come back again.
give %object% %actor.name%
drop %object%
say You go and get it right, and then come back again.
endif
elseif (%object.vnum% == 4952)
if (%object.count(4937)% == 8)
wait 1
mjunk %object%
wait 1 s
say Thank you, %actor.name%.
say A pleasure to do business with you.
emote hands over 2 tradepoints.
nop %actor.trade(2)%
if (%actor.level% < 10)
eval a 10
elseif %actor.level% > 45
eval a 45
else
eval a %actor.level%
endif
eval b 0
eval d 0
while %b% < %a%
set %actor.exp(4000)%
eval d %d%+4000
eval b %b%+1
global b
global d
done
%send% %actor% You have just gained %d% exp!
else
wait 1 s
say I can only take full containers! This is wholesale, not retail.
say All vegetables in it have to be of the right kind too!
wait 2 s
give %object% %actor.name%
drop %object%
say You go and get it right, and then come back again.
give %object% %actor.name%
drop %object%
say You go and get it right, and then come back again.
endif
elseif (%object.vnum% == 4953)
if (%object.count(4938)% == 8)
wait 1
mjunk %object%
wait 1 s
say Thank you, %actor.name%.
say A pleasure to do business with you.
emote hands over 2 tradepoints.
nop %actor.trade(2)%
if (%actor.level% < 10)
eval a 10
elseif %actor.level% > 45
eval a 45
else
eval a %actor.level%
endif
eval b 0
eval d 0
while %b% < %a%
set %actor.exp(4000)%
eval d %d%+4000
eval b %b%+1
global b
global d
done
%send% %actor% You have just gained %d% exp!
else
wait 1 s
say I can only take full containers! This is wholesale, not retail.
say All vegetables in it have to be of the right kind too!
wait 2 s
give %object% %actor.name%
drop %object%
say You go and get it right, and then come back again.
give %object% %actor.name%
drop %object%
say You go and get it right, and then come back again.
endif
elseif (%object.vnum% == 4954)
if (%object.count(4939)% == 8)
wait 1
mjunk %object%
wait 1 s
say Thank you, %actor.name%.
say A pleasure to do business with you.
emote hands over 2 tradepoints.
nop %actor.trade(2)%
if (%actor.level% < 10)
eval a 10
elseif %actor.level% > 45
eval a 45
else
eval a %actor.level%
endif
eval b 0
eval d 0
while %b% < %a%
set %actor.exp(4000)%
eval d %d%+4000
eval b %b%+1
global b
global d
done
%send% %actor% You have just gained %d% exp!
else
wait 1 s
say I can only take full containers! This is wholesale, not retail.
say All vegetables in it have to be of the right kind too!
wait 2 s
give %object% %actor.name%
drop %object%
say You go and get it right, and then come back again.
give %object% %actor.name%
drop %object%
say You go and get it right, and then come back again.
endif
elseif (%object.vnum% == 4955)
if (%object.count(4940)% == 8)
wait 1
mjunk %object%
wait 1 s
say Thank you, %actor.name%.
say A pleasure to do business with you.
emote hands over 2 tradepoints.
nop %actor.trade(2)%
if (%actor.level% < 10)
eval a 10
elseif %actor.level% > 45
eval a 45
else
eval a %actor.level%
endif
eval b 0
eval d 0
while %b% < %a%
set %actor.exp(4000)%
eval d %d%+4000
eval b %b%+1
global b
global d
done
%send% %actor% You have just gained %d% exp!
else
wait 1 s
say I can only take full containers! This is wholesale, not retail.
say All vegetables in it have to be of the right kind too!
wait 2 s
give %object% %actor.name%
drop %object%
say You go and get it right, and then come back again.
give %object% %actor.name%
drop %object%
say You go and get it right, and then come back again.
endif
elseif (%object.vnum%==4956||%object.vnum% == 4957||%object.vnum% == 4958||%object.vnum% == 4959)
return 0
wait 1 s
emote shakes his head, refusing to receive the item.
say Talk to my colleage, Mrs DelAngelo, my hands are full right now.
give %object% %actor.name%
drop %object%
else
wait 1
say I do not trade in items like this.
say I am only interested in freshly grown vegetables.
say And they have to be delivered in the Official 4D Containers as well.
give %object% %actor.name%
drop %object%
endif
After:
wait 3
emote examines the item.
if %object.vnum% == 4951 || %object.vnum% == 4952 || %object.vnum% == 4953 || %object.vnum% == 4954 || %object.vnum% == 4955
eval num %object.vnum% - 15
if %object.count(%num%)% == 8
wait 1
mjunk %object%
wait 1 s
say Thank you, %actor.name%.
say A pleasure to do business with you.
emote hands over 2 tradepoints.
nop %actor.trade(2)%
if %actor.level% < 10
eval exp 10 * 4000
elseif %actor.level% > 45
eval exp 45 * 4000
else
set exp %actor.level%
end
nop %actor.exp(%exp%)%
%send% %actor% You have just gained %exp% exp!
else
wait 1 s
say I can only take full containers! This is wholesale, not retail.
say All vegetables in it have to be of the right kind too!
wait 2 s
give %object.name% %actor.name%
drop %object.name%
say You go and get it right, and then come back again.
give %object.name% %actor.name%
drop %object.name%
say You go and get it right, and then come back again.
end
elseif %object.vnum%==4956 || %object.vnum% == 4957 || %object.vnum% == 4958 || %object.vnum% == 4959
return 0
wait 1 s
emote shakes his head, refusing to receive the item.
say Talk to my colleague, Mrs DelAngelo, my hands are full right now.
else
return 0
wait 1
say I do not trade in items like this.
say I am only interested in freshly grown vegetables.
say And they have to be delivered in the Official 4D Containers as well.
end