Summon genie script (magic lamp)

Post » Sat Jan 23, 2010 1:45 am

Hi all. I'm having problems at writing this easy script

Spoiler

Begin _magiclamp
short button

if ( onactivate == 1 )
MessageBox "Do you see an old lamp, what dou you want to do??", "rub it", "leave"
set button to GetButtonPressed
if ( button == 1 )
Messagebox "A genie appears in front of you" "Ok"
placeatpc "DM_genie" 15566 7665 1999988
else
return
endif
endif

end


When the player chooses "leave" it works well, but, when selecting "rub it" it makes the same as "leave", the messagebox dissapears and you can repeat this process all times you want, but the enie does′nt appear...why?

Thanks
User avatar
Minako
 
Posts: 3379
Joined: Sun Mar 18, 2007 9:50 pm

Post » Sat Jan 23, 2010 10:04 am

Change it to if ( button == 0 ). 0 is the first button, 1 is the second, and so on.

I saw that English isn't your best language in another thread, so you should change "Do you see an old lamp, what dou you want to do??" to "You see an old lamp. What do you want to do?" Multiple question marks are generally not seen in formal writing. I'd capitalize "rub" and "leave" also. You probably don't really need the else and return either, since if button == 1 it should just close the message box.
User avatar
Jonathan Windmon
 
Posts: 3410
Joined: Wed Oct 10, 2007 12:23 pm

Post » Sat Jan 23, 2010 3:04 am

Personally I'd take some of that code outside the OnActivate loop and rename the script so that it doesn't start with an underscore, as I believe that can cause problems.

Also, the [ CODE ] tags are the best way to post scripts as you can indent them nicely.

Here is a script (untested) using all the changes that have been suggested so far:

Begin dm_magiclampshort buttonshort messageOnif ( OnActivate == 1 )	MessageBox "You see an old lamp. What do you want to do?", "Rub it", "Leave"	set messageOn to 1endifif ( messageOn == 1 )	set button to GetButtonPressed	if ( button == 0 )		Messagebox "A genie appears in front of you" "Ok"		placeatpc "DM_genie" 15566 7665 1999988	endif	if ( button >= 0 )		set messageOn to 0	endifendifend


Good luck!
User avatar
Ryan Lutz
 
Posts: 3465
Joined: Sun Sep 09, 2007 12:39 pm

Post » Fri Jan 22, 2010 6:54 pm

Well, now it says that the direction on line 15 is wrong and cannot be compiled: -10363.807 -71163.914 166.306 that coordinates

Thanks for the script and the grammar correction, I really need to improve my english haha
User avatar
Nitol Ahmed
 
Posts: 3321
Joined: Thu May 03, 2007 7:35 am

Post » Sat Jan 23, 2010 7:55 am

PLaceAtPC doesn't take absolute coordinates. It's parameters are [amount of items], [distance from player], [direction from player], where the last one is simply a number: 0=front; 1=back; 2=left; 3=right. There are PlaceItem/PlaceItemCell commands that take coordinates for parameters, but they are Tribunal-only.
User avatar
Frank Firefly
 
Posts: 3429
Joined: Sun Aug 19, 2007 9:34 am

Post » Sat Jan 23, 2010 6:11 am

Oh yeah, I didn't even think about that xD

If you want the genie to appear in front of the player, use something like this:

PlaceAtPC, "DM_genie", 1, 64, 0


According to Morrowind Scripting for Dummies, PlaceAtPC works like this:

PlaceAtPC, "Object_ID", count_enum, distance_enum, direction_enumDirections:0 = front1 = back2 = left3 = right


So here the count is 1, the distance is 64, and the direction is in front. Feel free to tweak the numbers to get it to work how you want it to.
User avatar
kiss my weasel
 
Posts: 3221
Joined: Tue Feb 20, 2007 9:08 am


Return to III - Morrowind