I could propably figure this one out myself too, but since I have participated in game making contest and time is starting to run out (less than 4 days for deadline) i better continue programming from elsewhere and let you guys tell me how to do this.
Problem is (example code):
Function comparestrings(string)
if table1.text = string then something
Endfunction
Table1 = { text = "currenttext" }
Table2 = { text = "new text" }
comparestring(table2.text)
I thought this would work so, that it compares "currenttext" with "new text". However, i dont know how Hollywood works in this case, but it gives me error about "Cant compare string to number".
When i used
DebugPrint(table1.text, string)
right before the line "If table1.text=string)" it shows that table1.text contains "currenttext" and string contains "new text".
Yet despite that, it complains it cant compare string with number?
What am i doing wrong here, what am i not understanding?
How to compare string from table from function with string?
Re: How to compare string from table from function with string?
I think you have error in some other place in your code.
Something like this should just work:
Something like this should just work:
Code: Select all
Function StrCmp(str1, str2)
If str1 = str2
DebugPrint("Supplied strings are the same")
Else
DebugPrint("Supplied strings are different")
EndIf
EndFunction
Table1 = {}
Table1.text = "Hello"
Table2 = {}
Table2.text = "Hello"
StrCmp(Table1.text, Table2.text)
WaitLeftMouse()
Re: How to compare string from table from function with string?
Thanks, i believe that StrCmp will work. I will try it today.