edubart / otclient

An alternative tibia client for otserv written in C++11 and Lua, made with a modular system that uses lua scripts for ingame interface and functionality, making otclient flexible and easy to customize
Other
652 stars 399 forks source link

Make outputMessage::addRawString available in Lua #1218

Closed divinity76 closed 2 months ago

divinity76 commented 2 months ago

Why write

msg:addU8(1);
msg:addU8(0);
msg:addU8(113);

when you can instead write

msg:addRawString("\x01\x00\x71");

? Would make some lua scripts much easier to write :)

diath commented 2 months ago

Sure, I've also personally had some use for such functionality in the past.

divinity76 commented 2 months ago

@diath porting BlackD Proxy scripts like

# your open bp #1 must be your main bp. open bp #2 must be your manarune bp.
# set _i to how many you want to buy.
fastExiva _i=20
:startcount
sayMessage exura "{$_i$}
sayMessage exura "bp manarune
#move bbp from container #1 pos #2 to container #2 pos #1:
fastExiva >>0F 00 78 FF FF 40 00 01 38 0B 01 FF FF 41 00 00 01 
#open bbp from container #2 pos #1:
fastExiva >>0A 00 82 FF FF 41 00 00 38 0B 00 01 
#move manarune from container #2 pos #1 to container #1 pos #1
#fastExiva >>0F 00 78 FF FF 41 00 00 81 0C 00 FF FF 40 00 00 01 
#move manarune from container #2 spot #1 to floor under yourself
fastExiva >>0F 00 78 FF FF 41 00 00 81 0C 00 E6 03 6D 04 07 01 
:dev2
:dev
#gotoScriptLine $nlineoflabel:dev$
fastExiva _i={$numericalexp:{$_i$}-1$}
IfTrue ($_i$#number>#0) Goto $nlineoflabel:startcount$
gotoScriptLine 9999

to otclient is not fun without it! xD becomes stuff like

    local msg = OutputMessage.create()
    msg:addU8(15)
    msg:addU8(0)
    msg:addU8(120)
    msg:addU8(255)
    msg:addU8(255)
    msg:addU8(65)
    msg:addU8(0)
    msg:addU8(0)
    msg:addU8(129)
    msg:addU8(12)
    msg:addU8(0)
    msg:addU8(230)
    msg:addU8(3)
    msg:addU8(109)
    msg:addU8(4)
    msg:addU8(7)
    msg:addU8(1)
    g_game.getProtocolGame().send(msg)

instead of

    local msg = OutputMessage.create()
    msg:addRawString("\x0F\x00\x78\xFF\xFF\x41\x00\x00\x81\x0C\x00\xE6\x03\x6D\x04\x07\x01")
    g_game.getProtocolGame().send(msg)