Dagon Scripting Problem


#1

Hello there guys.Yesterday I wanted to play around with scripting in LUA with Dagon.
I wanted to modify codes in Asylum to learn how scripting goes in Dagon but problem appeared :frowning:

I wanted to make script that “player comments before he picks key”,but code didnt worked as I expected.I launched Dagon but code didnt worked,only picking key worked, but that “comment” script didnt.Others scripting parts work absolutely fine but this one is problem :frowning:
Does anyone know how to fix it?
(see the pictur that I uploaded)



#2

It’s been a while since I last did some scripting in Dagon, but I’ll try…

Have you defined needKeyMale?

I’m assuming the code is in the Notes module. Do you also have the male key coded in the English module? I seem to remember that you need both.

Loading the room with the editor screen running in Dagon can be helpful and running the lua file through the debugger in LuaEdit 2010 can also catch errors.

Best of luck.


#3

Hey Imari!
My “key” code works but “keyFirstComment = true” is not working,I checked Notes.lua and English.lua everything is fine there but comment before picking key is not working :frowning:
Is there any way that when player picks key then he talks like "picking key,feed(“example.ogg”)?
Im new to LUA,I am experienced with C++ and Opengl(GLSL) :).Others codes works absolutely fine only that one is trick to me :frowning:


#4

Hi Alem,
If I understand what you are doing…

  1. When the player first clicks the key, you want the comment to play.
  2. When the player next clicks the key, it goes into “inventory.”

I’m no coder, but I’d try separating the two events.

  1. Toggle keyFirstComment with a separate spot that is enabled by default. Disable it after the comment plays. Enable the second spot.
  2. Make the second spot (the one that gets the key) disabled by default and enable it after the first spot plays the comment.

Will that work for you? Best of luck.


#5

Hi Imari!
I am little confused.Do you mean this?(see the picture)
It keeps crashing me,sorry I dont understand,can you code it for me ? :frowning:



#6

Try using the feed directly and without a sound file like:

We can see where the problem is from there.

Is there any error reports in console and which version of Dagon are you using (it says at the top of the console window)?

Also in your second picture you are missing the “if”.


#7

Hello CivanT
Im using the first version of Dagon(Asylum Interactive Teaser).
Im modding the Asylum(only for learning the scripting,nothing else)

Iv been checking the console everytime when I open the engine,and there are no problems there
I tried "feed(“This is my feed.)” but still its not working.Dagon keeps crashing :frowning:
I fixed that “if” that is missed and nothing happens :frowning:


#8

Try replacing your code with this:

keyFirstComment = true key = infirmary2:addSpot( Spot(DOWN, {500, 272}) ) key:attach(IMAGE, "infirmary2_keys.png") key:attach(FUNCTION, function() if keyFirstComment == true then feed("This is a feed.") keyFirstComment == false elseif needKeyMale == false then journal:addEntry(Notes.Entries.KEY_UNKNOWN, keyMaleThoughts) journal:tagEntry(Notes.Entries.KEY_UNKNOWN) foundKeyMale = true play("grab_key.ogg") self:disable() else journal:tagEntry(Notes.Entries.KEY_MALE) foundKeyMale = true play("grab_key.ogg") self:disable() end end)

If it works as you expect I will explain.


#9

Thank you very much man!
It works now !!! :slight_smile:
How did you did it?Other codes works absolutely fine,but this one tricked me so hard :frowning:


#10

Main problem in your code was after the first click it was closing the spot. Going from second picture of your code what happens is since self:disable() is out of if chain, it closes the spot and you can’t click it a second time. I moved that command to elseif and else conditions to make sure it doesn’t run at first click.

I hope this helps.


#11

I understand now :slight_smile:
Thanks alot man !!!