Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make outputMessage::addRawString available in Lua #93

Closed
wants to merge 1 commit into from

Conversation

divinity76
Copy link

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 :)

Why write
msg:addU8(1);
msg:addU8(0);
msg:addU8(171);

when you can instead write
msg:addRawString("\x01\x00\x71");
? Would make some lua scripts much easier to write :)
@Oen44
Copy link
Collaborator

Oen44 commented Sep 13, 2024

Ignoring the fact that this repo is no longer maintained... This is in no way better.

@divinity76
Copy link
Author

@Oen44 in your opinion, is this code:

msg:addRawString("\x0A\x00\x82\xFF\xFF\x41\x00\x00\x26\x0B\x00\x01");

better or worse than this code:

msg:addU8(10)
msg:addU8(0)
msg:addU8(130)
msg:addU8(255)
msg:addU8(255)
msg:addU8(65)
msg:addU8(0)
msg:addU8(0)
msg:addU8(38)
msg:addU8(11)
msg:addU8(0)
msg:addU8(1)

?

@Oen44
Copy link
Collaborator

Oen44 commented Sep 13, 2024

Worse.
Why? Because how someone else that reads this code is supposed to know if you are sending bunch of 1-bytes or mixed with 2 or 4 bytes (u16, u32 etc.)? Not to mention it would be much harder to compare with the server side when you actually want to read these bytes.
Also your example is not even a real use case example. No one hardcodes that many numbers in a sequence.

@divinity76
Copy link
Author

@Oen44 explain what it does with comments.

Sometimes I record that the client sends a specific packet on a quest, don't have access to the server source code, don't know if it's actually comprised of U8 or U16's or U32's, don't really care, just know that on this specific part of the script, i need to send the exact packet \x0A\x00\x82\xFF\xFF\x41\x00\x00\x26\x0B\x00\x01 to proceed... and today that is very cubersome. if outputMessage::addRawString was available, it would be very easy.

@divinity76
Copy link
Author

divinity76 commented Sep 13, 2024

Also your example is not even a real use case example. No one hardcodes that many numbers in a sequence.

Bullshit. Here is a BlackD Proxy script to buy manarunes and stack them on http://tibiafunevo.zapto.org :

# 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
#</bbp_version>

@Oen44
Copy link
Collaborator

Oen44 commented Sep 13, 2024

Ah, you are here for botting, well, good luck!

@Oen44 Oen44 closed this Sep 13, 2024
@divinity76
Copy link
Author

divinity76 commented Sep 13, 2024

@Oen44 but do you see how difficult it is to port the blackd proxy script

fastExiva >>0F 00 78 FF FF 41 00 00 81 0C 00 E6 03 6D 04 07 01 

to otcv8? the otcv8 equivalent is literally:

    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)

if we make outputMessage::addRawString() available, it would be trivial to port:

    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)

@divinity76
Copy link
Author

divinity76 commented Sep 14, 2024

If OTCv8 wish to maintain scripting compatibility with edubart/otclient, this should be merged.

OutputMessage:addRawString has just been added to edubart/otclient, see edubart/otclient#1218 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants