42 posts
Posted 01 January 2014 - 06:42 PM
Is there a easy way to make a statement like : If string contains "…" then ?
1281 posts
Posted 01 January 2014 - 06:46 PM
if stringName:match"whatever you want it to contain" then
42 posts
Posted 01 January 2014 - 06:51 PM
I get attempt to call nill at line 11:
http://pastebin.com/6UhrxPVG
1281 posts
Posted 01 January 2014 - 06:59 PM
Because cell1 is not a string
local cell1 = peripheral.wrap("cofh_thermalexpansion_energycell_0")
Does not return a string, but rather a table. Thus you are not calling the string function when you do cell1:match"".
42 posts
Posted 01 January 2014 - 07:04 PM
Is there a way to get around this ?
1281 posts
Posted 01 January 2014 - 07:07 PM
Not entirely sure what you're trying to do there, as you already know what peirpheral is wrapped to cell1, no?
42 posts
Posted 01 January 2014 - 07:08 PM
I want it to check if cell1 is the energycell then execute the addBox-stuff else just skip it
1281 posts
Posted 01 January 2014 - 07:11 PM
if cell1.getEnergyStored then
Should check wether the table the cell is wrapped to, contains an energy cell function. If it does not, it's not an energy cell.
it is quite redundant however, as no other peripheral would have the same name, meaning your wrap would fail anyways if one wasn't connected.
Edited on 01 January 2014 - 06:12 PM
42 posts
Posted 01 January 2014 - 07:12 PM
Ahh it works :D/>
42 posts
Posted 01 January 2014 - 07:20 PM
But now I get line 10 or 28: attempt to index dependend on which is connected
But is should just skip this part of the code .
Edit: solved the problem by myself. using peripheral.isPresent(peripheral-name)
Edited on 01 January 2014 - 07:04 PM