Page 30 of 396
Re: Ask a simple question, get a simple answer
Posted: Wed Dec 10, 2014 9:32 am
by Grimfan
I want the reset to happen when the script timer elapses. The players must basically race against the clock to press the relevant buttons. If they don't do it in time I want the entire script to reset so they get another chance (no matter what button they are up to). At the moment it is only working once then doesn't reset a second time.
I hope that helps.
Re: Ask a simple question, get a simple answer
Posted: Wed Dec 10, 2014 12:35 pm
by TheLastOrder
Grimfan wrote:I want the reset to happen when the script timer elapses. The players must basically race against the clock to press the relevant buttons. If they don't do it in time I want the entire script to reset so they get another chance (no matter what button they are up to). At the moment it is only working once then doesn't reset a second time.
I hope that helps.
First of all sorry for any grammar mistakes.
I´m not an expert in scripting, so what I did for a similar (but not the exact) thing is:
You need the script, a timer, a counter and the proper controllers that solve the puzzle.
The timer starts everytime you activate the first controller-leverl-trigger, or whatever.
You want to link the timer to the counter. The counter value is originally 0, it grows to 1 when you start the countdown, and the timer decreases it to 0 again when the time has ended (disable self).
So in the script, you are telling basically that if those buttons have been pushed in the exact order AND the counter is 1, then, you open the door. If not, the door remains closed.
By the way: in the script you need to tell the counter to get the value of 1 everytime you start it, and start the timer as well.
Did you catch the idea?
Re: Ask a simple question, get a simple answer
Posted: Wed Dec 10, 2014 1:02 pm
by TheLastOrder
The damage is ridiculous.
I tried with the frostbolt, frostbolt_1 to _5 and moving up the level of the monster in the spawner.
Still ridiculous damage. I´d say the same...
Question: how can I do more damage with frostbolts spawned from a spawner?
Re: Ask a simple question, get a simple answer
Posted: Wed Dec 10, 2014 2:34 pm
by Grimfan
Thanks for the help TheLastOrder but I think this script alleviates the need for an external counter or timer... or at least I think it does.
The script is actually working, but only working once (it's not repeatable). There is some small syntax problem in it or a missing line that I'm not seeing because of my scripting inexperience.
What could it be?
Re: Ask a simple question, get a simple answer
Posted: Wed Dec 10, 2014 4:57 pm
by Thorham
Grimfan wrote:Thanks for the help TheLastOrder but I think this script alleviates the need for an external counter or timer... or at least I think it does.
The script is actually working, but only working once (it's not repeatable). There is some small syntax problem in it or a missing line that I'm not seeing because of my scripting inexperience.
What could it be?
Here's a working script that I did from scratch:
Code: Select all
buttonCount = 0
buttonList = {}
buttons = {}
buttons[1] = {id = "button_1", x = 11, y = 11, facing = 2, elevation = 0, action = "pressButton", door = dd_1}
buttons[2] = {id = "button_2", x = 5, y = 17, facing = 3, elevation = 0, action = "pressButton", door = dd_2}
buttons[3] = {id = "button_3", x = 22, y = 3, facing = 3, elevation = 0, action = "pressButton", door = dd_3}
buttons[4] = {id = "button_4", x = 7, y = 5, facing = 2, elevation = -1, action = "pressButton", door = dd_4}
buttons[5] = {id = "button_5", x = 1, y = 17, facing = 1, elevation = 0, action = "lastButton", door = dd_5}
text = {}
text[1] = ""
text[2] = ""
text[3] = ""
text[4] = ""
text[5] = ""
function init()
timer_1.timer:stop()
if buttonList[1] ~= nil then
removeButtons()
end
dd_6.door:close()
buttonCount = 1
timer_1.timer:enable()
spawnButton()
end
function pressButton(a)
timer_1.timer:stop()
a.go.clickable:disable()
spawnButton()
end
function lastButton(a)
timer_1.timer:stop()
timer_1.timer:disable()
a.go.clickable:disable()
hudPrint(a.go.id)
dd_6.door:open()
end
function spawnButton()
local a = buttons[buttonCount]
buttonList[buttonCount] = spawn("wall_button", 8, a.x, a.y, a.facing, a.elevation, a.id)
buttonList[buttonCount].button:addConnector("onActivate", "script_entity_2", a.action)
daemon_head_speaking_1.walltext:setWallText(text[buttonCount])
buttons[buttonCount].door.door:open()
buttonCount = buttonCount + 1
timer_1.timer:start()
end
function removeButtons()
local a
for a = 1, 5 do
if buttonList[a] ~= nil then
buttons[a].door.door:close()
buttonList[a]:destroy()
buttonList[a] = nil
end
end
end
Just add a timer called
timer_1 (or rename it in the script) . Disable the timer component of the timer in the editor, and set the timerInterval in the editor to how much time you want per button. If you want different amounts of time per button, then that's easy to add. After that, link the button/plate/whatever that starts the puzzle to the function
init() in the script.
The script runs more than once, will run again after completion, and can even be started again when the puzzle is active.
Re: Ask a simple question, get a simple answer
Posted: Wed Dec 10, 2014 11:19 pm
by bongobeat
Can the mine tileset be used on a 2 level dungeon ceiling, or more?
I'm getting some no-needed-visual-effect when trying to do a 2nd level ceiling.
edit:
I think I got the solution about the no desired visual things
you have to use the void tiles, then rebuild all walls, ceiling and floor, with the mine_elevation_edge, mine_ceiling and mine_floor
sorry to bother with so silly question
Re: Ask a simple question, get a simple answer
Posted: Thu Dec 11, 2014 7:00 am
by Grimfan
Thanks a lot for this script Thorham.
I'll try it out and tell you how it goes. Of course it has me wondering what went wrong with the other script?
Re: Ask a simple question, get a simple answer
Posted: Thu Dec 11, 2014 8:46 am
by Grimfan
Unfortunately Thorham's script isn't working 100% correctly either. It creates buttons which opens doors and spawns the next button in the chain until all the doors are opened, but it doesn't remove the buttons or repeat the process. Note that the first button which starts the chain of spawning buttons is button_0, which is supposed to open dd_1(door 1). The last button (button_5) opens dd_6 (door 6). Button_0 is also not a spawned button.
By the way, I have hooked button_0 up to the script init() and created a timer that the script links to. The timer is not being activated however. Is this because my first button is button_0 and not button_1?
Stranger and stranger...
Re: Ask a simple question, get a simple answer
Posted: Thu Dec 11, 2014 10:38 am
by Thorham
Grimfan wrote:Stranger and stranger...
Actually it's not so strange. The script is tested, but my instructions are incomplete. You have to connect the timer to the script function
removeButton and also tick
disableSelf for the timer in the editor.
Recap:
1. Make timer called
timer_1, or rename in script to what you want.
2. Disable timer's timer component.
3. Tick
disableSelf in timer's timer component.
4. Connect timer to script
removeButton function (for
onActivate event).
5. Set
timerInterval to what you want.
6. Connect a button/plate/whatever to script function
init (for
onActivate event) for starting puzzle.
The name of the button/plate/whatever that starts the puzzle is not important, because this button/plate/whatever only starts the puzzle, and is not accessed by the script in any way. The puzzle simply starts by calling the function. How it's called shouldn't matter.
I think I didn't forget anything this time
Edit: You might want to remove the
hudPrint which I forgot to remove from the script.
Re: Ask a simple question, get a simple answer
Posted: Thu Dec 11, 2014 1:12 pm
by Grimfan
With a few little personal tweaks it's working beautifully Thorham.
You are my new scripting hero!
And thanks for everyone's input. It was very much appreciated. You bring out the
in me.