Page 1 of 2

Non-Asset scripting

Posted: Thu Nov 01, 2012 6:29 pm
by drakx
Im new to the game's editor (any in fact) and learning the scripting from scratch. I have the basics down easy enough since its mostly point and click but I am not enough of a coder or computer guru to start mucking about with changing base values for anything. I am using scripting and had a puzzle I wanted to do. basicaly once all 3 doors are open, a teleporter in an off room (one square wide, since its only purpose is to port in an item when the puzzle is solved) is something Im having issues with. I have the switches set up, they open the three doors, all linking the the right codding for a "combination" lock puzzle but I dont know how to link those three lua scripts into another script so that that script can check that all 3 doors are open and activate the teleporter. I dont really understand "connecters" or how to type them manualy (especialy the "event", "target", 'action"). I have looked through the threads and tried skimming in the super thread but I must be looking over it.

Im not trying to mess with anything serious, or break the game to let people run in walls or make custom skins, just want to know how to use the basic functions in the editor and learn a little more about scripting. Any assistance would be appreciated. Thank you.

Re: Non-Asset scripting

Posted: Thu Nov 01, 2012 6:56 pm
by Skuggasveinn
Hi Drakx and welcome to the forums.

There are many ways to do what you want to do.
I'm far from being the scripting genius around here but this is how I would do it.
(skip the teleporter, you don't really need it)

take the following script, and make a connector from your doors to it so the script gets checked when they open/close

Code: Select all

function areallopen()
	if door_1:isOpen() and
	door_2:isOpen() and
	door_3:isOpen() then
	spawn("youritem", 2, 22, 27, 3)
	else

	end
end
every time one of the 3 doors gets opened or close this will run and see if all are open, if not it will do nothing, but if they are it will spawn the item in question.
The thing you need to know about spawning is the number code, in this exemple its 2,22,27,3 that means the item will spawn on level 2, grid 22 27 and 3 is the facing (north east south west)

Hope this helps.
Skuggasveinn.

Re: Non-Asset scripting

Posted: Thu Nov 01, 2012 8:55 pm
by drakx
He only issue I have with that is that the door only has a tab for its open/closed state and for the addition of a pull chain. I don't see an add connector option in the interface which leaves me with my other issue, I don't know how to set up a connector by script dialog. Unless I'm missing something, I have never seen an add connector option on doors, just logic items

Re: Non-Asset scripting

Posted: Thu Nov 01, 2012 9:00 pm
by Komag
You can leave off the "else" unless you have something to put in there, like this:

Code: Select all

function areAllOpen()
   if door_1:isOpen() and
      door_2:isOpen() and
      door_3:isOpen() then
      spawn("youritem", 2, 22, 27, 3)
   end
end
Also, to be clear, something else needs to trigger the script function "areAllOpen", such as maybe an invisible pressure plate or switch or something. If the other function with your combination stuff is the thing opening the doors, just add in somewhere areAllOpen() and it will fire it off (so long as the functions are in the same script entity, otherwise it needs to be scriptName.areAllOpen() )

Re: Non-Asset scripting

Posted: Thu Nov 01, 2012 9:10 pm
by Skuggasveinn
I have the switches set up, they open the three doors
This is where you add the connectors to the lua script, to the switches that open/close the doors.
So every switch has 2 connectors , one that opens the given door, another that targets the script.

Re: Non-Asset scripting

Posted: Thu Nov 01, 2012 9:17 pm
by drakx
Thank you. I thought I had to have a connector to the script from the door itself.

Re: Non-Asset scripting

Posted: Thu Nov 01, 2012 10:06 pm
by drakx
On the topic of basic and vanilla scripting, how does the game make those gargoyle eye/mouth jewel puzzles? I can get the sockets to drop an item but the only info I can find is about asset coding them to change properties and I'm sure the game doesn't do something like that and only offer a fake prop/tool kit.

Re: Non-Asset scripting

Posted: Thu Nov 01, 2012 10:36 pm
by Komag
I can't quite understand that post. The daemon's are just props, it's the invisible sockets that hold the gems - the eye sockets are coded to only accept blue ones and the mouth a green one. You can define custom sockets to hold other things.

Re: Non-Asset scripting

Posted: Thu Nov 01, 2012 10:40 pm
by drakx
So I use the empty eye sockets with blue and the mouth with green? Thanks, I think I have been using just red ones. My appoplgies if the post was confusing. I meant to say that there had to be a mechanic I was missing since it was in the game but I couldn't get it to work in the editor.

Re: Non-Asset scripting

Posted: Fri Nov 02, 2012 2:13 am
by msyblade
To make the sockets take whatever you want, dl the asset pack, find the socket in scripts/objects.lua, copy it and paste it in object.lua in "your dungeon/mod_assets/scripts/objects.lua". In that text is a very obvious "blue_gem" script. (with the quotes). you can change that to what you want by making sure it's typed exactly as the editor calls it.On that topic, in the custom alcoves thread, they've made one that takes swords like, down the throat for a really cool weapon daemon head.