matejcik / openwig

development continues at https://github.com/cgeo/openwig
3 stars 7 forks source link

GetAllOfType missing #160

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What cartridge are you playing?

- self written cartridges, Whack a Lackey

What is your phone/PDA manufacturer and model? What GPS are you using?

HTC Hero / Android 2.1 / WhereYouGo

What steps will reproduce the problem?
1. Play Whack a Lackey play anywhere cartridges
2. I could support writing special short cartridges for reproducing bugs if 
necessary

What is the expected output? What happens instead?

OpenWig Player contains several bugs if trying to use advanced LUA
OpenWig Player prints "you found a bug" message

If you see an error screen, please type its contents here:

sorry, no information in log -

What version are you using?

Newest WhereYougo Version

Please provide any additional information below.

I have programmed about 10 cartridges and detected 3 bugs - one at least you 
should already know and this is probably fixed or will never be fixed

All of these bugs should be reproduced playing the Whack a Lackey play anywhere 
cartridge - the source code is also available.

As far as I know there are at least the following bugs
1. table.getn not supported
2. dn = d:GetValue 'm' is the only method getting a value of object Distance, 
other methods crash
3. zcart:GetAllOfType method (to get a table e.g. from a zone) crashes

regards Andreas

Please contact me if I could support reproducing the bugs.

Original issue reported on code.google.com by bodensee...@gmail.com on 21 Sep 2011 at 5:00

GoogleCodeExporter commented 9 years ago
hi,

1. table.getn is deprecated in Lua 5.1 and you should use #varname instead.
however, because so many cartridges use it, i had to implement a compatibility 
function :e(

2. what do you mean by "other methods"? d:GetValue is the only supported method 
;e) okay, then there is d("m") and that should work too ... it was broken for 
some stupid reason, like me forgetting to update Kahlua when the underlying 
problem was fixed, but it will definitely work in the next update and beyond

using a variable of type Distance as a plain number is unsupported, because 
it's wrong (you can't type "60ft + 3" and expect it to work), but i might at 
some point implement adding two Distances together, and maybe multiplication 
("60ft x 2" is correct)
or, come to think about it, i might drop the Distance class altogether and use 
hacked-on functions for the GetValue calls. Distance is not useful at run-time 
anyway, it's there just to help cartridge creators.

3. yes, GetAllOfType is missing ... i believe it's not in Whack-A-Lackey, 
though, because Whack-A-Lackey works fine in the development build.
if you can send me a link to cartridge using GetAllOfType, that would be helpful

Original comment by matej...@gmail.com on 21 Sep 2011 at 12:03

GoogleCodeExporter commented 9 years ago
Hello,

I write my comments to the message.

Am 21.09.2011 14:03, schrieb openwig@googlecode.com:

fine, thats good to hear

I think d("m") is needed because in many cartridges used.

Yes absolutely clear.

A Cartridge I had to prepare - it was a test-cartridge (modified 
operational cartridge of mine) - the author of Whack-A-Lackey posted in 
groundspeak forum about the usage.
The link is:
http://forums.groundspeak.com/GC/index.php?showtopic=280707

Code-fragment is:

function  DeactivateAllZones(cartridge)
  for  _,zonein  ipairs(cartridge:GetAllOfType('Zone'))  do
   if  zone~=  nil  then
     zone.Active  =  false
   end
  end
end

So you should easily be able to test it - just call this function with 
current cartridge object.

If you need a Cartridge in gwc-format - I could prepare one.

Original comment by bodensee...@gmail.com on 21 Sep 2011 at 1:22

GoogleCodeExporter commented 9 years ago
Oh - only my fragments of my answer is there via email.

1. ok, fine to hear
2. it is absolutely clear for me, that I had to use d:GetValue or d("m") or 
d("ft") - I would never expect a good result using Distance other than this

3. test cartridge not yet existing - maybe I prepare one...

Original comment by bodensee...@gmail.com on 21 Sep 2011 at 1:30

GoogleCodeExporter commented 9 years ago
well, what kind of inputs does "GetAllOfType" expect?
you can write 'Zone', 'Task'? 'Item'? what happens if you say 
GetAllOfType('Strawberry') ?

(wherigo's type system is very bad...)

Original comment by matej...@gmail.com on 21 Sep 2011 at 1:41

GoogleCodeExporter commented 9 years ago
Am 21.09.2011 15:42, schrieb openwig@googlecode.com:

Hello,

Input of GetAllOfType could be in my oppinion all Wherigo Classes which 
belong to ZCartridge.

That means:
Zone
ZMedia
ZCharacter
ZItem
ZTimer

maybe also usefull (but I do not know) is
ZInput

I am not sure what Wherigo Developers thought and what is working on Garmin.

I tried Zone and ZMedia and will use of course
Zone
ZMedia
ZCharacter
ZItem
ZTimer
if available in OpenWig (and of course I-Phone Wherigo player)

My Usecase is to loop through the existing objects and do something - 
for example find the right object by name (e.g. for Media)
calculate distances zu all existing zones and activating the three which 
are nearest...

But maybe GetAllOfType is implemented in Garmin for alle predefined 
objects. That means that you could also get out the table of ZonePoints 
of a Zone or List of the Commands of a Item.

You should decide what is easy to implement and what not.

Original comment by bodensee...@gmail.com on 21 Sep 2011 at 2:13

GoogleCodeExporter commented 9 years ago
okay, thanks.
ZMedia, Zone, ZTask, ZTimer and ZItem/character is okay. (but in openwig, 
Characters and Items are the same thing, so ZItem and ZCharacter will return 
the same list. i will not fix this)
Commands could work too, but i will not add that until somebody tries to use it 
(it's more work and doesn't seem too useful)
ZonePoints are out of the question, that would be stupid .e)

not sure about ZInputs ... in openwig, ZInput is not an object at all. (it's 
just a table, same as tables you use for Messages. actually, you could write 
"Wherigo.GetInput {Text="blabla", InputType="Multiple Choice", 
Choices={"a","b","c"}, OnGetInput=CallbackCB123}" and it would work. i will 
have to try this on official player, because it should work too)

just a question, why do you need to find object by name? that doesn't seem 
useful

Original comment by matej...@gmail.com on 21 Sep 2011 at 2:25

GoogleCodeExporter commented 9 years ago
Finding objects by name.

I have 2 usecases

1. I use a Debug-Item and could move every zone to player.objectlocation 
and disable / enable it - so I could easily debug cartridges on 
operational device without going to the real place. So zone was entered 
in a Input-Dialog and I need to loop thru
the zones and find the right one.

2. I have implemented a cartridge with the Memory game. You have like a 
chess board fields with cards lying there - if you are on a field you 
can decide to see that card. In this case I need to return a Media 
Object. It makes not very much sense to put all media objects in a table 
with the cards, so I used the names of the media Objects und convert the 
names to the objects (sincerly: in the first implementation I used Media 
objects and got lot of problems on Garmin - with changing to simple 
Strings and then convert Strings to objects (I did it with if - then - 
elseif...) the cartridge was running on Garmin without problems).

I am trying to make a test-cartridge....

Am 21.09.2011 16:26, schrieb openwig@googlecode.com:

Original comment by bodensee...@gmail.com on 21 Sep 2011 at 2:39

GoogleCodeExporter commented 9 years ago
debug-item -> that makes sense

Memory game -> that doesn't make sense.
but i probably don't understand what you're saying. do you still have the
source code for that? i'd like to see it.
or just write a sample piece of (pseudo-)code for the first and the second
implementation?

(i don't need this to fix openwig, i'm just curious ;e) )

Original comment by matej...@gmail.com on 21 Sep 2011 at 2:50

GoogleCodeExporter commented 9 years ago
Here a test cartridge, built with Urwigo including source, gwc (only tested in 
emulator) - also included Urwigo-generated LUA which contains at the end User 
Code - that's what I massively use...

Original comment by bodensee...@gmail.com on 21 Sep 2011 at 3:24

Attachments:

GoogleCodeExporter commented 9 years ago
By the way...I forgot to mention TASKS - That yould be also fine to loop thru 
TASKS. That makes it much easier to determine if game is finished or not (e.g. 
you have to finish 7 out of 10 Tasks) - so if possible please allow also ZTask

Original comment by bodensee...@gmail.com on 21 Sep 2011 at 3:31

GoogleCodeExporter commented 9 years ago
...testcartridge on Garmon Oregon works - also with ZTask (which is 
wonderfull if you want to know how many Tasks are completed without 
counting)..

Entering Nonsense does works too (for sure there will be returned nil 
and not a list of strawberries...)

Am 21.09.2011 16:51, schrieb openwig@googlecode.com:

Original comment by bodensee...@gmail.com on 21 Sep 2011 at 3:45