Jump to content


qwerty's Content

There have been 35 items by qwerty (Search limited from 30-March 23)


By content type

See this member's


Sort by                Order  

#279471 Close multishell tabs automatically?

Posted by qwerty on 10 June 2020 - 09:33 PM in Ask a Pro

 Luca_S, on 10 June 2020 - 09:07 PM, said:

 qwerty, on 10 June 2020 - 06:25 PM, said:

Now I'm not an expert by any stretch of the word and am even less antiquated with the various bugs with the event system but my monkey brain believes this to be possible...
What do you mean? If you want to add a setting as described by Lupus you would just add an "and not settings.get("multishell.auto_close_tabs", false)" to the condition of the if.
k, cool. i might be mentally handicapped because I allways over engineer even the simplest of solutions, kinda like the code responsible for the two team color splat on cosmetics in 'Team Defense Fort Two'



#279469 Close multishell tabs automatically?

Posted by qwerty on 10 June 2020 - 06:25 PM in Ask a Pro

 Luca_S, on 29 May 2020 - 02:02 PM, said:

If you do end up changing multishell, this is the line you need to modify. You should probably also document that setting somewhere.

QQ - could one hypothetically attach
tProcess.bInteracted = true
to a
 corutine.yield() 
Now I'm not an expert by any stretch of the word and am even less antiquated with the various bugs with the event system but my monkey brain believes this to be possible...



#279468 [SOLVED] how do I filter peripherals in list = peripheral.getNames()

Posted by qwerty on 10 June 2020 - 06:21 PM in Ask a Pro

View Postvalithor, on 25 March 2020 - 02:23 AM, said:

Here is another solution:


Hmm, seems usefull.
Thank!



#279467 how do I look up an entry in a table?

Posted by qwerty on 10 June 2020 - 06:20 PM in Ask a Pro

View Postvalithor, on 25 March 2020 - 02:33 AM, said:

-chjop-

this is a little late of a response but thanks! you reminded me of like 3 projeckts on the backburner >kek
Thanks man, good help!



#279398 [SOLVED] how do I filter peripherals in list = peripheral.getNames()

Posted by qwerty on 20 March 2020 - 05:32 AM in Ask a Pro

ok well thanks.



#279396 [SOLVED] how do I filter peripherals in list = peripheral.getNames()

Posted by qwerty on 19 March 2020 - 12:43 PM in Ask a Pro

nvm, a friend helped me out. here's the code anyway;

periphlist = peripheral.getNames()
desired = {
"inset peripheral name here"
}
peripherals = {}

for p=1,#periphlist do
   for t=1,#desired do
      if string.find(periphlist[p],desired[t]) then
       peripherals[#peripherals+1] = periphlist[p]
     end
   end
end



#279395 [SOLVED] how do I filter peripherals in list = peripheral.getNames()

Posted by qwerty on 19 March 2020 - 11:30 AM in Ask a Pro

it amuses me that I'm the only one asking for help here.

On to the point, how do I filter a table of contents efficiently?
I have a list of peripherals attached in a table and I have potentially hundreds of peripherals on the network, however, all are not equal.
some are disk drives others are monitors, but I have a table with the peripherals that I need access to, and it looks a lot like this;
list = {
"immersiveengineering:storage_crate",
"minecraft:chest",
"thermalexpansion:storage_cache"
}
and here's a table that has the peripherals attached;
periph = {
"right",
"top",
"immersiveengineering:storage_crate_1",
"minecraft:chest_3"
}

so my question is; how do I determine that periph[item] equals list[any]?
thanks in advance.

with regards,
-qwerty



#279394 how do I look up an entry in a table?

Posted by qwerty on 17 March 2020 - 06:13 PM in Ask a Pro

not sure if any of it may help but thanks for the help anyway.



#279391 how do I look up an entry in a table?

Posted by qwerty on 17 March 2020 - 08:54 AM in Ask a Pro

unfortunately, this is not what I meant.

so you know how string.match('string', 'pattern') returns the first capture of 'pattern' in 'string'? yeah, I kinda need that functionality.

so I have a table right? inside the table are tables referring to inventory slots, and within those are keys referring to items within; kind of like this:
{
  [3] = {
    count = 32,
    name = "minecraft:cobblestone",
    damage = 0,
  },
}

and what I need is to be able to efficiently search the table for the name and its appropriate key so that I have something like a function that accepts a string and then returns the exact slot and inventory it is in, all without having to manually add inventories through hard-coding them or polluting the global enviornment



#279389 how do I look up an entry in a table?

Posted by qwerty on 16 March 2020 - 04:04 PM in Ask a Pro

How do I search a table for specific keys? I have read the 5.1 reference manual, but there's just too much to keep in track of.

specifically, I need to copy sub-tables from peripheral.getNames() to a different table.
since I'm making an inventory management program I need to keep track of where items are and since iterating trough a table is easier than polluting the global environment or hard coding things.

thanks in advance!

with regards,
-qwerty



#279387 [SOLVED]attempt to call global 'index' a table value.

Posted by qwerty on 25 February 2020 - 12:44 PM in Ask a Pro

View PostLupus590, on 25 February 2020 - 11:12 AM, said:

You have a variable name collision, using local variables will help.
k, thanks. I'm realy inexperienced with tables

View PostLupus590, on 25 February 2020 - 11:12 AM, said:

Side note, what is the goal of that function?
it is to index an inventory i.e. chests or storage crates -is for a storage management program-

View PostLupus590, on 25 February 2020 - 11:12 AM, said:

Also, are all these ask a pro posts you are making the same program?
maybe... maybe not.

View PostStekeblad, on 25 February 2020 - 11:16 AM, said:

You are overwriting your function and turning it into a table, when you try calling the function again it fails because its not a function anymore.
thanks, I really needed you to point that out... that's exactly my issue

with kind regards
-qwerty



#279384 [SOLVED]how do I reference a table inside another?

Posted by qwerty on 25 February 2020 - 10:50 AM in Ask a Pro

View PostLuca_S, on 25 February 2020 - 10:05 AM, said:


If you don't want the turtle to select the empty slots you can use nil in the table and do the following to skip them:

function selec(tRecipe)
  for k, v in pairs(tRecipe) do
	turtle.select(k)
	-- The item name is now stored in v
  end
end
now while I've discovered that it doesn't need to skip the nil entries, this is still very useful. Thank you!

with kind regards
-qwerty



#279383 [SOLVED]attempt to call global 'index' a table value.

Posted by qwerty on 25 February 2020 - 10:46 AM in Ask a Pro

that is the error I'm getting from this;

function index()
  if index ~= nil then
	index = nil
	index = inventory.list()
  else inventory.list()
  end
end
why is that?
as the name implies this is just a function used to update the index table of all items inside a chest.



#279381 [SOLVED]how do I reference a table inside another?

Posted by qwerty on 25 February 2020 - 09:12 AM in Ask a Pro

View PostLuca_S, on 25 February 2020 - 08:49 AM, said:

You should probably just replace nil with "minecraft:air" or some dummy item, and then check in the rest of code wether it's an actual item or "minecraft:air"

Ohhh ok then, I'll try that, thanks!

the only issue apparent here would be that the turtle selects all empty spaces and that's a no bueno in crafting.
scratch that, turtle.craft() is a stupid-to-use function.

with apreciation
-qwerty



#279379 [semi-solved]peripheral.wrap() handle equals "nill"

Posted by qwerty on 25 February 2020 - 08:24 AM in Ask a Pro

View PostLupus590, on 25 February 2020 - 07:55 AM, said:

I explained why it doesn't work but I will try again, Lua doesn't pass by reference, it copies function arguments. This means that the only ways to get information out of a function is to return it properly, modify an upvalue or modify a passed in table.

Local X = f() --# function f() return true end

Local t = {}
F(t) --# function f(tab) tab.x = true end

Local up
F() --# function f() up = true end

Those and variation will work, you could also pollute the global environment too.

thank you for your time and effort! man sleep deprivation really messes with one's head

with gratitude
-qwerty



#279378 [SOLVED]how do I reference a table inside another?

Posted by qwerty on 25 February 2020 - 08:20 AM in Ask a Pro

View PostLuca_S, on 25 February 2020 - 08:02 AM, said:

You need to use "sh.cbl" instead of "sh:cbl"

thanks man, works now.

do you mind allso telling me how would I leave spaces in the table so that the turtle ignores it but doesn't break the loop?
here's what I am stuck at

furnace = {
sh.cbl, sh.cbl, sh.cbl, nil,
sh.cbl, nil,	   sh.cbl, nil,
sh.cbl, sh.cbl, sh.cbl, nil,
}
function selec(table)
  for i=1,#table do
    turtle.select(i)
    --rest of code

as you can guess it doesn't work as expected and when encountering a nil it will break the for loop not finishing the selection process.

with gratitude
-qwerty



#279376 [SOLVED]how do I reference a table inside another?

Posted by qwerty on 25 February 2020 - 08:01 AM in Ask a Pro

It amuses me that I'm the only one starting threads here since the 20th, anyway- here's where I'm stuck yet again.
how do I reference a table within a different one?

this is what I got so far
sh = {} --[[sh stands for shorthand because I'm making a turtle crafting interface]]


sh["cbl"]="minecraft:cobblestone"


furnace = {
  sh:cbl, sh:cbl, sh:cbl, nil,
  sh:cbl, nil, sh:cbl, nil,
  sh:cbl, sh:cbl, sh:cbl, nil,
}
however you might notice that this doesn't work.
I've tried throwing everything but the kitchen sink of simple solutions but it looks like I'll have to use advanced techniques.

with regards
-qwerty



#279374 how do I autowrap peripherals on wired network?

Posted by qwerty on 25 February 2020 - 02:06 AM in Ask a Pro

View PostLyqyd, on 25 February 2020 - 01:18 AM, said:

... it seems like the easiest method would be to maintain a table keyed by the peripheral names, with the value being the "wrapped" peripheral. you can iterate over the table for access...
sounds good, and I'll try it, but would you be so kind as to provide a snippet of code I could use?

View PostLyqyd, on 25 February 2020 - 01:18 AM, said:

...and use the peripheral connection event to update the contents of the table.
literally what I was gonna do.

View PostLyqyd, on 25 February 2020 - 01:18 AM, said:

In fact, I think you can skip the table of wrapped peripherals entirely and simply iterate over the connected peripherals table returned by getNames().
so just use peripheral.call() insead of .wrap()? and parse the table entry to work in a peripheral call, I assume.

P.S. how do I compare two table contents? i.e. table_0 has [boolean] and I'm comparing to table_1's [47] to determine stuff


with regards
-qwerty



#279372 how do I autowrap peripherals on wired network?

Posted by qwerty on 24 February 2020 - 11:53 PM in Ask a Pro

Once more I am asking for your divine guidance with a problem of peripherals.
namely: how do I automatically wrap them when -the computer turns on or when a new peripheral is attached via wired modem.

so far I've come up with using string.find() to compare things, but peripheral.getNames() gives a table so that's more manipulation than I know. besides, trying to detect witch reference instance was found is rather difficult for me.

case and point: this is what I'm trying to accomplish.
reference = {chest, crate, cache}
List =  peripheral.getNames()

--code I have no idea on how to construct--

pointer = peripheral.wrap(*inventory from list*)
reference_id** = pointer

-- ** > the reference and id are to be used as pointers to selected inventory --

P.S. I'm using cc:tweaked if it wasn't allready obvious

with regards
-qwerty



#279371 [semi-solved]peripheral.wrap() handle equals "nill"

Posted by qwerty on 24 February 2020 - 10:55 PM in Ask a Pro

View PostLupus590, on 24 February 2020 - 02:35 PM, said:

Basically, if you return nickname does it have the value you expect?

Negative Chief, this was actually my main complaint. Also now that I tried running wrapID(), the debug worked just fine(printing the inventory in handle and table in nickname), but outside it returned nil on both.

I tried to do;
var,  temp = wrapID(crate,0,"crt")
and that worked, but it's also counter productive since I wanted all that to happen inside the function.

But if I must, I will.

<edit> I've made the decision to just simply use it like regular peripheral.wrap() </edit>

with regards
-qwerty



#279369 [semi-solved]peripheral.wrap() handle equals "nill"

Posted by qwerty on 24 February 2020 - 09:33 AM in Ask a Pro

View PostLupus590, on 23 February 2020 - 09:35 PM, said:

Can you post all the code?
that is all the code above. haven't touched it for a while since I got stuck, but you might appreciate a more detailed explanation of what I'm aiming for.

these are used as shorthand because typing >immersiveengineering:woodencrate:< is just too teadious when you have like 40 of 'em
--#setting global variables for referance#--
crate = "immersiveengineering:woodencrate"
cache = "thermalexpansion:storage_cache"
chest = "minecraft:chest"
Qchest = "quark:quark_chest"


this right here is the api call I want to implement.
you add >name< from reference(plain var), >id< from attached modem in numbers and >nickname< for ease of use and control abilities.
--#wraping the inventory with apropreate id#--
function wrapID( name , id , nickname )

  handle = tostring( name .. "_" .. id )
  nickname = peripheral.wrap(handle)

end

the use of handle is either to be wrapped in nickname or to be used in *nickname*.pullItems(handle,*slot*) or others

and that summarizes all of my code.

with regards
-qwerty



#279368 [SOLVED]propper use of unserialize to run functions?

Posted by qwerty on 24 February 2020 - 09:26 AM in Ask a Pro

View PostLupus590, on 23 February 2020 - 02:27 PM, said:

you want loadstring not textutils.unserialise...
Thanks man! woorks like a charm now!



#279367 How to make my turtle stop moving when waiting for building blocks?

Posted by qwerty on 24 February 2020 - 09:24 AM in Ask a Pro

View PostLupus590, on 23 February 2020 - 02:40 PM, said:

lua doesn't have a continue statement

I know, the "continue" there is just a representation, pseudo code if you will and I speciffically added "along the lines of", implying that that's only a template



#279365 [semi-solved]peripheral.wrap() handle equals "nill"

Posted by qwerty on 23 February 2020 - 08:35 PM in Ask a Pro

found here; https://ibb.co/TLt53jP

Now while I've taken what you said into consideration, I personally didn't find anything wrong and triple checked all connections and properly wrapped them



#279361 [SOLVED]propper use of unserialize to run functions?

Posted by qwerty on 23 February 2020 - 11:43 AM in Ask a Pro

A new problem I've run into is: how do I run scripts that have been unserialized.

I understand how
textutils.unserialize()
works, how ever my issue is that, not only do I not know how to pass commands to the lua prompt, but also the problem that when calling
tempvar()
it trhows a nill error, but it prints just fine.

I'm using plethora's chat recorder with the standard script running code but slightly altered to run the lua code entered in chat.
the original plethora's code found here
(It's the third code snippet)

and my code that I'm using-

--[[irrelevant code

local function clear()
  term.clear()
  term.setCursorPos(1,1)
end

clear()
--]]

local chat = peripheral.wrap("right")

while true do

--message catching
  local _, player, message, uuid = os.pullEvent("chat_message")

--message parsing
  local tempmsg = string.sub(message,2)
  tempvar = textutils.unserialize(tempmsg)

--debug
  print(message)
  print(tempmsg)
  print(tempvar) --pre edit: print(tempmsg)

--atempted function call
  tempvar()

end


With regards
-qwerty