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.
 Entire forum ➜ MUSHclient ➜ Lua ➜ Trouble With My Script

Trouble With My Script

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


Posted by Dawastedpanda   (14 posts)  Bio
Date Fri 23 Apr 2021 05:35 PM (UTC)

Amended on Fri 23 Apr 2021 05:40 PM (UTC) by Dawastedpanda

Message

<!--   Script    --> 
<script>
<![CDATA[ 
	require "tprint"
	require "commas"
	require "serialize"
	require "copytable"
	
	currentPowerlevel = 0
	currentFatigue = 0
	currentKi = 0
	kiRestoreLevel = 0
	plRestoreLevel = 0
	fatigueRestoreLevel = 0
	attackType = ""
	currentAttack = ""
	mobTarget = ""
	healItem = ""
	waterContainer = ""
	willDevour = ""
	willDrink = ""
	kiLevel = 0
	plLevel = 0
	fatigueLevel = 0
	
	
	function fightTriggerOn()
		EnableTriggerGroup ("autoFarm", true)
	end
	
	function fightTriggerOff()
		EnableTriggerGroup ("autoFarm", false)
	end
	
	function timerzOff()
		EnableTimerGroup ("Timerz", false)
	end
	
	function timerzOn()
		EnableTimerGroup ("Timerz", true)
	end -- TimerzOn
	
	
	
	function watchPrompt(name, list, args)
		kilevel = string.gsub (args [2], ",", "")
		currentKi = tonumber(kilevel) + currentKi
		plLevel = string.gsub (args [1], ",", "")
		currentPowerlevel = tonumber(plLevel) + currentPowerlevel
		fatigueLevel = string.gsub (args [4], ",", "")
		currentFatigue = tonumber(fatigueLevel) + currentFatigue
	end -- watchPrompt
	

	function setFleePowerlevel(name, list, args)
		plRestoreLevel = args[1]
	end -- setFleePowerlevel
	
	function setFleeKiLevel(name, list, args)
		kiRestoreLevel = args[1]
	end -- setFleeKiLevel
	
	function setFleeFatigueLevel(name, list, args)
		mobTarget = args[1]
	end -- setTarget
	
	function healUp()
		if (currentPowerlevel =< plRestoreLevel) then
			fightTriggerOff()
			timerzOff()
			healTriggerOn()
		end -- if statement
	end -- healUp
	
	function fatigueUp()
		if (currentFatigue >= fatigueRestoreLevel) then
			fightTriggerOff()
			timerzOff()
			fatigueTriggerOn()
		end -- if statement
	end -- fatigueUp
	
	function kiUp()
		if (currentKi =< kiRestoreLevel) then
			fightTriggerOff()
			timerzOff()
			kiTriggerOn()
		end -- if statement
	end -- kiUp

	function attackOnce()
		Send(currentAttack .. mobTarget)
		Send("sense" .. mobTarget)
	end -- attackOnce
	
	function setTarget(name, list, args)
		mobTarget = args[1]
	end -- setTarget
	
	function setAttack(name, list, args)
		currentAttack = args[1]
	end -- setAttack
	
	function setHealItem(name, list, args)
		healItem = args[1]
	end -- setHealItem
	
	function setWaterType(name, list, args)
		waterContainer = args[1]
		willDrink = true
	end -- setWaterType
	
	function senseMobTarget()
		Send("sense ".. mobTarget)
	end -- senseMobTarget
	
	function setDevourOn()
		willDevour = true
	end -- willDevour
	
	function afterDeath()
		if willDevour == "true" then
			Send("--")
			Send("get all all")
			Send("Get Namek")
			Send("Get Corpse")
		else
			Send("--")
			Send("get all all")
			Send("Get Namek")
		end -- if statement
	end -- afterDeath
	
	function fatigueTriggerOn()
		if willDevour == "true" then
			Send("--")
			Send("flee")
			Send("devour corpse")
			Send("devour corpse")
			Send("devour corpse")
			Send("devour corpse")
			Send("devour corpse")
			Send("devour corpse")
			Send("devour corpse")
			Send("devour corpse")
			Send("devour corpse")
			Send("devour corpse")
			fightTriggerOn()
		elseif willDrink == "true" then
			Send("drink" .. waterContainer)
			Send("drink" .. waterContainer)
			Send("drink" .. waterContainer)
			Send("drink" .. waterContainer)
			Send("drink" .. waterContainer)
			Send("drink" .. waterContainer)
			Send("drink" .. waterContainer)
			Send("drink" .. waterContainer)
			Send("drink" .. waterContainer)
			Send("drink" .. waterContainer)
		else
			Send("Camp")
			Send("Sleep")
		end -- if statement
	end -- fatigueTriggerOn
	
	function healTriggerOn()
		Send("--")
		Send("flee")
		Send("swallow Senzu")
		fightTriggerOn()
	end
  ]]> 
  </script>
</muclient>
Top

Posted by Dawastedpanda   (14 posts)  Bio
Date Reply #1 on Fri 23 Apr 2021 05:36 PM (UTC)
Message
Compile error
Plugin: AutoFarmer (called from world: DBE)
Immediate execution
[string "Plugin: AutoFarmer"]:216: ')' expected near '='
[WARNING] C:\Users\RAC\Downloads\LotjClient-master\LotjClient-master\worlds\plugins\AutoFarmerV1.xml
Line 82: Error parsing script (Cannot load)
Top

Posted by Nick Gammon   Australia  (23,101 posts)  Bio   Forum Administrator
Date Reply #2 on Fri 23 Apr 2021 08:14 PM (UTC)

Amended on Fri 23 Apr 2021 08:17 PM (UTC) by Nick Gammon

Message
Quote:


 Line 82: Error parsing script (Cannot load)



In line 82 of your script (counting from the first line which has require "tprint" in it) you have:


  if (currentKi =< kiRestoreLevel) then


That is not a valid comparison. It should be:


  if (currentKi <= kiRestoreLevel) then


You have the same problem in the healUp function.

- Nick Gammon

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

Posted by Dawastedpanda   (14 posts)  Bio
Date Reply #3 on Sat 24 Apr 2021 12:49 PM (UTC)
Message
Thank you that fixed my issue. Now I have another small one. Sorry for the simple questions, I'm still learning.

function attackOnce()
Send(currentAttack .. mobTarget)
end -- attackOnce

That is a function of mine. It's taking the variable currentAttack and using it against the mobTarget. My problem is that it's lumping them together. How do I get a space inbetween. It's coming out as.

BlastDragon instead of Blast Dragon
Top

Posted by Nick Gammon   Australia  (23,101 posts)  Bio   Forum Administrator
Date Reply #4 on Sat 24 Apr 2021 08:04 PM (UTC)
Message

 Send(currentAttack .. " " .. mobTarget)


Or:


 Send(currentAttack, " ", mobTarget)



Template:function=Send Send

The documentation for the Send script function is available online. It is also in the MUSHclient help file.


- Nick Gammon

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

Posted by Dawastedpanda   (14 posts)  Bio
Date Reply #5 on Mon 26 Apr 2021 03:30 AM (UTC)
Message
I'm sorry for all the questions. I'm having another problem with a part in this script.


	function watchPrompt(name, list, args)
		kilevel = string.gsub (args [2], ",", "")
		currentKi = tonumber(kilevel) + currentKi
		plLevel = string.gsub (args [1], ",", "")
		currentPowerlevel = tonumber(plLevel) + currentPowerlevel
		fatiguelevel = string.gsub (args [4], ",", "")
		currentFatigue = tonumber(fatigueLevel) + currentFatigue
		if (currentPowerlevel <= plRestoreLevel) then
			ColourNote("yellow","", "Powerlevel Low. Fleeing to heal.")
			fightTriggerOff()
			timerzOff()
			healTriggerOn()
		elseif (currentFatigue >= fatigueRestoreLevel) then
			ColourNote("yellow","", "Fatigue High. Fleeing to restore.")
			fightTriggerOff()
			timerzOff()
			fatigueTriggerOn()
		elseif (currentKi <= kiRestoreLevel) then
			ColourNote("yellow","", "Ki is low. Fleeing to restore.")
			fightTriggerOff()
			timerzOff()
			kiTriggerOn()
		else
			fightTriggerOn()
			timerzOn()
		return
		end --if statement
	end -- watchPrompt
Top

Posted by Dawastedpanda   (14 posts)  Bio
Date Reply #6 on Mon 26 Apr 2021 03:32 AM (UTC)

Amended on Mon 26 Apr 2021 03:33 AM (UTC) by Dawastedpanda

Message
This is the trigger that's calling that bit of script. The problem is it's not accurately monitoring the prompt and firing off the functions.

 	<trigger name= "monitorPrompt" match= "[Pl:*%][Ki:*%][*% EXP][Fatigue: *%]*"            group= "Monitor" script= "watchPrompt" enabled= "y" regexp= "n" sequence= "100"/> 
Top

Posted by Nick Gammon   Australia  (23,101 posts)  Bio   Forum Administrator
Date Reply #7 on Mon 26 Apr 2021 05:00 AM (UTC)
Message
It's hard to say without see samples of the prompts that are not working.

- Nick Gammon

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

Posted by Dawastedpanda   (14 posts)  Bio
Date Reply #8 on Mon 26 Apr 2021 11:28 PM (UTC)

Amended on Tue 27 Apr 2021 07:40 PM (UTC) by Nick Gammon

Message
[Pl:11,666,557][Ki:8,504,392][86% EXP][Fatigue: 0%][HT][FM]


This is an example of the prompt. I want it store variables for curentPowerlevel, CurrentKi and CurentFatigue. It should compare those variables to another variable that gets set by the user like 1,500,000.
Top

Posted by Nick Gammon   Australia  (23,101 posts)  Bio   Forum Administrator
Date Reply #9 on Sat 01 May 2021 01:14 AM (UTC)
Message
Do you mean it is doing it sometimes or not at all?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


19,462 views.

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.