Page 2 of 6
Re: General scripting issues and questions
Posted: Fri Sep 14, 2012 12:40 am
by Montis
Thanks.
Another question:
I tried to set a global variable and then using it in a
scripting hook.
Basically what I did was
Code: Select all
onMove = function(self, dir)
print(myvariable)
end
but it always prints out "nil". What am I doing wrong?
Re: General scripting issues and questions
Posted: Fri Sep 14, 2012 6:41 am
by petri
There are no global variables. We are considering adding variable setters/getters to the public interface of script entities.
Re: General scripting issues and questions
Posted: Fri Sep 14, 2012 6:47 am
by cromcrom
Oh yes please.
Re: General scripting issues and questions
Posted: Fri Sep 14, 2012 11:30 am
by Montis
Thanks for the answer.
Another question:
I want to emulate the random rumbles and screen shakes from the main game but at a specific point (after a trigger). I tried the following but the earthquake sound doesn't stop and loops forevermore.
Code: Select all
function rumblealot()
party:shakeCamera(1, 10)
playSound("earthquake")
end
I tried cloning the sound object(?) and setting the loop to false but that didn't work. I also tried only having the sound play at a specific location (playSoundAt()) but then it gave an error about "trying to play non-mono sound at location".
Any ideas besides importing a custom sound?
And still another question:
Is it possible to manipulate the map (and with that I mean the automap) per script? E.g make areas unexplored again or some such?
Re: General scripting issues and questions
Posted: Fri Sep 14, 2012 1:23 pm
by Montis
Montis wrote:I want to emulate the random rumbles and screen shakes from the main game but at a specific point (after a trigger). I tried the following but the earthquake sound doesn't stop and loops forevermore.
[omitted code]
I tried cloning the sound object(?) and setting the loop to false but that didn't work. I also tried only having the sound play at a specific location (playSoundAt()) but then it gave an error about "trying to play non-mono sound at location".
Any ideas besides importing a custom sound?
ok I could make it work with
Code: Select all
defineSound{
name = "rumble",
filename = "assets/samples/env/earthquake_01.wav",
volume = 0.5,
minDistance = 2,
maxDistance = 5,
loop = false,
}
but the sound cuts off apruptly at the end.
sucks a bit.
Re: General scripting issues and questions
Posted: Sun Sep 16, 2012 3:12 am
by Lmaoboat
I have a puzzle where you have to zap a trap mechanism to cause the traps in a nearby room to turn on the enemy. Since there's nothing to check for the state of a receptor, I have it teleport something into a pressure plate named "security" in a sealed room and check for the state of that plate. I don't get any errors from the script, and the pressure plate is being triggered, but when it's pressed, I don't even get the "successes" message in the console.
Code: Select all
if security:isDown() then
trap1:setTriggeredByParty(disable)
trap1:setTriggeredByMonster(enable)
print("success")
end
Re: General scripting issues and questions
Posted: Sun Sep 16, 2012 4:54 am
by Komag
I think you could forgo the rock on pressure plate trick and just have the receptor connect directly to the script with a "zaptrigger" function:
maybe this script will work:
Code: Select all
function zaptrigger()
trap1:setTriggeredByParty(disable)
trap1:setTriggeredByMonster(enable)
print("success")
end
Re: General scripting issues and questions
Posted: Sun Sep 16, 2012 4:57 am
by Lmaoboat
How do I go about connecting the receptor to the script?
Re: General scripting issues and questions
Posted: Sun Sep 16, 2012 5:00 am
by Komag
After you make the script, you just select the receptor and do a normal "Add Connector" and select the script item. The "Action" should automatically say "zaptrigger" (or whatever you want to name it in the script)
Re: General scripting issues and questions
Posted: Sun Sep 16, 2012 5:02 am
by Lmaoboat
Oh wow, didn't know it worked like that. This is going to make things much easier.