Page 1 of 1

How to set the filter propertie?

Posted: Wed May 29, 2013 11:31 am
by Spawn
Hello again,
many thanks for the help and the answer in the past. :D
Does anyone know how to set the filter for the smart-inserter and (my problem) the logistic-container in requester-mode?
I tried the following ... but does not work :twisted:

Code: Select all

game.onevent(defines.events.onbuiltentity, function(event)
	if event.createdentity.name == "foo-logistic-container" then
        event.createdentity.filter[1]="coal"
       -- event.createdentity.filter="coal" 
      end
end)
Error message= Key.Filter doesnt exist! ..yep .. i see. ;)

I have tried different ways to find out the existing keys.
Thought, if i send the entity to console, i can find some information, so i use:

Code: Select all

game.player.print(serpent.block(event.createdentity)) 
game.player.print(tostring(event.createdentity) )
game.player.print(table.concat(event.createdentity) )
game.player.print(serpent.block(entity)) 
game.player.print(tostring(game.entity) )
....
in all combinations - nothing works... pfffff - iI'm so sad 8-)
thankful for every tip

greetings Frank




thx Frank

Re: How to set the filter propertie?

Posted: Wed May 29, 2013 12:04 pm
by FreeER
Spawn wrote:Thought, if i send the entity to console, i can find some information
If you tried these in the console these did not work because they are not valid 'pointers' (probably not the proper term but best I can think of lol) to the filter-inserter. I typically do test = game.findentities{{},{}} and insert the coords (from f5) inbetween both of the inner braces. and then you can do game.player.print(serpent.block(test[1]). You could also use test = game.player.character.getselected() and then test print test with serpent.block. That would probably be faster, but it only allows you to get one entity, if you wanted to test several for some reason then placing them all close together and using findentities is probably the better method. If you were trying them in your code (assuming you commented out the line causing errors) then event.createdentity should have printed to the screen.

However, I do not believe it is currently possible to set the filter property (at least I have not heard of a way, nor can I think of one).
The typical list of funtions however is: note that calling some of these on the wrong entity type may (read probably will) cause errors/crashes! Also serpent.block (when used in the console) seems to cut off the first letter of some of the function names (Not sure why I have not ever reported this as a bug). Before Factorio disallowed the use of the lua io library I used serpent.block to print most of these function to a file so it was trivial to update the list (both to place here and for my own personal use).

Code: Select all

addmarketitem
caninsert
canreachentity
clearguiarrow
clearitemsinside
damage
destroy
die
disableflashlight --probably exclusive to player
equals
setactive
getavailableenergy
getcraftingqueuesize --probably exclusive to player
getcraftingspeedmodifier
getdestructible
getdropposition
getdroptarget
getenergy
getinventory --starts at 0, some entities have multiple inventories (like the player)
getitemcount
getminable
getopened
getoperable
getoutputinventory
getrecipe --afaik this is exclusive to the assembling machines
getrotatable
getselected --probably exclusive to player
getselectedgunindex --probably exclusive to player
hascommand --probably exclusive to creeper
hasflag
insert
iscraftingqueueempty --probably exclusive to player
isvalid
removeitem
setactive
setcommand --probably exclusive to creeper
setcraftingspeedmodifier
setdestructible
setguiarrow
setminable
setoperable
setrotatable
teleport

game.player however has these
clearconsole
connecttocharacter
disconnectcharacter
setgoaldescription
print --obviously :)
setendingscreendata
setgoaldescription
I have personally used few of these to be honest, mainly caninsert, damage, destroy, die, equals (on occasion), insert (of course), isvalid, and since I've tried making a cloning mod I've used the connect/disconnect character functions of the player (not to mention print)

Is there a specific reason you are wanting to do this? The only one I can think of right now is if you were creating a map, in which case I'd say create a scenario and place the filter in a far off (but known) location with the settings you want and then simply teleport it in when you need to...not a great solution but a work around at least.
Sorry I couldn't be a bit more helpful here.

Re: How to set the filter propertie?

Posted: Wed May 29, 2013 12:06 pm
by rk84
Hi. You propably need to make mod interface request for get what you looking for.

Also. you can print messages that you can select (Ctrl+A) and copy/paste to notepad or similar (for better visibility)

Examples.

Code: Select all

game.showmessagedialog(serpent.block(glob))
--or
game.showmessagedialog(serpent.block(game))
--or
game.showmessagedialog(serpent.block(game.player.character.getselected())) -- hover mouse over entity