News:

Simutrans.com Portal
Our Simutrans site. You can find everything about Simutrans from here.

Error using: command x (tool_build_way)

Started by Yona-TYT, September 12, 2016, 11:35:25 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Yona-TYT


Try loading the attached scenario.


Loading BDF font 'cyr.bdf'
Reading city configuration ...
Reading speedbonus configuration ...
Reading menu configuration ...
Reading object data from pak/...
Loaded /home/yona/Descargas/simutrans/pak/sound/horse.wav to sample 19.
Loaded /home/yona/Descargas/simutrans/pak/sound/crossing.wav to sample 20.
Reading menu configuration ...
Midi disabled ...
Calculating textures ...done
Creating cities ...
Creating cities: 1
Creating factories ...
Distributing 1 tourist attractions ...
Preparing startup ...
Loading BDF font 'cyr.bdf'
Show banner ...
Running world, pause=0, fast forward=0 ...
script engine started.
World destroyed.
script engine started.
sim: boden/wege/weg.cc:98: static weg_t* weg_t::alloc(waytype_t): Assertion `0' failed.


Thread 1 "sim" received signal SIGABRT, Aborted.
0xb7fdabc8 in __kernel_vsyscall ()
(gdb) where
#0  0xb7fdabc8 in __kernel_vsyscall ()
#1  0xb7b585c9 in __GI_raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#2  0xb7b59ca7 in __GI_abort () at abort.c:89
#3  0xb7b50e17 in __assert_fail_base (
    fmt=0xb7ca365c "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
    assertion=0x836a3e2 "0", file=0x836a3d0 "boden/wege/weg.cc", line=98,
    function=0x836a5a0 <weg_t::alloc(waytype_t)::__PRETTY_FUNCTION__> "static weg_t* weg_t::alloc(waytype_t)") at assert.c:92
#4  0xb7b50e9b in __GI___assert_fail (assertion=0x836a3e2 "0",
    file=0x836a3d0 "boden/wege/weg.cc", line=98,
    function=0x836a5a0 <weg_t::alloc(waytype_t)::__PRETTY_FUNCTION__> "static weg_t* weg_t::alloc(waytype_t)") at assert.c:101
#5  0x0809d6d3 in weg_t::alloc (wt=ignore_wt) at boden/wege/weg.cc:98
#6  0x0830cbfe in tool_build_way_t::get_besch (this=0x9a83620,
    timeline_year_month=23160, remember=false) at simtool.cc:2129
#7  0x0830d091 in tool_build_way_t::init (this=0x9a83620, player=0x89de210)
    at simtool.cc:2221
#8  0x081f4918 in script_api::param<script_api::call_tool_work>::push (vm=
    0x9a6cd20, v=...) at script/api/api_command.cc:195
#9  0x081f4701 in command_work (vm=0x9a6cd20) at script/api/api_command.cc:145
#10 0x0829c707 in SQVM::CallNative (this=0x9a6cd20, nclosure=0x9a94b10,
    nargs=5, newbase=9, retval=..., suspend=@0xbfffc72f: false)
    at squirrel/squirrel/sqvm.cc:1210

Dwachs

The last argument of the work function must be the (internal) name of a way (see class way_desc_x, member function get_name)

local tool = command_x(tool_build_way)
local err = tool.work(player_x(1), square_x( coordx[j+2].x, coordx[j+2].y ).get_ground_tile(), square_x( coordx[j+2].x+6, coordx[j+2].y ).get_ground_tile(), PUT_NAME_OF_WAY_HERE)

Using class command_x puts you in undocumented land. I think I should invent some properly named functions to issue such commands. Now that somebody is using this.

For use of this class, see my AI script. The AI builds ways, stations, depots, and vehicles.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Opens and immediately closes. ???



local tool = command_x(tool_build_way)
local err = tool.work(player_x(1), square_x( coordx[2].x, coordx[2].y ).get_ground_tile(), square_x( coordx[2].x+6, coordx[2].y ).get_ground_tile(),""+wt_road)





Dwachs


""+wt_road

will not work. You will need the raw name (untranslated) of an existing way object, for example "cobblestone_road" in pak64.

Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Still does not work.

local err = tool.work(player_x(1), square_x( coordx[2].x, coordx[2].y ).get_ground_tile(), square_x( coordx[2].x+6, coordx[2].y ).get_ground_tile(),"cobblestone_road")


If I put: ""+cobblestone_road, Index does exist.

Yona-TYT

My intention with this is to build the stations automatically.

Dwachs

This code works for me

local t = command_x(tool_build_way)
local err = t.work(player_x(1), {x=20, y=40, z=4}, {x=20, y=41, z=4}, "cobblestone_road")

Can't see what is wrong with your script.
Parsley, sage, rosemary, and maggikraut.

Yona-TYT


Doing some tests I found that "command_x(tool_build_way)" and "command_x(tool_set_climate)" are interfere with each other.


For example, if run first "tool_set_climate" I can no longer use "tool_build_way".


Is this a bug ?. ???

Dwachs

Difficult to say without script code. Could you please post the script and debug output (-debug 2)
Parsley, sage, rosemary, and maggikraut.

Yona-TYT

Quote from: Dwachs on September 15, 2016, 06:07:42 AM
Difficult to say without script code. Could you please post the script and debug output (-debug 2)
I think it was a error from the savegame, I was solved with a new map.

Now the problem is it locks when the "command_x (tool_set_climate)" and then "command_x (tool_build_way)" is used.
Quote from: Yona-TYT on September 14, 2016, 09:41:11 PM
Doing some tests I found that "command_x(tool_build_way)" and "command_x(tool_set_climate)" are interfere with each other.
For example, if run first "tool_set_climate" I can no longer use "tool_build_way".
Is this a bug ?. ???

To replicate load the savegame and then use the remove tool as public service.

If you remove the line "94-99" in "regions.nut" this does not happen.

if (opt == 0)
{                 
   local tool = command_x(tool_build_way)         
   local err = tool.work(player_x(1), square_x( coord_st1[j+2].x, coord_st1[j+2].y ).get_ground_tile(), square_x( coord_st1[j+2].x+6, coord_st1[j+2].y ).get_ground_tile(),"cobblestone_road")
           
}


Scenario: regions3-256x256.zip
Savegame: Savegame.sve


               

Yona-TYT

I think it's a problem with the function "is_work_allowed_here", I guess some restrictions still remains undocumented. ???

Dwachs

I cannot see anything wrong with the script. What should I do to trigger an error?
Parsley, sage, rosemary, and maggikraut.