help
#1
Posted 04 March 2014 - 06:45 PM
local rules = {
"&eNOTICE. The use of external tools, scripts or other vote boosting methods are prohibited.\n&0",
"\n",
"&3RULE 1.0&0. No Harassment, Bullying or Disrespect to anyone on the server including Staff, other Players and Guests. This also extends to the forum; this includes swearing directly at someone ingame, or harassing other players because of something you do not like. \n",
"\n\n",
"&3RULE 1.1&0. We're not stupid, we can see when you are duping.\n",
"\n\n",
"&3RULE 1.2&0. This rule is simple, PVP is disabled then do not try and kill another player. This includes placing turrets (for example next to another players land), placing lava, water, gravel or sand on another player while they are AFK, and traps. We classify any of these methods of cheating, and punishments are harsh.\n",
"\n\n",
"&3RULE 1.3&0. If an item is on the banned or restricted list and you do not have explicit permission from an administrator (only) to use/craft/place/interact with the item, you could be jailed/banned for breaking this rule if caught with the item.\n",
"\n\n",
"&3RULE 1.4&0. We don't allow griefing or stealing anywhere within the main world. You may steal from a non-residence within The Nether, The Twilight Forest and The End, you may not grief these worlds, i.e destroying blocks for the sake of destruction, revenge or otherwise. You may NOT grief or steal within a residence in any world, even if you have trusted permissions within the residence, including the 3 listed before.\n",
"\n\n",
"&3RULE 1.5&0. We will not accept any form of advertising in game for things unrelated to this server. This includes, but is not limited to advertising other servers, websites, youtube channels, facebook pages and other similar things. You may however advertise things within the game, for example you can tell others about your shop or residence, you may not spam the chat or message system.\n",
"\n\n",
"&3RULE 1.6&0. We utilise plugins to prevent players spamming with repeated messages, commands within their messages on the server. If you work out a way to bypass this and spam the chat, you will be mute/jailed/banned.\n",
"\n\n",
"&3RULE 1.7&0. If you are offline, your machines must also be offline. This means when you log off, turn off or disable your machines, we will jail/ban people who breach this rule. Timers are not allowed under 3 seconds, this is to prevent lag.\n",
"\n\n",
"&3RULE 1.8&0. You may not protect shared land or blocks. For example, creating a residence within areas like the spawn, or other peoples houses."
}
local function writeWithFormat(...)
local s = "&0"
for k, v in ipairs(arg) do
s = s .. v
end
s = s .. "&0"
local fields = {}
local lastcolor, lastpos = "0", 0
for pos, clr in s:gmatch"()&(%x)" do
table.insert(fields, {s:sub(lastpos + 2, pos - 1), lastcolor})
lastcolor, lastpos = clr , pos
end
for i = 2, #fields do
term.setTextColor(2 ^ (tonumber(fields[i][2], 16))) write(fields[i][1])
end
end
local mon = peripheral.wrap("back")
term.redirect(mon)
mon.setTextScale(1.0)
term.clear()
term.setCursorPos(1, 1)
for i = 1, #rules do
writeWithFormat(rules[i])
end
term.restore()
#2
Posted 04 March 2014 - 08:46 PM
Now, for my own and other's sanity's sake, imma add the code tags myself before i take a look at it...
local rules = {
"&eNOTICE. The use of external tools, scripts or other vote boosting methods are prohibited.\n&0",
"\n",
"&3RULE 1.0&0. No Harassment, Bullying or Disrespect to anyone on the server including Staff, other Players and Guests. This also extends to the forum; this includes swearing directly at someone ingame, or harassing other players because of something you do not like. \n",
"\n\n",
"&3RULE 1.1&0. We're not stupid, we can see when you are duping.\n",
"\n\n",
"&3RULE 1.2&0. This rule is simple, PVP is disabled then do not try and kill another player. This includes placing turrets (for example next to another players land), placing lava, water, gravel or sand on another player while they are AFK, and traps. We classify any of these methods of cheating, and punishments are harsh.\n",
"\n\n",
"&3RULE 1.3&0. If an item is on the banned or restricted list and you do not have explicit permission from an administrator (only) to use/craft/place/interact with the item, you could be jailed/banned for breaking this rule if caught with the item.\n",
"\n\n",
"&3RULE 1.4&0. We don't allow griefing or stealing anywhere within the main world. You may steal from a non-residence within The Nether, The Twilight Forest and The End, you may not grief these worlds, i.e destroying blocks for the sake of destruction, revenge or otherwise. You may NOT grief or steal within a residence in any world, even if you have trusted permissions within the residence, including the 3 listed before.\n",
"\n\n",
"&3RULE 1.5&0. We will not accept any form of advertising in game for things unrelated to this server. This includes, but is not limited to advertising other servers, websites, youtube channels, facebook pages and other similar things. You may however advertise things within the game, for example you can tell others about your shop or residence, you may not spam the chat or message system.\n",
"\n\n",
"&3RULE 1.6&0. We utilise plugins to prevent players spamming with repeated messages, commands within their messages on the server. If you work out a way to bypass this and spam the chat, you will be mute/jailed/banned.\n",
"\n\n",
"&3RULE 1.7&0. If you are offline, your machines must also be offline. This means when you log off, turn off or disable your machines, we will jail/ban people who breach this rule. Timers are not allowed under 3 seconds, this is to prevent lag.\n",
"\n\n",
"&3RULE 1.8&0. You may not protect shared land or blocks. For example, creating a residence within areas like the spawn, or other peoples houses."
}
local function writeWithFormat(...)
local s = "&0"
for k, v in ipairs(arg) do
s = s .. v
end
s = s .. "&0"
local fields = {}
local lastcolor, lastpos = "0", 0
for pos, clr in s:gmatch"()&(%x)" do
table.insert(fields, {s:sub(lastpos + 2, pos - 1), lastcolor})
lastcolor, lastpos = clr , pos
end
for i = 2, #fields do
term.setTextColor(2 ^ (tonumber(fields[i][2], 16))) write(fields[i][1])
end
end
local mon = peripheral.wrap("back")
term.redirect(mon)
mon.setTextScale(1.0)
term.clear()
term.setCursorPos(1, 1)
for i = 1, #rules do
writeWithFormat(rules[i])
end
term.restore()
Vertical scrolling is actually very simple, since you can place the cursor offscreen.
function vertScroll(text) local termX,termY = term.getSize() local cursX,cursY = term.getCursorPos() local scrollLength = termX-cursX+1 -- calculate visible area for i = 1,#text+scrollLength do --loop the length of the text and the length of the visible area term.setCursorPos(cursX-#text+i-1,cursY) term.write(text) sleep(0.2) --scroll speed end end
Working your color scheme into that however is gonna be a bit more complex, i should probably go test this code. gimme a few minutes here.
Edit: I'll add some comments and explainations tomorrow if you want.
function vertScroll(text)
local termX,termY = term.getSize() -- get terminal size
local cursX,cursY = term.getCursorPos() --get current cursor position, so it will print to wherever the cursor is currently located
local scrollLength = termX-cursX+1 -- calculate visible area
local writeText = string.rep(" ",scrollLength)..text -- pad the text to scroll with enough blank spaces to fill the visible area after the text has scrolled by, to clear it
for i = 1,#text+scrollLength do --loop the length of the text and the length of the visible area
term.setCursorPos(cursX-#writeText+i,cursY) --set the cursor offscreen by the length of the string we're scrolling, then subtract how many times we've scroll forward (i)
local tLines = {} --table containing the strings seperated by color tags, and what color they should be
for color, line in writeText:gmatch("&(%d)([^&]+)") do -- loop once for every color tag followed by a number (%d) then followed by anything that's not a colortag ([&^]+)
tLines[#tLines+1] = {
string = line, --store the line to the table
color = color --store the color to the table
}
end
for i=1,#tLines do --loop once for every entry of the table
term.setTextColor(2 ^ tLines[i].color) --set the color
term.write(tLines[i].string) --write the text
end
sleep(0.2) --pause between each scroll
end
term.setCursorPos(cursX,cursY) --return the cursor to it's original position
end
Edited by CometWolf, 05 March 2014 - 10:18 PM.
#3
Posted 05 March 2014 - 09:16 PM
#4
Posted 05 March 2014 - 10:18 PM
#5
Posted 06 March 2014 - 03:34 PM
#6
Posted 06 March 2014 - 04:53 PM
#7
Posted 08 March 2014 - 02:50 PM
#8
Posted 08 March 2014 - 04:24 PM
#9
Posted 08 March 2014 - 04:24 PM
#10
Posted 08 March 2014 - 04:29 PM
If you really want multiple scrolling lines at the same time, it shoudl be pretty easily doable with the parallel api. I can show you if you need it.
local rules = {
"&eNOTICE The use of external tools, scripts or other vote boosting methods are prohibited.",
"&3RULE 1.0&0. No Harassment, Bullying or Disrespect to anyone on the server including Staff, other Players and Guests. This also extends to the forum; this includes swearing directly at someone ingame, or harassing other players because of something you do not like.",
"&3RULE 1.1&0. We're not stupid, we can see when you are duping.",
"&3RULE 1.2&0. This rule is simple, PVP is disabled then do not try and kill another player. This includes placing turrets (for example next to another players land), placing lava, water, gravel or sand on another player while they are AFK, and traps. We classify any of these methods of cheating, and punishments are harsh.",
"&3RULE 1.3&0. If an item is on the banned or restricted list and you do not have explicit permission from an administrator (only) to use/craft/place/interact with the item, you could be jailed/banned for breaking this rule if caught with the item.",
"&3RULE 1.4&0. We don't allow griefing or stealing anywhere within the main world. You may steal from a non-residence within The Nether, The Twilight Forest and The End, you may not grief these worlds, i.e destroying blocks for the sake of destruction, revenge or otherwise. You may NOT grief or steal within a residence in any world, even if you have trusted permissions within the residence, including the 3 listed before.",
"&3RULE 1.5&0. We will not accept any form of advertising in game for things unrelated to this server. This includes, but is not limited to advertising other servers, websites, youtube channels, facebook pages and other similar things. You may however advertise things within the game, for example you can tell others about your shop or residence, you may not spam the chat or message system.",
"&3RULE 1.6&0. We utilise plugins to prevent players spamming with repeated messages, commands within their messages on the server. If you work out a way to bypass this and spam the chat, you will be mute/jailed/banned.",
"&3RULE 1.7&0. If you are offline, your machines must also be offline. This means when you log off, turn off or disable your machines, we will jail/ban people who breach this rule. Timers are not allowed under 3 seconds, this is to prevent lag.",
"&3RULE 1.8&0. You may not protect shared land or blocks. For example, creating a residence within areas like the spawn, or other peoples houses."
}
local tHex = {
a = 2 ^ 10,
b = 2 ^ 11,
c = 2 ^ 12,
d = 2 ^ 13,
e = 2 ^ 14,
f = 2 ^ 15,
}
for i=0,9 do
tHex[i] = 2 ^ i
end
local function vertScroll(text,obj)
local term = obj or term
local termX,termY = term.getSize() -- get terminal size
local cursX,cursY = term.getCursorPos() --get current cursor position, so it will print to wherever the cursor is currently located
local scrollLength = termX-cursX+1 -- calculate visible area
for i = 1,#text+scrollLength do --loop the length of the text and the length of the visible area
term.setCursorPos(cursX-#text-scrollLength+i,cursY) --set the cursor offscreen by the length of the string we're scrolling, then subtract how many times we've scroll forward (i)
local tLines = {
[1] = {
string = string.rep(" ",scrollLength),
color = tHex[1]
}
} --table containing the strings seperated by color tags, and what color they should be
for color, line in text:gmatch("&([0-9abcdef])([^&]+)") do -- loop once for every color tag followed by a number (%d) then followed by anything that's not a colortag ([&^]+)
print(color)
print(line)
if string.match(color,"%d") then
color = tonumber(color)
end
tLines[#tLines+1] = {
string = line, --store the line to the table
color = tHex[color] --store the color to the table
}
end
for i=1,#tLines do --loop once for every entry of the table
term.setTextColor(tLines[i].color) --set the color
term.write(tLines[i].string) --write the text
end
sleep(0.2) --pause between each scroll
end
term.setCursorPos(cursX,cursY) --return the cursor to it's original position
end
local mon = peripheral.wrap("back")
mon.setTextScale(1.0)
mon.clear()
mon.setCursorPos(1, 1)
for i = 1, #rules do
vertScroll(rules[i],mon)
end
#11
Posted 09 March 2014 - 04:09 PM
#13
Posted 09 March 2014 - 11:24 PM
CometWolf, on 08 March 2014 - 04:29 PM, said:
You did vertical scrolling quite a difficult way, you basically reinvented the entire script as well as the wheel, all you needed to add was a term.scroll call with some minor extra logic.
Edited by theoriginalbit, 09 March 2014 - 11:30 PM.
#14
Posted 10 March 2014 - 05:19 AM
#15
Posted 10 March 2014 - 05:22 AM
CometWolf, on 10 March 2014 - 05:19 AM, said:
CometWolf, on 10 March 2014 - 05:19 AM, said:
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











