Jump to content

Print to gwl log?


duncanhoyle

Recommended Posts

Is it possible to send debug output to the gwl file using print or something similar?

 

The reason I want to do this is that I've finished my cartridge but am having issues with the Android player performing my data storage and reloading during OnSave and OnResume events and I want to see what's happening. Originally I was using complex objects but have now simplified it down booleans and strings (all created with the Urwigo UI and not in Lua code) for the data I want to persist. Everything appears to work as intended in the emulator.

 

I've experimented with message boxes in the events and they appear in the gwl file but prints would be nicer. Also, the message box in the OnSave event didn't appear on screen or in the gwl. I assume this is because it happens after the cartridge has ended.

 

Thanks for any help

 

Duncan

Link to comment

Look at http://wherigobuilder.wikispaces.com/Wherigo+(Class) for the function LogMessage().

 

Thanks.

I've now debugged and have a much cleaner solution to what I wanted to achieve in my code

 

Now that I have a cartridge working on the emulator and Android I've managed to borrow an iPhone. After struggling to work out how to copy my cartridge across (eventually with Phone Stick windows application - I don't like iTunes!) I've come across the rather useful error when running my cartridge...

 

Lua Alert

Don't know how to call '<null>

 

Is there a way to create a log file on the iPhone similar to the one on Android? I see a console.log file but it just shows the same messages with a date stamp.

 

Thanks for any help

Edited by duncanhoyle
Link to comment

If you have print or logging statements in your cartridge, you'll get this error on some players.

 

I don't know what logging features will be available on the Wherigo Foundation player. I will, however, need to create some API methods and a UI to allow you to access the raw log files. That feature is at a big 0% right now until I can come up with some ideas as to how to present it to the user. I didn't even know some people were still using the log files, so I didn't think that a feature important enough to add to the WF site. Perhaps, during implementing that feature, I'll resurrect the visual log file viewer I created several years ago--or, at least, its spirit. No code necromancy.

Link to comment

I'm now building a cardridge that works on the emulator and on android, but trows the message:

Lua Alert - Don't know how to call <null>

 

Since this thread is one of four results I got with Google on a search for this message and the only with useful information. I hope somebody can give me more information.

 

If you have print or logging statements in your cartridge, you'll get this error on some players.

 

So I added the following code:

function appleSucks()
end
if nil == Wherigo.LogMessage then Wherigo.LogMessage = appleSucks end 

 

But that doesn't help. What also doesn't help is that I (in contrast with the emulator) don't get the function name that is null. And I don't seem to have access to any kind of logfiles on iOs.

 

Does anybody know how to debug a Wherigo on iOs, or should I just give up (after spending dozens of hours to get it working on iOs) and just release it for Android and Oregon?

 

Tc

Link to comment

I have an iPhone, so have to debug things occasionally. Usually, I just use Wherigo's message box to pop up variable values. If I need to keep track of a log, I can just append to a string. If I need something more complicated, like when I'm creating an over the top game like Whack-A-Lackey, Battleship, Cacher Pursuit, or Tetris, I create an item that has a bunch of debug or administrative goodies. For example, when I was first testing Whack-A-Lackey in the field, my admin control item had an option to set the field size, timers, score, or anything else I needed to test out or simulate. It was easier than going to a laptop, making a change, uploading it to a test listing on the Wherigo site (I now use the WF site for my tests), then downloading it through my phone. The admin item still exists in some of those cartridges, though there isn't usually a way to get to it without modifying the source code (all my cartridges are open source).

 

As you can see, there are a few good ways to go about debugging a cartridge.

Link to comment

Thank you for your response. It has already reduced some of my frustrations. Like you write, I did already create a Tester character that gives me control of many things I would like to change, and I'm using popup boxes to show debug messages.

 

My current problem is:

b = tobase(n2, chars);
_Urwigo.MessageBox({Text = '(j)' });

 

With the tobase function, intended to print numbers in a arbitrary base with arbitrary characters.

 

function tobase(num, str)
txt = txt .. 'tobase('..tostring(num)..', '..tostring(str)..')'..nl;
   _Urwigo.MessageBox({Text = txt });
  	Wherigo.LogMessage({Text= txt })
if 0 == num then
	txt = txt .. 'klaar' .. nl;
	_Urwigo.MessageBox({Text = txt });
	return '';
end
local pos = num % str:len() + 1
--txt = txt .. 'pos = '..tostring(pos)..''..nl;
--_Urwigo.MessageBox({Text = txt });
return tobase(math.floor(num/str:len()), str) .. str:sub(pos, pos)
end

I do get the "tobase" messages, but between the "klaar" (=finished in Dutch) popup and the "j" popup, I've get 7 "null" messages. And I don't know what causes them.

 

Did I miss something? Is there a way to see what goes wrong? I'm out of ideas right now.

 

Tc

Link to comment

So it's probably the recursion that throws the warning. Rewriting the function to the code below solves the function. A shame that a lua interpreter cannot handle recursive functions. So now I can rewrite them to loops :-( Hope this solves my problems.

function tobase(num, chr)
 	Wherigo.LogMessage({Text= 'tobase('..tostring(num)..', '..tostring(chr)..')' })
	local pos, str = 0, '';
while num > 0 do
	pos = num % chr:len() + 1;
	str = chr:sub(pos, pos) .. str;
	num = math.floor(num /chr:len());
	Wherigo.LogMessage({Text= 'tobase('..tostring(num)..', '..tostring(chr)..') => '..str })
end
_Urwigo.MessageBox({Text = 'tobase('..tostring(num)..', '..tostring(chr)..') '..tostring(str)..'' });
return str
end

 

Tc

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...