• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

Question - Can I call a :Block and return nothing?

Bytebait

Member
Joined
Jan 21, 2023
RedCents
230¢
How can I return nothing? (( I'm sorry, I don't know what to call these little blocks of code :ThisBlock . )) I took QBasic 45 years ago and dont remember. Anyhow, how can call a block , but if nothing needs to be done then the initial block will carry on? Unless this is failing because of something else? Thank you guys!

[CODE title="example"]
Sub Main
:Start
/goto :Do_I_Need_To_Do_Something
/delay 5s
/goto :Start


:Do_I_Need_To_Do_Something
/declare mobcount = ${Me.XTarget}
/echo Mobcount is ${mobcount}

/if (mobcount > 0){
/emote Time to get our hands dirty
}else{
/echo yeah... do nothing.
}


[/CODE]
 
Solution
Well the basics of a macro function is

Code:
Sub NameOfSub
    |Body of Code here
/return

If you don't have a return, then the function will never return to where it was.
In the case of Sub main a return will end the macro. Failure to return would result in an error. So technically speaking you can, but it results in an error.

With that said.
:Start
:Do_I_Need_To_Do_Something are both /goto tags. None of those are reasonable to use here. You should use a function, and you should use while loops. goto is not the "correct" way to do just about anything ever.

Code:
Sub Main
    /declare mobCount int outer 0
    /while (1) {
        /call DoINeedToDoSomething
        /delay 5s
    }
/return

Sub DoINeedToDoSomething
    /varset...
Well the basics of a macro function is

Code:
Sub NameOfSub
    |Body of Code here
/return

If you don't have a return, then the function will never return to where it was.
In the case of Sub main a return will end the macro. Failure to return would result in an error. So technically speaking you can, but it results in an error.

With that said.
:Start
:Do_I_Need_To_Do_Something are both /goto tags. None of those are reasonable to use here. You should use a function, and you should use while loops. goto is not the "correct" way to do just about anything ever.

Code:
Sub Main
    /declare mobCount int outer 0
    /while (1) {
        /call DoINeedToDoSomething
        /delay 5s
    }
/return

Sub DoINeedToDoSomething
    /varset mobCount ${Me.XTarget}
    /echo mobcount is ${mobCount}
    
    if (${mobCount} > 0) {
        /emote Time to get our hands dirty
    } else {
        /echo yeah... do nothing.
    }
/return

Now that I've hastily written an example of what it would look like done differently. I suggest considering investing time into learning Lua instead of macro language. I'm sure others will chime in with the same sentiment.
 
Solution
Question - Can I call a :Block and return nothing?

Users who are viewing this thread

Back
Top
Cart