Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ usage of 'or'

usage of 'or'

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2 

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #15 on Sun 29 Jun 2003 10:05 AM (UTC)
Message
Why are you even doing that second check?

wouldnt by definition, if the first one (the if theyre 0 check) wasnt true, the second one (if either is not 0) would be?

Just do an If Then Else, and ditch the second if.. since it seems redundant (unless of course, the hour is getting to me as well)

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #16 on Sun 29 Jun 2003 10:05 AM (UTC)
Message
Quote:

unless there is a client-side tester?


You can simulate MUD input (even when disconnected) with Shift+Ctrl+F12

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #17 on Sun 29 Jun 2003 10:16 AM (UTC)

Amended on Sun 29 Jun 2003 10:25 AM (UTC) by Flannel

Message
ACtually, (Now that Ive actually looked at the code) your first if, Shouldnt it be an AND?
You first check to see if EITHER of the variables is the same, and then you set both variables? (Why shouldnt you just do the one that is the same?)

THEN, you check (You only get here if neither of the variables are the same)
then, you find the change of each, and then check to see if the change is positive on one OR the other, and then check to see if its negative on one OR the other...

I think you should probably split it up to be something like this:

Check to see if sp is same, if it is, store new sp, check to see if hp is same, if it is, store new hp. Check to see if either of them have changed (OR) then, within that if have two sets of ifs, one for SP, then one for HP (or however youd like) to see if it (HP) changed (sicne we dont know which one of the two has) and then inside that, check if positive then since we know we wouldnt be this far if it was 0, we can do an else for negative, then step up a level, check the other (SP) has changed, then check for positive, and since we know again we wouldnt be here if its 0, we do an automatic negative. Then, step out, and store variables..

edit:
Actually, Ive got a better idea (now that I see what youre sending) really ought to read these things all the way through.. anyway. Itll come soon.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #18 on Sun 29 Jun 2003 10:36 AM (UTC)

Amended on Sun 29 Jun 2003 11:45 AM (UTC) by Flannel

Message

Sub OnNewHp(strAliasName, strOutput, arrWildCards)
  dim spchange, hpchange, hpsign, spsign
  newhp = world.getvariable ("newhp")
  newsp = world.getvariable ("newsp")
  oldsp = world.getvariable ("oldsp")
  oldhp = world.getvariable ("oldhp")
  totalhp = world.getvariable ("totalhp")
  totalsp = world.getvariable ("totalsp")
  if newhp = oldhp then              \
    setvariable "oldhp", newhp        \
  end if                               \  See
  if newsp = oldsp then                / Below
    setvariable "oldsp", newsp        /
  end if                             /
  hpchange = oldhp - newhp
  spchange = oldsp - newsp
  if hpchange >= "0" then
    hpsign = "+"
  else
    hpsign = "-"
    hpchange = abs(hpchange)
  end if
  if spchange >= "0" then
    spsign = "+"
  else
    spsign = "-"
    spchange = abs(spchange)
  end if
  if spchange + hpchange then 
    World.Send "ps Hp: " & newhp & "(" & totalhp & ") " & hpsign & hpchange & " Sp: "_
 & newsp & "(" & totalsp & ") " & spsign & spchange & ""
  end if
  world.setvariable "oldhp",newhp
  world.setvariable "oldsp",newsp
end sub


edit:
Added the underscore after SP: I THINK thats the VBscript line continuation... Just hate seeing the forum have a horiz. scroll, to fix it, delete the underscore, and the carriage return.
probably want to delete it anyway, since the underscore might not work.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Poromenos   Greece  (1,037 posts)  Bio
Date Reply #19 on Sun 29 Jun 2003 11:02 AM (UTC)
Message
if newhp = oldhp then
setvariable "oldhp", newhp
end if

Redundant. If newhp is 10, and oldhp is also 10, then that portion will set oldhp to 10, but it was 10 to begin with.

if newsp = oldsp then
setvariable "oldsp", newsp
end if

Same.

Also, why do the sign thing and not just have it display the native, i.e. "10" for +10 hp and "-10" for -10?

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #20 on Sun 29 Jun 2003 11:42 AM (UTC)

Amended on Sun 29 Jun 2003 11:43 AM (UTC) by Flannel

Message
Youre right, I didnt think about that first part, just copied it.

Anyway, The plus thing is how they originally had it setup, and it makes sense. (And was trying to keep output the same, which is why I have the empty string at the end of the line)

They have newstat(total)+/-change
Thats waht the double dipping was, one for positive, one for negative (originally had native for -, but that would require more complex code stuff for the send lines. This made it a lot easier.

COULD have done.... "" as sign (when negative) and then used native. That crossed my mind too, but I decided to go with this, since its more symmetric.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #21 on Mon 30 Jun 2003 04:27 PM (UTC)

Amended on Mon 30 Jun 2003 05:08 PM (UTC) by Magnum

Message
For comparison's sake, I'll offer you a large chunk of code from one of my own plugins. (The Plugin is unreleased, still needs much work, and I barely script lately).

On my mud, instead of 'spell points' [SP], we have 'concentration points' [CP].

On my mud, healer characters can choose a "heal all" spell which sends a wave of healing to the entire mud. For fun, I decided to script a thank-you informing the healer of how many HP's they healed. I use the "thank" emote which will accept an argument for additional text to add to the emote.

Thanking the healer is actually a bit tricky, because: If I am in combat, the heal the world message comes between two health bars, with the added hit points being in the health bar after the heal all line, but if I am not in combat, a health bar is presented first, and then the heal all line is presented. In order to offer an accurate message to the healer, I track the most recent health bar indicating my current health, plus the previous two health bars. (I can turn autothanks on/off via an alias).

In direct regards to what you are doing, I also have the ability to display the difference between health bars. I call this "Tickinfo". I have an alias to turn "Tickinfo" on/off via an alias, or I can just use the alias "Tick" to present the information just once.

Since the health bar is slighly different while in combat (It has an additional "OPPONENT: Perfect Health" added to it), I can detect whether I am in combat or not. This can be useful, so I track this information as well.

The script includes calls to another plugin of mine, "StatLine", which is used to present information on the status line in MUSHclient. (That one is available at my website).

Some of the triggers have &Prompt; at the beginning of them. This is a special substring meant to capture my prompt, in case it is displayed on the same line as the text I want to trigger on. The actual expression for matching my prompt is declared in an ENTITY value at the beginning of the plugin:

<!DOCTYPE muclient [
	<!ENTITY NoteColour "#FF64B9" >
	<!ENTITY NamePrefix "AOD_MON:" >
	<!ENTITY Prompt "(?:&gt; )*" >
	]>

I find that a very useful means of offering flexability in plugins. Someone with a different prompt only need change that one value, and all the triggers in my plugin should still work.

Finally, there may be subroutines and functions called in this quoted script, which have not been quoted. (Like my "Padleft" function for example).

<!--	===== Monitor Health Status =================================== -->

<triggers>
	<trigger
		enabled="y"
		match="^&Prompt;HP\: \[(.*?)\/(.*?)\]  CONC\: \[(.*?)\/(.*?)\]$"
		name="MONITOR_Health_Status"
		regexp="y"
		script="Get_Health_Status"
		sequence="100"
		>
	</trigger>
	<trigger
		enabled="y"
		match="^&Prompt;HP\: \[(.*?)\/(.*?)\]  CONC\: \[(.*?)\/(.*?)\]  OPPONENT\: (.*?)$"
		name="MONITOR_Health_Status_InCombat"
		regexp="y"
		script="Get_Health_Status"
		sequence="100"
		>
	</trigger>
</triggers>

<aliases>
	<alias
		name="MON_TickInfo"
		script="Toggle_TickInfo"
		match="^TickInfo(?:[ ]+(.*))?$"
		enabled="y"
		regexp="y"
		ignore_case="y"
		>
	</alias>
	<alias
		name="Display_TickInfo"
		script="Display_TickInfo"
		match="^tick$"
		enabled="y"
		regexp="y"
		ignore_case="y"
		>
	</alias>
</aliases>

<script>
<![CDATA[

Dim HPc_Full,  HPc_Current,  HPc_Percent,  CPc_Full,  CPc_Current,  CPc_Percent
Dim HPp_Full,  HPp_Current,  HPp_Percent,  CPp_Full,  CPp_Current,  CPp_Percent
Dim HPp2_Full, HPp2_Current, HPp2_Percent, CPp2_Full, CPp2_Current, CPp2_Percent

Sub InCombat_False (TriggerName, TriggerLine, arrWildcards)
	World.SetVariable "InCombat", vbsFalse
	World.SetVariable "InCombatStatus", "Peace."
	World.CallPlugin "5c582b1da52fd6a9d5d912a8", "AddString", "19_InCombatStatus" & _
		Chr(10) & World.GetVariable("InCombatStatus")
	If ThankHealer Then Send_Thank_Healer
End Sub

Sub InCombat_True (TriggerName, TriggerLine, arrWildcards)
	World.SetVariable "InCombat", vbsTrue
	World.SetVariable "InCombatStatus", "Combat!"
	World.CallPlugin "5c582b1da52fd6a9d5d912a8", "AddString", "19_InCombatStatus" & _
		Chr(10) & World.GetVariable("InCombatStatus")
	If ThankHealer Then Send_Thank_Healer_InCombat
End Sub

Sub Get_Health_Status (TriggerName, TriggerLine, arrWildcards)
	Dim StatusLineText
	HPp2_Current = HPp_Current
	HPp2_Full = HPp_Full
	HPp2_Percent = HPp_Percent
	CPp2_Current = CPp_Current
	CPp2_Full = CPp_Full
	CPp2_Percent = CPp_Percent
	HPp_Current = HPc_Current
	HPp_Full = HPc_Full
	HPp_Percent = HPc_Percent
	CPp_Current = CPc_Current
	CPp_Full = CPc_Full
	CPp_Percent = CPc_Percent
	HPc_Current = CStr(CInt(arrWildcards(1)))
	HPc_Full = CStr(arrWildcards(2))
	HPc_Percent = CStr(Round(((CInt(HPc_Current) / CInt(HPc_Full)) * 100)))
	CPc_Current = CStr(arrWildcards(3))
	CPc_Full = CStr(arrWildcards(4))
	CPc_Percent = CStr(Round(((CInt(CPc_Current) / CInt(CPc_Full)) * 100)))
	If World.GetVariable("TickInfo") Then Display_TickInfo "Get_Health_Status", TriggerLine, arrWildcards
	StatusLineText = "HP: " & HPc_Percent & "%  CP: " & CPc_Percent & "%"
	World.CallPlugin "5c582b1da52fd6a9d5d912a8", "AddString", "12_HealthStatus" & _
		Chr(10) & StatusLineText
	If CStr(arrWildcards(5)) <> Empty Then
		InCombat_True "Get_Health_Status", TriggerLine, arrWildcards
	Else
		InCombat_False "Get_Health_Status", TriggerLine, arrWildcards
	End If
End Sub

Sub Display_TickInfo (AliasName, AliasLine, arrWildcards)
	World.ColourNote NoteColour, "", "HP: " & _
		PadLeft(CStr(CInt(HPc_Current) - CInt(HPp_Current)), Len(HPc_Current) + 1) & _
		PadLeft("CONC: ", Len(HPc_Full) + 10) & _
		PadLeft(CStr(CInt(CPc_Current) - CInt(CPp_Current)), Len(CPc_Current) + 1)
End Sub

Sub TickInfo_On
	World.SetVariable "TickInfo", True
	World.SetVariable "TickInfoStatus", "TickInfo: On"
	World.ColourNote NoteColour, "", World.GetVariable("TickInfoStatus")
End Sub

Sub TickInfo_Off
	World.SetVariable "TickInfo", False
	World.SetVariable "TickInfoStatus", "TickInfo: Off"
	World.ColourNote NoteColour, "", World.GetVariable("TickInfoStatus")
End Sub

Sub Toggle_TickInfo (AliasName, AliasLine, arrWildcards)
	Dim Argument
	Argument = Trim(LCase(arrWildcards(1)))
	If (Argument = "on")  or (Argument = "yes") or (Argument = "true")  Then Argument = "y"
	If (Argument = "off") or (Argument = "no")  or (Argument = "false") Then Argument = "n"
	If Argument = "y" Then
		TickInfo_On
	ElseIf Argument = "n" Then
		TickInfo_Off
	Else
		If World.GetVariable("TickInfo") Then
			TickInfo_Off
		Else
			TickInfo_On
		End If
	End If
End Sub

]]>
</script>

<!--	===== Thank Healer ============================================ -->

<aliases>
	<alias
		name="MON_AutoThank"
		script="Toggle_AutoThank"
		match="^(?:athank|autothank)(?:[ ]+(.*))?$"
		enabled="y"
		regexp="y"
		ignore_case="y"
		>
	</alias>
</aliases>

<triggers>
	<trigger
		enabled="y"
		match="^&Prompt;(\w*) lets (?:his|her) healing powers flow through the world\.$"
		name="MONITOR_Heal_The_World"
		regexp="y"
		script="Set_Healer_To_Thank"
		sequence="100"
		>
	</trigger>
</triggers>

<script>
<![CDATA[

Dim ThankHealer,    ThankHealerName

Sub Set_Healer_OptOut
End Sub

Sub Set_Healer_To_Thank (TriggerName, TriggerLine, arrWildcards)
	ThankHealerName = CStr(arrWildcards(1))
	ThankHealer = vbsTrue
	If CInt(HPp_Percent) = 100 Then ThankHealer = vbsFalse
End Sub

Sub Send_Thank_Healer
	Dim Message
	ThankHealer = vbsFalse
	If World.GetVariable("AutoThank") Then
'		Message = " HP: [" & HPp2_Current & "/" & HPp2_Full & "] - to -> HP: [" & HPp_Current & "/" & HPp_Full & "]"
		Message = " for " & CStr(HPp_Current - HPp2_Current) & " HP's worth of healing"
		World.LogSend "thank " & ThankHealerName & Message
	End If
End Sub

Sub Send_Thank_Healer_InCombat
	Dim Message
	ThankHealer = vbsFalse
	If World.GetVariable("AutoThank") Then
'		Message = " HP: [" & HPp_Current & "/" & HPp_Full & "] - to -> HP: [" & HPc_Current & "/" & HPc_Full & "]"
		Message = " for " & CStr(HPc_Current - HPp_Current) & " HP's worth of healing"
		World.LogSend "thank " & ThankHealerName & Message
	End If
End Sub

Sub AutoThank_On
	World.SetVariable "AutoThank", True
	World.SetVariable "AutoThankStatus", "AutoThank: On"
	World.ColourNote NoteColour, "", World.GetVariable("AutoThankStatus")
End Sub

Sub AutoThank_Off
	World.SetVariable "AutoThank", False
	World.SetVariable "AutoThankStatus", "AutoThank: Off"
	World.ColourNote NoteColour, "", World.GetVariable("AutoThankStatus")
End Sub

Sub Toggle_AutoThank (AliasName, AliasLine, arrWildcards)
	Dim Argument
	Argument = Trim(LCase(arrWildcards(1)))
	If (Argument = "on")  or (Argument = "yes") or (Argument = "true")  Then Argument = "y"
	If (Argument = "off") or (Argument = "no")  or (Argument = "false") Then Argument = "n"
	If Argument = "y" Then
		AutoThank_On
	ElseIf Argument = "n" Then
		AutoThank_Off
	Else
		If World.GetVariable("AutoThank") Then
			AutoThank_Off
		Else
			AutoThank_On
		End If
	End If
End Sub

]]>
</script>

Oh, the empty sub "Set_Healer_OptOut" is just a reminder that I intend to write additional code to restrict thanking certain healers who do not wish to be thanked (they find it too spammy).

Argh, the forum software removed a \ character here and there, particularly in the quoted triggers, escaping square brackets. I have tried to fix them.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #22 on Mon 30 Jun 2003 09:29 PM (UTC)

Amended on Mon 30 Jun 2003 09:30 PM (UTC) by Nick Gammon

Message
Quote:

Argh, the forum software removed a \ character here and there, particularly in the quoted triggers, escaping square brackets. I have tried to fix them.


Magnum, take the plugin (copy it), paste it into a blank MUSHclient notepad window, select "Quote Forum Codes" - that will fix all backslashes and square brackets. Then post it. You should always do that when posting code snippets with backslashes and/or square brackets, AND you are using Forum Codes.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Neverwhere   USA  (40 posts)  Bio
Date Reply #23 on Tue 01 Jul 2003 02:28 AM (UTC)
Message
well, i use '+10' in place of '10' because there are numerous idiots on my mud :)

and your right, it is redundant, ill remove that part.

Thanks for your code Flannel, it works fine.

ChaosMUD: chaosmud.org:23
Always looking for new players/coders. Willing to train if your willing to lear. Contact Neverwhere or just mention that I sent you.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


74,311 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.