Help - Search - Members - Calendar
Full Version: String to Variable?
AC Tools Everything Macro > AC Tool Macros > Macro Development
Bear
I'm trying to Generalize some Repeating Code and it Does work except that the End result is being treated as a Statement(String) instead of a Variable Holder.

Here's the Code before Generalization:
CODE

Constants
Tool_Dur_1 = 50 // Tool #1 Durability
Tool_Slot_1 = 6
//
Tool_Dur_2 = 25 // Tool #2 Durability
Tool_Slot_2 = 7
//
Tool_Dur_3 = 35 // Tool #3 Durability
Tool_Slot_3 = 8
//
Tool_Dur_X =
//
Tools = 3 // Using 3 Tools
Tool_S = 1 // Start with Tool 1
End

Procedure Check_Tool
IF $Tool_S = 1
IF $Tool_Dur_1 >= 2
// I saw somewhere that people wanted to stop before Breaking the Tool
Compute Tool_Dur_X = $Tool_Dur_1 - 1
Set Tool_X,6
Call Harvest $Tool_Dur_X
Call Rest $Tool_X
End
End

IF $Tool_S = 2
IF $Tool_Dur_2 >= 2
// I saw somewhere that people wanted to stop before Breaking the Tool
Compute Tool_Dur_X = $Tool_Dur_2 - 1
Set Tool_X,7
Call Harvest $Tool_Dur_X
Call Rest $Tool_X
End
Inc Tool_S
Exit
End

IF $Tool_S = 3
IF $Tool_Dur_3 >= 2
// I saw somewhere that people wanted to stop before Breaking the Tool
Compute Tool_Dur_X = $Tool_Dur_3 - 1
Set Tool_X,8
Call Harvest $Tool_Dur_X
Call Rest $Tool_X
End
Inc Tool_S
Exit
End

IF $Tool_S > $Tools
Timestamp We're Out of Tools
STOP
End
End

Call Check_Tool


Here's the Code as I'm trying to Generalize:
I can Get "CT_Var1" to equal a String of "Tool_Dur_1" but I was Aiming For "CT_Var1" to equal the Value of "Tool_Dur_1" in this case a value of 50. Any Idea's?
CODE

Constants
Tool_Dur_1 = 50 // Tool #1 Durability
Tool_Slot_1 = 6
//
Tool_Dur_2 = 25 // Tool #2 Durability
Tool_Slot_2 = 7
//
Tool_Dur_3 = 35 // Tool #3 Durability
Tool_Slot_3 = 8
//
Tool_Dur_X =
//
Tools = 3 // Using 3 Tools
Tool_S = 1 // Start with Tool 1
//
CT_Var1 = {NULL}
CT_Var2 = {NULL}
Dollar = $
End

Procedure Check_Tool Using Tool_Num
TimeStamp Tool # ( $Tool_Num ), Check Tool Var 1 ( $CT_Var1 ), Check Tool Var 2 ( $CT_Var2 )
Set CT_Var1 = $Dollar
TimeStamp Tool # ( $Tool_Num ), Check Tool Var 1 ( $CT_Var1 ), Check Tool Var 2 ( $CT_Var2 )
Set CT_Var1 = $CT_Var1 + Tool_Dur_
TimeStamp Tool # ( $Tool_Num ), Check Tool Var 1 ( $CT_Var1 ), Check Tool Var 2 ( $CT_Var2 )
Set CT_Var1 = $CT_Var1 + $Tool_Num
TimeStamp Tool # ( $Tool_Num ), Check Tool Var 1 ( $CT_Var1 ), Check Tool Var 2 ( $CT_Var2 )
Compute CT_Var1 = $CT_Var1
TimeStamp Tool # ( $Tool_Num ), Check Tool Var 1 ( $CT_Var1 ), Check Tool Var 2 ( $CT_Var2 )

//IF $Tool_S = 1
//IF $Tool_Dur_1 >= 2
IF $CT_Var1 >= 2
// I saw somewhere that people wanted to stop before Breaking the Tool
//Compute Tool_Dur_X = $Tool_Dur_1 - 1
Compute Tool_Dur_X = $CT_Var1 - 1
Set CT_Var2 = $Dollar
TimeStamp Tool # ( $Tool_Num ), Check Tool Var 1 ( $CT_Var1 ), Check Tool Var 2 ( $CT_Var2 )
Set CT_Var2 = $CT_Var2 + Tool_Slot_
TimeStamp Tool # ( $Tool_Num ), Check Tool Var 1 ( $CT_Var1 ), Check Tool Var 2 ( $CT_Var2 )
Set CT_Var2 = $CT_Var2 + $Tool_Num
TimeStamp Tool # ( $Tool_Num ), Check Tool Var 1 ( $CT_Var1 ), Check Tool Var 2 ( $CT_Var2 )
Set Tool_X,$CT_Var2
Call Harvest $Tool_Dur_X
Call Rest $Tool_X
End
End

Call Check_Tool 1
Timestamp Did Tool 1 pass?
Call Check_Tool 2
Call Check_Tool 3
Stop
Ahk
I would suggest using a dataset to store the tools and their durability, that way you can just look up the tools values.

I was unable in to get this to work at my first couple of attempts here, and have spent a decent enough amount of time trying at it -- I'm sure given more time maybe it's doable, but dataset would be the way to go.

I'd write it up for you but I'm out of time. There is a Dataset Primer (tutorial) shortcut under help if you've never used them before.

I would use 3 fields: ToolNum, Durability, and Slot as Integers.

Bear
QUOTE(Ahk @ Mar 4 2009, 08:47 PM) *
I would suggest using a dataset to store the tools and their durability, that way you can just look up the tools values.

I would use 3 fields: ToolNum, Durability, and Slot as Integers.

Ah, ok. Thanks. Been awhile since I used Datasets.. The ACTool Version of TradeBot was the Last time. heh
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.