Jump to content

Scipting troubles


Raven7669

Recommended Posts

I a noob in regards to tes script writing and I am having difficulties gettin mine to work. Below is a smaller version of one I am working on and I can't seem to get it right. My ultimate goal is to write a script that will be assigned to a door which will only activate if a question is answered correcetly. The catch is I want it to ask a different question each time (up to five). I think if I can get the below script to work correctly It will solve the problems I am having with the larger one.

 

Begin Door_Test

 

short doorvar

short answer

 

if (menumode == 1)

Return

endif

 

if (onactivate == 1)

If (doorvar == 0)

messagebox "QUESTION","1","2"

set answer to GetButtonPressed

if (answer == -1)

return

elseif (answer == 2)

set doorvar to 1

else

set doorvar to 2

endif

endif

if (doorvar == 1)

activate

endif

if (doorvar ==2)

messagebox "door is locked"

endif

 

endif

 

 

end

 

Thanks for reading this

Link to comment
Share on other sites

I'm still having trouble with the meaagebox getbutton pressed stuff myself, and my brain is in idle mode toady, sorry i can't help with that script at the moment, but i replied because i had the idea that you could use 5 different question scripts and from the door script use startscript for the different questions. I'm not sure how you have this all set up to work i was just thinking an idea maybe relevant or not. I might be overcomplicating things again.

 

Also i saw somewhere a script that allows you to enter letters to spell a word up to 8 letters or something, So you have to actually know the answer and not just get a multiple choice question right by luck. Again I don't know if this is relevant.

 

I'll look at that script a little later when my brain starts working again.

Link to comment
Share on other sites

Thanks Kevin,

 

It a local script though not a glaobal and I don't know if it would work. Any way I solved the problem. I now have a script that I can use to ask question to someone trying to activate an object, If they get it right the object activates and they can always use it, if they get it wrong it summons a creature to fight. Next time you click on it it will ask a different question. The limit on question is how ever many u put in, or until you reach the script limits. If any one is interested I will post it.

Link to comment
Share on other sites

what is the problem you are having? (what isent it doing that it should and what is it doing that it shouldent?)

 

Begin Door_Test

short doorvar
short answer

//if (menumode == 1)|-- (dont need this becouse a mesage box counts as a menu
//Return|-- and if it only happens on activate it should be the only menu
//endif|-- available)

if (onactivate == 1) //this will only fire once and if it returns out of this loop will not 
                            // fire again thus negating your detecion of button presses
If (doorvar == 0)
messagebox "QUESTION","1","2"
set answer to GetButtonPressed
if (answer == -1)
return
elseif (answer == 2) // this needs to be 1 for question 2 im "fairly" sure
set doorvar to 1
else
set doorvar to 2
endif
endif
if (doorvar == 1)
activate
endif
if (doorvar ==2)
messagebox "door is locked"
endif

endif


end

 

i would add a "state" variable to keep track of what is hapening and if the on activate function returns 1 set the state to 1 then start the loop if the state is 1 changing it to -1 when the button processing step comes into play thus terminating the loop

Link to comment
Share on other sites

wookie, Thanks for the detailed response. This is actually a simplified version of a larger script. The menumode function is in there so that if a question is answered wrong the player can't go into the menu to avoid the effects of the spell.

 

The question thing was one of the problems, I forgot it assigned -1 for no button pushed then 0 for the 1st button pushed, 1 for the second and so on.

 

I actually got the script to work the other day, as written it can ask 5 different questions. If you get 1 right the door activates if you get it wrong you have to fight a creature and try again with a different question asked. Its the first script I have ever writtne so I was quite happy with it.

 

Working on my first mod and so far i have written about 5 scripts and created3 quest. Hopefully should be done within the next 2 weeks.

 

The interiors are done and now I just have to place creatures and items in the chests. I couldn't add any new meshes/textures b/c I am working on a laptop and I don't think it will handle the graphics programs required to do that.

 

Anyway if you want me to I will post my final script.

Link to comment
Share on other sites

Yeah its been a while since I have done anything like this. The last time I was writing programs it was either for pic processor or in C++.

 

I am still learnig, most of the time I have to use a base script from scripting for dummies and expand from that. But I am sure I will get better,

 

Thanks again for the help.

Link to comment
Share on other sites

Isn't very hard to make a script. just the learn is hard a little. about 8 days ago i can make nothing with the TES CS. now i can make enchanted books, hunterknives, new creatures, buildings, cities, magical effects. i have one enchanted book with journal updater script so if u wanna help i can.

:D

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...