News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

squirrel script - ::debug.pause() not work

Started by Andarix, Yesterday at 03:46:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andarix

I can't say where the error lies. Whether it's with me, the script, or the program.

In any case, I can no longer use `debug.pause()` without getting an error message.

ceeac

#1
Adding a debug.pause() to the start() function of sqai_rail works correcly in r12139. Maybe the debug table is overwritten somewhere?

EDIT: There are variables named 'debug' all over the place that are set in the constructor of various classes but are not declared in the class. Maybe that is the cause? In any case IMO these should be renamed to e.g. 'debug_enabled' to reduce confusion.

victor_18993

I was able to reproduce the exact error message, but it does not appear to be a regression in Simutrans.
debug.pause() is still registered and working correctly in 124.5.1 and in the current trunk. The problem seems to be related to Squirrel name resolution.
There are two situations that can produce exactly:
[the index 'pause' does not exist]The first is name shadowing. For example,
sqai_rail/basic.nut has a member called:
debug = falseInside a method where that member is visible,
debug.pause() tries to access
pause on that local/member value instead of on Simutrans' global
debug table.
In that case, using:
::debug.pause()explicitly accesses the global table and should work.
The second possibility is that some script has replaced or modified the global
::debug table itself.
You can distinguish the two cases quickly with:
print("debug=" + (typeof debug) + " ::debug=" + (typeof ::debug))
foreach(k,v in ::debug) print("  key " + k)

If you get something like:
debug=bool ::debug=tableand
pause appears in the keys, then it is a name-shadowing issue and
::debug.pause() should solve it.
If
::debug is a table but
pause is missing, then something in the scripts has replaced or modified the global
debug table; in that case I would search for assignments such as
debug <- or
::debug <-.
I also checked the current
sqai_rail sources: the calls in
astar.nut already use
::debug.pause(), so your line 4683 is probably from a modified/local version of the script.
So at this point I don't think a Simutrans trunk change is needed. The binding itself is working correctly.
En la vida todo son vivencias y cada una de ellas nos hace mas grandes,¿Como de grande eres tu? :)

prissi

IN any case, it may be a good idea to update squirrel to the next stable. There is a script to update squirrel, but it does not work out of the box on Mingw on Windows. (Although, there might be merging conflict, I forgot.)

Andarix

I had set 'debug = false' to disable debug messages. I didn't expect that to delete everything else, though.

prissi

On could force timeline off on loading games with invalid years as an easy fix