View Full Version : Dialog.Message error
midlander
03-19-2004, 02:32 PM
I have been using AMS4 for a little while now and love it but I am considering upgrading to take advantage of the wonderful new abilities of AMS5. So I just downloaded the trial version of AMS5 Pro.
Ran into a snag right off the bat. I endered this code into the OnClick action for a graphic.
result = Image.GetPos("Image1");--get top/left
Dialog.Message("Notice", result);--tell me the top/left
but I get On Click, Argument 2 must be of type string.
I thought type conversion were automatic with AMS?
I cant find in the documentation where it says that the GetPos returns a unique type or requires special conversions.
What am I doing wrong?????
Thanks in advance
GetPos returns a table:
if (result ~= nil) then
Dialog.Message("Notice", "X = " .. result.X .." \r\n\Y = " .. result.Y);--tell me the top/left
end
midlander
03-19-2004, 02:44 PM
Wow what a swift reply. Thanks
Here is the code now:
result = Image.GetPos("Image1");--get top/left
if (result ~= nil)then
Dialog.Message("Notice", result);--tell me the top/left
else
Dialog.Message("Notice", "nil");--tell me the top/left
end
Exact same error for line 3.
Im confused :ok
Yea, you caught me inbetween edits. I realized after I posted that, what was wrong. Look at the original (edited) reply.
Sometimes speedy answers need editing, especially when they are read just as quickly :)
Desmond
03-19-2004, 02:50 PM
Hello Midlander,
Image.GetPos returns a type table (not a string). In fact, the table contains two numbers, referenced by .X and .Y. So to output the position of the image, you will have to effectively reference two numbers.
Do this:
Dialog.Message("X Position", result.X);
Dialog.Message("Y.Position", result.Y);
Keep in mind that Image.GetPos is really returning two values in the form of a table, and u'll be set!
Desmond.
midlander
03-19-2004, 02:54 PM
Works perfectly!
Now, why the .. before and after???
I can sort of understand the result.X (guess getting the value for X) but why was the raw result not displayed??
Thanks again
The .. concatate (combines) strings in lua
"My" .. " Name " .. "is" .. " Brad"
would be the same as
"My Name is Brad"
midlander
03-19-2004, 03:01 PM
So many new features so little time. Thanks all.
Now I will go back to playing with AMS5.
:)
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.