And I'm back! With another, probably easy, question.
So I have a static prompt. Meaning that it stays in one place unless I hit enter, or something from the server is sent my way.
What I would like to do is have it, if possible, to move my prompt without flooding me full of Prompt lines. I know deleteFull() will work for removing the prompt lines, but how would you's suggest I go about having it so that it actually fires the prompt without the aforementioned things happening?
I don't want to have to go through every trigger line and setup a variable so that the system does an if statement within the prompt seeing if it just double fired then deleting the second prompt.... Is there an easier way? Or is this a road that plenty of people have gone down and thus there isn't much to do but have something like a timer tick once in a while?
I remember an old Mudlet system, think back when Kaeus was first building his, that wouldn't have double prompts and the like. It would always have one prompt between all lines that appeared. Was this just a fluke? Or is there a way to do that?
Thanks!
'Those that do not attempt are those with the least stories to tell.'
Why are you getting double prompts? Are you gagging lines of text, and that is why you're getting prompts? If so, it's simple enough to gag line+prompt rather than just the line.
If it happens all the time regardless, I suspect there is a preference setting to do with telnet protocols etc which you need to check/uncheck.
You can send a blank line on a recurring timer, which will prompt a prompt. If this is with mudlet, you could then gag the previous line upon the arrival of the new prompt, though getting the code for this right is a bit finicky.
I hate playing around with moveCursor(), as it, for some reason, never seems to work the way I plan so it winds up involving a lot of trial and error - so I'm not going to write it for you. Still, here is a list of mudlet functions you'll need, and you can find examples on how to use them in the mudlet wiki. FYI, in mudlet you can move the cursor anywhere in the scrollback, and gag, echo, whatever, anywhere you like. It's just a bit awkward to do it as the reference point is always the current line, which obviously changes - a lot.
getLineCount()
moveCursor() selectLine() (tbh, don't quite remember if this is a func or not, you may need selectString(line,1) or similar)
check selection (is it a prompt?)
deleteLine() (or you may need to use replace() for this one, can't recall)
Still trying to grasp Tables properly. I'm working with gmcp.Room.players and trying to put the names in there into a table within Mudlet so it will then echo back who's all there on a side window.
But so far all I'm successfully doing is copying exact what is under gmcp.Room.players:
{
{
name = "Jensen",
fullname = "Lion Jensen Starion, the Cannibal Cook"
},
{
name = "Daegon",
fullname = "Daegon"
}
}
Is what I'm getting. Anytime I try to echo it back it gives me nothing, or simply the number of 'variables' or names within the new variable. So how do I get it to recognize only the names and only display them?
'Those that do not attempt are those with the least stories to tell.'
You can send a blank line on a recurring timer, which will prompt a prompt. If this is with mudlet, you could then gag the previous line upon the arrival of the new prompt, though getting the code for this right is a bit finicky.
I hate playing around with moveCursor(), as it, for some reason, never seems to work the way I plan so it winds up involving a lot of trial and error - so I'm not going to write it for you. Still, here is a list of mudlet functions you'll need, and you can find examples on how to use them in the mudlet wiki. FYI, in mudlet you can move the cursor anywhere in the scrollback, and gag, echo, whatever, anywhere you like. It's just a bit awkward to do it as the reference point is always the current line, which obviously changes - a lot.
getLineCount()
moveCursor() selectLine() (tbh, don't quite remember if this is a func or not, you may need selectString(line,1) or similar)
check selection (is it a prompt?)
deleteLine() (or you may need to use replace() for this one, can't recall)
moveCursorEnd("main")
Just want to say thanks for this. Finally got a around to messing with it and have a working script for this. It was a pain in the arse, but we got'r working.
'Those that do not attempt are those with the least stories to tell.'
so I'm trying to make a 'highligher' system for my enemies, so far I have
function addEnemy(name)
name = name:title()
table.insert(mayhem.list.enemies, name)
cecho("<red>" .. name .. " <white>has been added as an enemy")
end
I've never messed with color coding and what I keep doing keeps messing up and sending EVERYthing that color.. So I am wondering if any of you would be able to advise me on a way to make ^ color the name?
@Irruel That's what I been trying to get to work but it wont work!
As I dont just want to use it for 'enemies' No Worries I'll keep looking around
Said script doesnt delete the color once its added and you remove, you can only set 1 color so everyone allies/friends/citymembers/enemies etc etc will all be the same color...
@azton I feel as though string.format() ought to be able to offer a simpler solution for this, but I've never bothered to learn how to use it. So!
The following is a bit rough; I made it up as I went. But it seems to work, so...
function test3( c1, c2, pos )
local pos = pos or 15
if string.len(c1) < pos then
local diff = pos - string.len(c1)
local spaces = string.rep( " ", diff )
c1 = c1 .. spaces
end
send("\n" .. c1 .. c2 .. "\n")
end
Edit: I seem to have screwed up the code tag thing.
@azton I feel as though string.format() ought to be able to offer a simpler solution for this, but I've never bothered to learn how to use it. So!
The following is a bit rough; I made it up as I went. But it seems to work, so...
function test3( c1, c2, pos )
local pos = pos or 15
if string.len(c1) < pos then
local diff = pos - string.len(c1)
local spaces = string.rep( " ", diff )
c1 = c1 .. spaces
end
send("\n" .. c1 .. c2 .. "\n")
end
Edit: I seem to have screwed up the code tag thing.
echo("\nattwin_click fires with: <" .. m .. ">\n")
echo(type(m))
if m == "off" then echo(hello) end
end
This is what is displayed/echoed when the function is run with an argument of "off". I have tried calling the function both with the intended click of a label, and directly from script. The result is the same:
attwin_click fires with: <off> string
Why won't the if statement evaluate true, when the echoes clearly prove that m is a string with a value of 'off'?
It's erroring when it hits echo(hello), most likely. Unless you have a defined variable named hello, you're going to want to switch that to echo("hello")
I cannot figure this out and it's driving me nuts.
[blockquote]
company = {"list", "Lyl", "Ezalor"}
for k,v in pairs(company) do
if (v ~= "list") then
list = "v, "
end
end
[/blockquote]
For some reason list is cropping up nil when I go to print it or call it. And I don't understand why... In hind sight, I'd expect the code to at the very least show me: company.list = "Ezalor, "
Ultimately what I want is to do this:
Send ("wt @Target is at " .. location .. " with " .. company.list)
x_x I must be way off or something.
Edit:
When I do this:
for k, v in pairs(company) do
print (k, v, i)
end
I get this result:
1 list nil
2 Lyl nil
3 Ezalor nil
¤ Si vis pacem, para bellum. ¤
Someone powerful says, "We're going to have to delete you."
This won't work because you're using an indexed list, which is to say that it's just a series of values, rather than a key/value pair. So first off, you should be using the ipairs() function, not pairs().
In line #4, when you're setting the value of list, you're setting a global variable called list. Unfortunately, you're also setting it improperly. If you fix the pairs() issue and then do display(list), it will probably have a value of "v, ". company.list isn't changing because you never do anything with it.
list = "v, " --> company.list = v .. ", "
Now, the last problem is that this won't work anyway, because list -technically- isn't defined. What you have is a string at index [1], whose value is "list". The table you had set up initially actually looks like this:
company = {
[1] = "list",
[2] = "Lyl",
[3] = "Ezalor"
}
As has been mentioned so far, the table structure itself could use a little work. Try this, instead:
company = {"Lyl", "Ezalor"}
company.list = {}
for _, name in ipairs(company) do
-- We only care about the value in this script.
-- Instead of "v", let's name it "name" to make it easy to identify.
if name ~= "Omei" then
-- Just an example to show filtering.
-- Set an index equal to the current size of company.list + 1
-- If the list is empty, the index is 1.
-- The value of this index will be the name pulled from company.
company.list[#company.list + 1] = name
end
end
This is still a little unwieldy - I don't personally like mixing up the sorts of things I put in tables, for instance, and would make company.list its own separate table. But hopefully it shows you how to fix up your code!
With this method, you would then do:
Send("wt Haven is in Nirvana. \(Company: " .. table.concat(company.list, ", ") .. "\)")
Edit: Whoops, guess I was ninja'd something fierce. Oh well.
This won't work because you're using an indexed list, which is to say that it's just a series of values, rather than a key/value pair. So first off, you should be using the ipairs() function, not pairs().
In line #4, when you're setting the value of list, you're setting a global variable called list. Unfortunately, you're also setting it improperly. If you fix the pairs() issue and then do display(list), it will probably have a value of "v, ". company.list isn't changing because you never do anything with it.
list = "v, " --> company.list = v .. ", "
Now, the last problem is that this won't work anyway, because list -technically- isn't defined. What you have is a string at index [1], whose value is "list". The table you had set up initially actually looks like this:
company = {
[1] = "list",
[2] = "Lyl",
[3] = "Ezalor"
}
As has been mentioned so far, the table structure itself could use a little work. Try this, instead:
company = {"Lyl", "Ezalor"}
company.list = {}
for _, name in ipairs(company) do
-- We only care about the value in this script.
-- Instead of "v", let's name it "name" to make it easy to identify.
if name ~= "Omei" then
-- Just an example to show filtering.
-- Set an index equal to the current size of company.list + 1
-- If the list is empty, the index is 1.
-- The value of this index will be the name pulled from company.
company.list[#company.list + 1] = name
end
end
This is still a little unwieldy - I don't personally like mixing up the sorts of things I put in tables, for instance, and would make company.list its own separate table. But hopefully it shows you how to fix up your code!
With this method, you would then do:
Send("wt Haven is in Nirvana. \(Company: " .. table.concat(company.list, ", ") .. "\)")
Edit: Whoops, guess I was ninja'd something fierce. Oh well.
That was quite an excellent explanation regardless. Always prefer to teach rather than solve (when time permits).
Comments
And I'm back! With another, probably easy, question.
So I have a static prompt. Meaning that it stays in one place unless I hit enter, or something from the server is sent my way.
What I would like to do is have it, if possible, to move my prompt without flooding me full of Prompt lines. I know deleteFull() will work for removing the prompt lines, but how would you's suggest I go about having it so that it actually fires the prompt without the aforementioned things happening?
I don't want to have to go through every trigger line and setup a variable so that the system does an if statement within the prompt seeing if it just double fired then deleting the second prompt.... Is there an easier way? Or is this a road that plenty of people have gone down and thus there isn't much to do but have something like a timer tick once in a while?
I remember an old Mudlet system, think back when Kaeus was first building his, that wouldn't have double prompts and the like. It would always have one prompt between all lines that appeared. Was this just a fluke? Or is there a way to do that?
Thanks!
If it happens all the time regardless, I suspect there is a preference setting to do with telnet protocols etc which you need to check/uncheck.
I hate playing around with moveCursor(), as it, for some reason, never seems to work the way I plan so it winds up involving a lot of trial and error - so I'm not going to write it for you. Still, here is a list of mudlet functions you'll need, and you can find examples on how to use them in the mudlet wiki. FYI, in mudlet you can move the cursor anywhere in the scrollback, and gag, echo, whatever, anywhere you like. It's just a bit awkward to do it as the reference point is always the current line, which obviously changes - a lot.
getLineCount()
moveCursor()selectLine() (tbh, don't quite remember if this is a func or not, you may need selectString(line,1) or similar)
check selection (is it a prompt?)
deleteLine() (or you may need to use replace() for this one, can't recall)
moveCursorEnd("main")
Awesome, Thanks Irruel.
That gives me a baseline, and at least I know it is possible! Lol, I'll give updates here if it works.
Nothing is going to get better. It's not.”
― Dr. Seuss, The Lorax
function addEnemy(name)
name = name:title()
table.insert(mayhem.list.enemies, name)
cecho("<red>" .. name .. " <white>has been added as an enemy")
end
I've never messed with color coding and what I keep doing keeps messing up and sending EVERYthing that color.. So I am wondering if any of you would be able to advise me on a way to make ^ color the name?
Also Keep the color for when I relogin etc
Check that script out.
As I dont just want to use it for 'enemies' No Worries I'll keep looking around
Said script doesnt delete the color once its added and you remove, you can only set 1 color so everyone allies/friends/citymembers/enemies etc etc will all be the same color...
I have a few HELP files which are like
- Stilltongue: Hidden whispers
- Shadowblow: hi
but the Alignment is all wrong, Anyone know how to align it so 'Hidden whsipers' and 'hi' start on the same 'space' so to speak?
I feel as though string.format() ought to be able to offer a simpler solution for this, but I've never bothered to learn how to use it. So!
The following is a bit rough; I made it up as I went. But it seems to work, so...
function test3( c1, c2, pos ) local pos = pos or 15 if string.len(c1) < pos then local diff = pos - string.len(c1) local spaces = string.rep( " ", diff ) c1 = c1 .. spaces end send("\n" .. c1 .. c2 .. "\n") end
Edit: I seem to have screwed up the code tag thing.@Irruel Thanks soo much!!
fixed
Abhorash says, "Ve'kahi has proved that even bastards can earn their place."
end
This is what is displayed/echoed when the function is run with an argument of "off". I have tried calling the function both with the intended click of a label, and directly from script. The result is the same:
attwin_click fires with: <off>
string
Why won't the if statement evaluate true, when the echoes clearly prove that m is a string with a value of 'off'?
i am rapture coder