getroomVariables contains error

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

aliko
Posts: 117
Joined: 09 Mar 2013, 16:26

getroomVariables contains error

Postby aliko » 29 Jan 2015, 08:35

Hello,

This is my room variables;
r.getVariables().toString() : vars:[[RVar: created_date, type: 4, value: 2015-01-29 09:25:54, isPriv: false], [RVar: playera, type: 4, value: xxx, isPriv: false], [RVar: playerb, type: 4, value: , isPriv: false], [RVar: botgame, type: 1, value: true, isPriv: false], [RVar: gamestatus, type: 2, value: 0, isPriv: false]]

But when i try to run this , i'm getting false, but botgame variable is exist.
r.getVariables().contains("botgame") : false


What did I wrong can you help me please?

Best Regards
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: getroomVariables contains error

Postby Lapo » 29 Jan 2015, 12:45

Hi,
there's a problem with your code.
room.getVariables() returns a List<RoomVariable>

If you call contains("something") on that list you're searching for the String "something" inside a List that doesn't even contain strings (it contains RoomVariable types)

What you probably wanted to do is this:

Code: Select all

room.containsVariable("varName");


which will return true, if a RoomVar with that name exists.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 22 guests