Shard is currently offline.



Take the Tour | Site Map

It is currently Sat Mar 23, 2019 2:18 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Sat Mar 02, 2019 11:47 am 
Offline
Apprentice Scripter
Apprentice Scripter

Joined: 01/30/2012 17:47
Posts: 27
What’s the best way to express the following:

If %1 = 2 || 3 || 4
{
Event macro 5 6
Wait 10
}
Else
{
Event macro 5 4
Wait 10
}

It seems like it only gives me the result I want when %1 = 2 , when %1 = 3 or 4, it doesn’t work like I want.
I’m typing this on my phone from memory so I apologize if it’s confusing.


Sent from my iPhone using Tapatalk


Top
  Profile 
PostPosted: Sat Mar 02, 2019 1:22 pm 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 07/10/2004 17:11
Posts: 2307

if %1 = 2 || %1 = 3 || %1 = 4...

_________________
Image


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Sat Mar 02, 2019 2:13 pm 
Offline
Apprentice Scripter
Apprentice Scripter

Joined: 01/30/2012 17:47
Posts: 27
Awesome, thank you!

I should have thought of that.


Top
  Profile 
PostPosted: Mon Mar 04, 2019 11:32 pm 
Offline
Developer
Developer
User avatar

Joined: 06/29/2003 11:05
Posts: 2472

I don't remember but I think there's also a syntax like this:

if _%1_ in _2_3_4_
{
msg YAY!
}


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Tue Mar 05, 2019 7:57 am 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 07/10/2004 17:11
Posts: 2307

if %1 in _2_3_4_ is correct. If you wanted underscores around the %1, you'd need commas. But Cheffe shows out with the much easier way of doing it.
Here's the other way:
if _ , %1 , _ in _2_3_4_ that way it would format the info in %1 like this: _ , 2 , _ or _2_ and be an exact match. In the case of using numbers, there could be a time where adding an underscore in front and behind would make the results more accurate. So it's sometimes best to use underscores or anything really as separators to ensure that the data is an exact match. Same with item types, some types might be the same letter, and you'll run into some issues with finding certain types if you don't surround them with underscores. I can't think of a specific example off hand, but I'm sure I've run into it before, and I use underscores to separate item types, and character ids for that specific reason. Always do things Cheffe's way, unless someone gives you a good reason. He's scolded me into compliance a number of times. ;) Just never EVER PM him. haha Especially with a stupid question.

_________________
Image


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Wed Mar 06, 2019 7:11 am 
Offline
Apprentice Scripter
Apprentice Scripter

Joined: 01/30/2012 17:47
Posts: 27
Thanks Scripty and Cheffe. I like that way. It looks cleaner. I save my PM's for you Scripty ;)


Top
  Profile 
PostPosted: Wed Mar 06, 2019 12:46 pm 
Offline
Legendary Scripter
Legendary Scripter
User avatar

Joined: 07/10/2004 17:11
Posts: 2307

Here's an example of why using underscores matters. Say you're searching for some items. And you want to find BH. You'd go:

if _ , BH , _ in _ , #findtype , _

That way, it wouldn't score a hit if the #findtype happened to be BHR

This would be true for both BH and BHR, which would be incorrect below:

if bh in #findtype

That would flag both BH and BHT if found in #findtype and be incorrect.

_________________
Image


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Wed Mar 06, 2019 2:21 pm 
Offline
Apprentice Scripter
Apprentice Scripter

Joined: 01/30/2012 17:47
Posts: 27
I understand!


Top
  Profile 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Hosted by CalWeb Internet Services, Inc.