Script Question: Can an object's connections be polled?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Isaac
Posts: 3182
Joined: Fri Mar 02, 2012 10:02 pm

Script Question: Can an object's connections be polled?

Post by Isaac »

Does anyone know how (or if) an object's connection targets can be determined via script?

For example: If I wanted to connect three buttons (or 300) to various objects, and connect all of them to one specific script that could detect what [else] the calling button is connected to... Is this possible to do?
3socks
Posts: 11
Joined: Sun Nov 04, 2012 11:29 pm

Re: Script Question: Can an object's connections be polled?

Post by 3socks »

You could create this functionality by yourself.
Create a function called for example addMyConnector(object, event, target, action) and a table e.g. allConnections, where you will store all connections and connected objects to them.
In addMyConnector call addConnector on object with other parameters passed to this function. And then store what you want to the allConnections table. Use this function in your scripts anytime you want to create a connection.
Then you should have all the data you need in allConnections table.

Something like this:

Code: Select all

allConnections = {}
function addMyConnector(object, event, target, action)
    object:addConnector(event, target, action)
    if allConnections[object.id] == nil
    then
        allConnections[object.id] = {target}
    else
        table.insert(allConnections[object.id], target)
    end
end
Not sure if we can use table.insert function in our grimrock scripts, but I hope you got the idea of what I am trying to do.
User avatar
Isaac
Posts: 3182
Joined: Fri Mar 02, 2012 10:02 pm

Re: Script Question: Can an object's connections be polled?

Post by Isaac »

3socks wrote:...
That is pretty neat. I can see a use for it in my future projects. 8-)
Thanks
Post Reply