[0.10.0] New modding possibilities
Posted: Fri Jun 06, 2014 6:42 pm
Added set/get/clear filter methods to access inserter filters
Added set/get/clear requestslot to access requester chest requests
Added set/get/clear methods for circuit conditions.
Added lua interfaces to force to get/set modifiers
new Read/write Properties for luaForce:
Expanded connectneighbour-method
Simple API to write to disk (makefile, removepath)
Code: Select all
Name: getfilter(integer filterindex)
Returns: itemname; nil if filter is empty
Description: returns the name of the item for the selected filter;
if the filter is empty it returns nil
Note: can be called on smart-inserters only
Example:
-- selected entity has to be a smart-inserter
-- prints the itemname that was selected in the first filterslot
game.player.print(game.player.selected.getfilter(1))
Code: Select all
Name: setfilter(string itemname, integer filterindex)
Returns: nothing
Description: sets the given filterslot to the passed itemname
Note: can be called on smart-inserters only
Example:
-- selected entity has to be a smart-inserter
-- sets the first filterslot to raw-wood
game.player.selected.setfilter("raw-wood", 1)
Code: Select all
Name: clearfilter(integer filterindex)
Returns: nothing
Description: clears the given filterslot
Note: can be called on smart-inserters only
Example:
-- selected entity has to be a smart-inserter
-- clears the second filterslot of the inserter
game.player.selected.clearfilter(2)
Code: Select all
Name: getrequestslot(integer slotindex)
Returns: itemstack; nil if requestslot is empty
(itemstack = table with "name" and "count" keys that holds the relevant values)
Description: returns the current configuration of the passed requestslot
Note: can be called on entities that have requestslots only
Example:
-- selected entity is a requester-chest
-- prints the configuration of requestslot 3
game.player.print(serpent.block(game.player.selected.getrequestslot(3)))
Code: Select all
Name: setrequestslot(itemstack, integer slotindex)
Returns: nothing
Description: configurate the passed requestslot
Note: can be called on entities that have requestslots only
Example:
-- selected entity is a requester-chest
-- configurate the chest to accept 1k raw-wood (the first slot is used)
game.player.selected.setrequestslot({name="raw-wood",count=1000},1)
Code: Select all
Name: clearrequestslot(integer slotindex)
Returns: nothing
Description: clear the passed requestslot
Note: can be called on entities that have requestslots only
Example:
-- selected entity is a requester-chest
-- clears requestslot 4
game.player.selected.clearrequestslot(4)
Code: Select all
Name: getcircuitcondition(integer circuitType)
Returns: table similar to itemstack, but with an additional "operator"-key
that contains the operator (<, >, =) as a string
retuns nil if entity is not part of the passed network
Description: returns the circuitconditions of the entity
Note: can be called on smart-inserters only
Example:
-- selected entity has to be a smart-inserter
-- the defines.lua file contains "constants" for the different circuitTypes
-- prints the red-wire circuitconditions
game.player.print(serpent.block(game.player.selected.getcircuitcondition(defines.circuitconnector.red)))
Code: Select all
Name: setcircuitcondition(integer circuitType, table condition)
Returns: nothing
Description: sets the circuitconditon for the passed circuitType
condition-table similar to itemstack, but with an additional "operator"-key
Note: can be called on smart-inserters only
Example:
-- selected entity has to be a smart-inserter
-- the defines.lua file contains "constants" for the different circuitTypes
-- sets the red-wire circuitcondition
condition = {name = "raw-wood", count = 600, operator = ">"}
game.player.selected.setcircuitcondition(defines.circuitconnector.red, condition)
Code: Select all
Name: clearcircuitcondition(integer circuitType)
Returns: nothing
Description: clears the circuitcondition for the passed circuit-type
Note: can be called on smart-inserters only
Example:
-- selected entity has to be a smart-inserter
-- the defines.lua file contains "constants" for the different circuitTypes
-- clear the green-wire & logistic circuitcondition
game.player.selected.clearcircuitcondition(defines.circuitconnector.green)
game.player.selected.clearcircuitcondition(defines.circuitconnector.logistic)
Code: Select all
Name: getammodamagemodifier(string ammo-category)
Returns: current value
Description: returns the current ammo-modifier for the given ammo-category
Note: nothing
Example:
-- prints the damagemodifier for bullet-type ammo
game.player.print(game.player.force.getammodamagemodifier("bullet"))
Code: Select all
Name: setammodamagemodifier(string ammo-category, number newValue)
Returns: nothing
Description: sets the current ammo-modifier for the given ammo-category
Note: nothing
Example:
-- set the damagemodifier for bullet-type ammo to 10 (10 times the normal-damage)
game.player.force.setammodamagemodifier("bullet", 10)
Code: Select all
Name: getgunspeedmodifier(string ammo-category)
Name: setgunspeedmodifier(string ammo-category, number newValue)
both work similar to get/set ammodamagemodifier
Code: Select all
Name: getturretattackmodifier(string turretname)
Returns: current value
Description: returns the damage-modifier for the given turret
Note: nothing
Example:
-- prints the modifier for laser-turrets
game.player.print(game.player.force.getturretattackmodifier("laser-turret"))
Code: Select all
Name: setturretattackmodifier(string turretname, number newValue)
Returns: nothing
Description: sets the damage-modifier for the given turret
Note: nothing
Example:
-- doubles the modifier for laser-turrets
game.player.force.setturretattackmodifier("laser-turret", 2)
Code: Select all
- laboratoryspeedmodifier
- logisticrobotspeedmodifier
- logisticrobotstoragemodifier
- inserterstacksizebonus
- numbercharacterlogisticslots (read only)
- numberquickbars
- maximumfollowingrobotscount
- ghosttimetolive (unit is gametick)
Code: Select all
Name: connectneighbour(entity targetentity [,integer circuitType])
Returns: true on success; otherwise false
Description: creates wires between electric poles and/or valid entities
Note: can be called on electric poles only
the circuitType is optional, if not used copper-wire is used
Example:
-- the start electric pole is stored in startPole
-- selected entity is another pole that is reachable
-- create copper, red-/green-wire connection between poles
startpole.connectneighbour(game.player.selected) --copper-wire
startpole.connectneighbour(game.player.selected, defines.circuitconnector.red) --red-wire
startpole.connectneighbour(game.player.selected, defines.circuitconnector.green) -- green-wire
-- selected entity is now a smart inserter
-- connects the inserter with the pole
startpole.connectneighbour(game.player.selected, defines.circuitconnector.green)
Code: Select all
Name: makefile(string path, string/number data)
Returns: nothing
Description: creates file that contains the passed data
path is relative to the script-output-folder
Note: user actions are restricted to the script-output-folder
Example:
-- creates a file that contains a dummytext in the root-folder
dummyText = "bar"
game.makefile("foo.txt",dummyText)
-- creates another file (and folder if needed)
dummyText2 = "apple"
dummyNumber = 3.14159265359
game.makefile("recipies/applepie.txt",dummyText2 .." "..dummyNumber)
Code: Select all
Name: removepath(string path)
Returns: nothing
Description: removes everything in the specified path
path is relative to the script-output-folder
Note: user actions are restricted to the script-output-folder
Example:
-- remove the files which were created in the previous example
game.removepath("foo.txt")
game.removepath("recipies")