BBot - The best bot of the world
String variables in Macros? - Printable Version

+- BBot - The best bot of the world (https://forums.bmega.net)
+-- Forum: BBot (https://forums.bmega.net/forum-3.html)
+--- Forum: News (https://forums.bmega.net/forum-14.html)
+--- Thread: String variables in Macros? (/thread-20903.html)



String variables in Macros? - MegaNo0body - 08-15-2018

Just wondering... Let's suppose...
What if we could use string in macros?
What if we had even a simple API, like the following one?
Could it make possible to bring new features to BBot? (yey Cassino, AutoResponder..., some NPC quest? maybe POI with fucking bureaucrats?)

Quote:Comment(String Assignation)

Str.Set(A, Hello)
Str.Set(B, World)
Str.Set(C, hello)
Str.Set(Message, !A !B)

Comment(String Comparision)

Str.Equals(A, B)==:False
Str.Equals(A, C)==:True
Str.EqualsSensitive(A, C)==:False

Comment(String Manipulation)

Str.Upper(A)
Str.Lower(A)

Comment(String Regex Pattern Matching)

Str.Set(Text, You have 12345 gold pieces.)
Str.Set(MoneyPattern, You have (\d+) gold pieces.)
Str.Regex(MoneyPattern, Text)==:True
!Str.MatchSucced==:True
!Str.MatchFailed==:False
Str.Equals(Str.Match.1, 12345)

Str.Set(NoMatch, What the hell)
Str.Regex(MoneyPattern, NoMatch)==:False

Comment(LOOL BBot has String support in macros)
Comment(This is actual API and this is a valid macro hehe)

had we have this simple STR API.. we could extend some functionalities like "Event/Listener/When/Handlers":

Quote:Comment(NOTICE the following API is not final and may change before the final release)
Comment(Message Handling with When handlers)
Messages.whenAny(whenLabel, messageRegexPatternString)
Messages.whenSystem(whenServerSave, "Server will shutdown.*")
Messages.whenAny(whenLow, "low")
Messages.whenAny(whenHigh, "high")
Messages.whenSay(whenDeposit, "deposit (\d+)")
Messages.whenSpell(whenExori, "exori")
Messages.whenSpell(whenSio, "exura sio")
Messages.whenSpell(whenSummon, "utevo res")
Exit()

{whenLow}
Self.Say(Someone said LOW)
Exit()

{whenHigh}
Self.Say(Someone said HIGH)
Exit()

{whenDeposit}
Self.Say(!Message.Sender.Name said DEPOSIT with !Message.Group.0)
Exit()

{whenSio}
Comment(Combo SIO!)
Self.Say(exura sio "!Message.Spell.Param)
Exit()

Comment(Additional Variables)
!Message.IsSystem :true | :false
!Message.IsPositional :true | :false
!Message.IsSpell :true | :false
!Message.Kind Confusedystem | :positional | :creature | Confuseday | Confusedpell

!Message.Sender.Name
!Message.Sender.ID

!Message.Text

!Message.Spell.Name
!Message.Spell.Param

Regex Group
!Message.Group.0
!Message.Group.1
!Message.Group.2
!Message.Group.3
!Message.Group.4

!Message.Pos.X
!Message.Pos.Y

Now that we also could have a 'When' event system using macros, we could extend it to other advanced features:

Quote:CreatureData = !Creature.ID, !Creature.Name
ContainerData = !Container.ID

Creatures.whenEnterScreen(LabelName) -> CreatureData
Creatures.whenLeaveScreen(LabelName) -> CreatureData
Creatures.whenSkull(LabelName) -> CreatureData
Creatures.whenParty(LabelName) -> CreatureData
Creatures.whenWalk(LabelName) -> CreatureData

Containers.whenOpen(LabelName) -> ContainerData
Containers.whenClosed(LabelName) -> ContainerData

String Handling? Why not... packet handling? Big Grin
Str.ToHex(MsgAsHex, Hello World)
Misc.SendPacket(0x12 0xF2 !Self.Equip.LeftHand.ID 1 !MsgAsHex)

By the way, what is the best name for Messages handling macros?
  • Messages.handleSay
  • Messages.onSay
  • Messages.whenSay

Leave your vote!


RE: String variables in Macros? - Nvp - 08-15-2018

Casino with auto inviter Wink


RE: String variables in Macros? - Catar - 08-15-2018

WhenSay will be better understood imo