Jump to content


plazter's Content

There have been 32 items by plazter (Search limited from 10-February 22)


By content type

See this member's


Sort by                Order  

#258835 Sending table over rednet is always nil

Posted by plazter on 01 September 2016 - 02:12 PM in Ask a Pro

on a side note, its a big reactor program, and makes RF, if you want it in EU you need to recalculate it down dont you?
1 EU = 4 RF


EDIT: im being a derp sorry :P



#258776 [SOLVED][<program>:17: Attempt to call string] Fs.readLine() trouble...

Posted by plazter on 31 August 2016 - 05:41 PM in Ask a Pro

View PostAnavrins, on 31 August 2016 - 05:36 PM, said:

View Postplazter, on 31 August 2016 - 04:19 PM, said:

function import()
local datafile = fs.open("whitelist", "r")
for name in datafile.readLine do
  table.insert(whitelist, name:lower())
  whitelist[name] = true
end
end
You won't be needing that table.insert line, since you're now referencing the whitelist as a string key and not by a numerical index.

oh ok :) well thanks a bunch!



#258755 [SOLVED][<program>:17: Attempt to call string] Fs.readLine() trouble...

Posted by plazter on 31 August 2016 - 04:19 PM in Ask a Pro

View PostAnavrins, on 31 August 2016 - 01:21 AM, said:

Load your whitelist into your table as {"plazter" = true, "Anavrins" = true}
 local whitelist = {} for name in file.readLine do whitelist[name] = true end 
When checking for a user in the whitelist, instead of using a loop like in Rockets example, you can simply index the name from the whitelist
 if whitelist[name] then -- Is in whitelist else -- Not in whitelist end 

Ok so i changed it, still dont work xD, i might not be understanding you correctly..
function import()
local datafile = fs.open("whitelist", "r")
for name in datafile.readLine do
  table.insert(whitelist, name:lower())
  whitelist[name] = true
end
end
and then where i look
function auth()
  for k,result in pairs(s.getPlayers()) do
   local name = result.name:lower()
   if whitelist[name] then
	 print("ok")
	 else
	 print("nope")
   end
  end
end

keeps saying nope :P

EDIT: forgot to add lower() to the whitelist[name]xD



#258691 [SOLVED][<program>:17: Attempt to call string] Fs.readLine() trouble...

Posted by plazter on 30 August 2016 - 05:08 PM in Ask a Pro

-snip-
for t,result in ipairs(s.getPlayers()) do
  local name = result.name:lower()
    for i = 1,#whitelist do
      if name == whitelist[i] then
        rs.setOutput("left", true)
     end
    end
  end
rs.setOutput("left", false)
end


it prints the UUID, and the Name .. and dont turn back off when i leave :P, it works fine without the whitelist part :P
not sure how to fix it rly :), been trying diffrent stuff :P cant seem to figure it out :P'


EDIT: Figured it out at last.
- How ever i have a light i use to test it with, and it seems to work the edit's i've done so far, but, the light is not turning back on when i leave it (inverted white lamp)
(Code has been updated in the post here)



#258687 [SOLVED][<program>:17: Attempt to call string] Fs.readLine() trouble...

Posted by plazter on 30 August 2016 - 04:33 PM in Ask a Pro

View PostAnavrins, on 30 August 2016 - 04:27 PM, said:

-snip-
  for line in datafile.readLine() do
	 table.insert(whitelist, line)
  end
-snip-
You were on the right path with this, remove the () after "readLine", and this code will put each individual line of the file in "whitelist"
Oh really?, time to test it again :D

The entire purpose is to make it detect the whitelisted players then let it turn on but if not keep stuff hidden away / turned off

- You were right man! Cheers!!



#258685 [SOLVED][<program>:17: Attempt to call string] Fs.readLine() trouble...

Posted by plazter on 30 August 2016 - 04:09 PM in Ask a Pro

function Authorised()
  for k, v in pairs(s.getPlayers()) do
	    for p, playerName in pairs(v) do
		   for i = 1,#whitelist[i] do
				  if playerName:lower() == whitelist[i] then
				    print("Allowed: ".. playerName)
				 end -- if
		   end --for
		 end --for
  end --for
end  --function

This will type the uuid too :(



#258684 [SOLVED][<program>:17: Attempt to call string] Fs.readLine() trouble...

Posted by plazter on 30 August 2016 - 01:46 PM in Ask a Pro

Quote

-snip-
--# After declaration of `datafile`
local line = datafile.readLine()
while line do
	table.insert(whitelist, line)
	line = datafile.readLine()
end
--# whatever else

Because now you're reading line after line until there are no more lines - generally how you'd want to do it. It looks like you had the right idea, just a bit of confusion with .readLine().

wont local line do fine once? :P

And it works man! Cheeeers!

EDIT: that second line is nessesary for it to notice theres not more.. :P



#258681 Click Events says "attempt to compare string with number expected, got string"

Posted by plazter on 30 August 2016 - 01:14 PM in Ask a Pro

(Y) Your welcome!



#258679 [SOLVED][<program>:17: Attempt to call string] Fs.readLine() trouble...

Posted by plazter on 30 August 2016 - 01:06 PM in Ask a Pro

View Posthouseofkraft, on 30 August 2016 - 01:01 PM, said:

You can try using a variable to store your whitelist

Code:
local whitelist = nil
file = fs.open("whitelist", "r")
whitelist = file.readLine()
file.close()

Sorry if this is not what you wanted. Im not the best at CC

Ill give it a go :), ill tell ya if it works or not :P

Well it works, but not what im looking for :), thanks for the answer tho houseofkraft :)



#258678 Click Events says "attempt to compare string with number expected, got string"

Posted by plazter on 30 August 2016 - 01:01 PM in Ask a Pro

View Posthouseofkraft, on 30 August 2016 - 12:49 PM, said:

Hi Guys!

I am working on a new OS for CC that's in heavy beta but i am having issues with click events

Error: setup:13: attempt to compare string with number expected, got string

Code:
-snip-
local event, side, x, y = os.pullEvent("mouse_click")
if x >= 19 and x < 26 and y == 14 then
   term.clear()
end
-snip-

Thank you!

Try that, thats the line i use to make mine works :)



#258676 [SOLVED][<program>:17: Attempt to call string] Fs.readLine() trouble...

Posted by plazter on 30 August 2016 - 12:50 PM in Ask a Pro

Hello again pros.. :P

- Im currently working on an extra security sensor, but cant get the code to read my whitelist File as the title says, i get an attempt to call string in my attempt to insert the names into the whitelist.
-snip-
  for line in datafile.readLine() do
	 table.insert(whitelist, line)
  end
-snip-

And i really cant figure out why...

Heres the code:
Spoiler

Pastebin: http://pastebin.com/QVUhkELh

//Plazter

EDIT: New problem, how can i avoid it printing the UUID, and just the player names? :/
function Authorised()
  for k, v in pairs(s.getPlayers()) do
	for p, playerName in pairs(v) do
	   for i = 1,#whitelist[i] do
		  if playerName:lower() == whitelist[i] then
		   --Do something here
		 end -- if
	   end --for
	 end --for
  end --for
end  --function



#258341 Bundled cable troubles.

Posted by plazter on 23 August 2016 - 04:11 PM in Ask a Pro

Ah ok, ill look at it once im a little more fresh :P drove tired in it xD



#258339 Bundled cable troubles.

Posted by plazter on 23 August 2016 - 02:47 PM in Ask a Pro

View PostDragon53535, on 23 August 2016 - 02:44 PM, said:

So you want persistent storage of the number?

File Tutorial

If I misinterpreted that and you mean you don't know how to set new colors in with the old. Just set the output with the old or new color subtracted or added in.

local num = rs.getBundledOutput("right")
num = num - 256
rs.setBundledOutput("right",num)

not persistant (i think) but just keep the ones thats on at the moment (currently got 8 spawners connected to a bundled cable with levers.. really ugly :P)
but as u can i see i tried to make the current "signal" to be saved in the table on.

Quote

-snip-
num = num - 256

Whats the 256 for? O_o



#258337 Bundled cable troubles.

Posted by plazter on 23 August 2016 - 02:41 PM in Ask a Pro

well its easy to hard code yes, but theres more colors to come since i got a lot of spawners on the server im playing on :), kinda why i want it to automatic remember the colors thats on and unless i click the right button it goes off ofc.. (not sure that made sense :B)



#258335 Bundled cable troubles.

Posted by plazter on 23 August 2016 - 02:36 PM in Ask a Pro

Spoiler

uhm.. so 1 to 16 .. it returns with the correct number (heximal) from the cc wiki :s..
but how would i get it to add the colors aswell tho? thats kinda the problem currently :P



#258333 Bundled cable troubles.

Posted by plazter on 23 August 2016 - 02:14 PM in Ask a Pro

Hello again pros!

- I am trying to make a simple code for a few spawners, and want to use bundled cables, but i've hit a brick wall... im not sure what im doing wrong.. the code works more or less,
but its not saving the colors thats allready active in the table i want to use for it..

(Sorry for the bad describtion)

http://pastebin.com/0ynx1UvH

Spoiler

Hope you can help me!!

Regards Plazter



#250038 Steel tank reading.. cant get it working

Posted by plazter on 12 April 2016 - 07:29 PM in Ask a Pro

View PostLupus590, on 12 April 2016 - 07:24 PM, said:

I've updated my code to get new data.

Is that line 28 error on my code?

edit: should be fixed
And now pastebin get aint working on zeh server :/



#250022 Steel tank reading.. cant get it working

Posted by plazter on 12 April 2016 - 06:53 PM in Ask a Pro

View PostLupus590, on 12 April 2016 - 06:37 PM, said:

to do that you will need to replace the inner most loop of printEntry

-- full function
local function printEntry(t, m)--t is tankInfo, m is monitor
  for _,a in pairs(t) do
	m.print("name: "..a.contents.name)
	m.print("amount: "..a.contents.amount)
  end
end


I should say that I'm not familiar with this tank, so it's possible that this won't work at all

One thing I have noticed is that this wont add blank lines to separate things, opps

Ill try your version thanks mate

EDIT: Line 28: attempt to index ? (a nil value)



#250011 Steel tank reading.. cant get it working

Posted by plazter on 12 April 2016 - 06:09 PM in Ask a Pro

View PostLupus590, on 12 April 2016 - 06:07 PM, said:

I'm going to go and just rewrite all of that (it's almost painful to look at)

I will edit my post with the code soon

lol xD thanks

made it only write fluid: <name>
and amount: <amount>



#249997 Steel tank reading.. cant get it working

Posted by plazter on 12 April 2016 - 04:54 PM in Ask a Pro

Hey lupus, thanks for answering aswell, the name of the liquid is in the contents part as i showed up in the top,
now ive added all those and made it into a loop ( while true do loop).
got it running, but now the monitor wont update the text :(
Spoiler

http://imgur.com/WSTKMBJ - A Picture of curret setup



#249991 Steel tank reading.. cant get it working

Posted by plazter on 12 April 2016 - 03:45 PM in Ask a Pro

View PostSewbacca, on 12 April 2016 - 03:39 PM, said:

View Postplazter, on 12 April 2016 - 03:28 PM, said:

tank = peripheral.wrap("back")
tankInfor k,v in pairs(tankInfo) do
  for o,c in pairs(v) do
	for a,b in pairs(c) do
	  print(a)
	end
  end
end

try:

tank = peripheral.wrap("back")
tankInfo = tank.getTankInfo()
for _, t in pairs(tankInfo) do
  for k,v in pairs(t.contents) do
	--Your stuff
  end
end

I am too lazy for explanations.

Well thanks xD, that worked :P
- Tho it prints too much info xD



#249989 Steel tank reading.. cant get it working

Posted by plazter on 12 April 2016 - 03:36 PM in Ask a Pro

Tried with:
tank = peripheral.wrap("back")
tankInfo = tank.getTankInfo()

for k,v in pairs(tankInfo) do
  for o,c in pairs(v) do
		 if c == "contents" then
		   for a,b in pairs(c) do
		    print(a..": ".. B)/>
		   end
    end
  end
end

now it returns no error but just .. ye.. runs the program :P



#249987 Steel tank reading.. cant get it working

Posted by plazter on 12 April 2016 - 03:28 PM in Ask a Pro

Hello pros!
so.. i've been looking around the net, and really cant find something that does as i wish, i've been trying and testing stuff, but cant get it to work
all i need is to read the amount and name from the tank, what i wrote is:

tank = peripheral.wrap("back")
tankInfo = tank.getTankInfo()

for k,v in pairs(tankInfo) do
  for o,c in pairs(v) do
	for a,b in pairs(c) do
	  print(a)
	end
  end
end

when i run it it returns with: testTwo:6: table expected, got number
and when i try to print Y, it returns with a string obv :b

when i do tank.getTankInfo() in the LUA it returns with:
{
  {
	  capacity = 56000000
	  contents = {
						 rawName = "Lava",
						 amount = 256300
						 name = "lava",
						 id = 2,
					  },
			   },
}


what am i missing here? :s

all i really want it to do is:
Name:
Amount: x/capacity

EDIT: got it to print to only 1 monitor as i'd liked :D
But, it still wont update: pastebin is: http://pastebin.com/bPrRY9nZ



#248962 Auto Wrap

Posted by plazter on 27 March 2016 - 07:22 AM in Ask a Pro

View PostDragon53535, on 27 March 2016 - 06:23 AM, said:

monitors[1].write(turbines[1].getActive())
--#Should be
monitors[1].write(turbines[i].getActive())
At the same time, I would first make sure that such values exist.
if (turbines[i] and turbines[i].getActive) then
   monitors[1].write(turbines[i].getActive())
end
If nothing prints out then we know for a fact that you're for some reason not getting properly wrapped turbines, or that they don't have a .getActive method

we got it working, i had done the isActive ingame.. derp :>, and the if one u mention.. i like that idea :>



#248960 Auto Wrap

Posted by plazter on 27 March 2016 - 05:55 AM in Ask a Pro

View PostDog, on 27 March 2016 - 05:54 AM, said:

On your first line, you're missing a closing quote and closing brackets/parenthesis
turbines = { peripheral.find("BigReactors-Turbine") }

just saw that, it was a typo :P, the error is still occuring.. line 10: Attempt to call nill