aboutsummaryrefslogtreecommitdiff
path: root/assets/manual.html.LyXconv/manual.css
blob: ed26400615d0489ae0a0dce4aa1c853156558017 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
 
/* start css.sty */
.ecsx-1728{font-size:170%; font-weight: bold;}
.ecsx-1728{ font-weight: bold;}
.ecsx-1728{ font-weight: bold;}
.ecsx-1728{ font-weight: bold;}
.ecsx-1728{ font-weight: bold;}
.ecsx-1200{font-size:120%; font-weight: bold;}
.ecsx-1200{ font-weight: bold;}
.ecsx-1200{ font-weight: bold;}
.ecsx-1200{ font-weight: bold;}
.ecsx-1200{ font-weight: bold;}
.ectt-1000{ font-family: monospace;}
.ectt-1000{ font-family: monospace;}
.ectt-1000{ font-family: monospace;}
.ectt-1000{ font-family: monospace;}
.ectt-1000{ font-family: monospace;}
.ecsx-1000{ font-weight: bold;}
.ecsx-1000{ font-weight: bold;}
.ecsx-1000{ font-weight: bold;}
.ecsx-1000{ font-weight: bold;}
.ecsx-1000{ font-weight: bold;}
p.noindent { text-indent: 0em }
td p.noindent { text-indent: 0em; margin-top:0em; }
p.nopar { text-indent: 0em; }
p.indent{ text-indent: 1.5em }
@media print {div.crosslinks {visibility:hidden;}}
a img { border-top: 0; border-left: 0; border-right: 0; }
center { margin-top:1em; margin-bottom:1em; }
td center { margin-top:0em; margin-bottom:0em; }
.Canvas { position:relative; }
img.math{vertical-align:middle;}
li p.indent { text-indent: 0em }
li p:first-child{ margin-top:0em; }
li p:last-child, li div:last-child { margin-bottom:0.5em; }
li p~ul:last-child, li p~ol:last-child{ margin-bottom:0.5em; }
.enumerate1 {list-style-type:decimal;}
.enumerate2 {list-style-type:lower-alpha;}
.enumerate3 {list-style-type:lower-roman;}
.enumerate4 {list-style-type:upper-alpha;}
div.newtheorem { margin-bottom: 2em; margin-top: 2em;}
.obeylines-h,.obeylines-v {white-space: nowrap; }
div.obeylines-v p { margin-top:0; margin-bottom:0; }
.overline{ text-decoration:overline; }
.overline img{ border-top: 1px solid black; }
td.displaylines {text-align:center; white-space:nowrap;}
.centerline {text-align:center;}
.rightline {text-align:right;}
div.verbatim {font-family: monospace; white-space: nowrap; text-align:left; clear:both; }
.fbox {padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
div.fbox {display:table}
div.center div.fbox {text-align:center; clear:both; padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
div.minipage{width:100%;}
div.center, div.center div.center {text-align: center; margin-left:1em; margin-right:1em;}
div.center div {text-align: left;}
div.flushright, div.flushright div.flushright {text-align: right;}
div.flushright div {text-align: left;}
div.flushleft {text-align: left;}
.underline{ text-decoration:underline; }
.underline img{ border-bottom: 1px solid black; margin-bottom:1pt; }
.framebox-c, .framebox-l, .framebox-r { padding-left:3.0pt; padding-right:3.0pt; text-indent:0pt; border:solid black 0.4pt; }
.framebox-c {text-align:center;}
.framebox-l {text-align:left;}
.framebox-r {text-align:right;}
span.thank-mark{ vertical-align: super }
span.footnote-mark sup.textsuperscript, span.footnote-mark a sup.textsuperscript{ font-size:80%; }
div.tabular, div.center div.tabular {text-align: center; margin-top:0.5em; margin-bottom:0.5em; }
table.tabular td p{margin-top:0em;}
table.tabular {margin-left: auto; margin-right: auto;}
td p:first-child{ margin-top:0em; }
td p:last-child{ margin-bottom:0em; }
div.td00{ margin-left:0pt; margin-right:0pt; }
div.td01{ margin-left:0pt; margin-right:5pt; }
div.td10{ margin-left:5pt; margin-right:0pt; }
div.td11{ margin-left:5pt; margin-right:5pt; }
table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; }
td.td00{ padding-left:0pt; padding-right:0pt; }
td.td01{ padding-left:0pt; padding-right:5pt; }
td.td10{ padding-left:5pt; padding-right:0pt; }
td.td11{ padding-left:5pt; padding-right:5pt; }
table[rules] {border-left:solid black 0.4pt; border-right:solid black 0.4pt; }
.hline hr, .cline hr{ height : 1px; margin:0px; }
.tabbing-right {text-align:right;}
span.TEX {letter-spacing: -0.125em; }
span.TEX span.E{ position:relative;top:0.5ex;left:-0.0417em;}
a span.TEX span.E {text-decoration: none; }
span.LATEX span.A{ position:relative; top:-0.5ex; left:-0.4em; font-size:85%;}
span.LATEX span.TEX{ position:relative; left: -0.4em; }
div.float, div.figure {margin-left: auto; margin-right: auto;}
div.float img {text-align:center;}
div.figure img {text-align:center;}
.marginpar {width:20%; float:right; text-align:left; margin-left:auto; margin-top:0.5em; font-size:85%; text-decoration:underline;}
.marginpar p{margin-top:0.4em; margin-bottom:0.4em;}
table.equation {width:100%;}
.equation td{text-align:center; }
td.equation { margin-top:1em; margin-bottom:1em; } 
td.equation-label { width:5%; text-align:center; }
td.eqnarray4 { width:5%; white-space: normal; }
td.eqnarray2 { width:5%; }
table.eqnarray-star, table.eqnarray {width:100%;}
div.eqnarray{text-align:center;}
div.array {text-align:center;}
div.pmatrix {text-align:center;}
table.pmatrix {width:100%;}
span.pmatrix img{vertical-align:middle;}
div.pmatrix {text-align:center;}
table.pmatrix {width:100%;}
span.bar-css {text-decoration:overline;}
img.cdots{vertical-align:middle;}
.figure img.graphics {margin-left:10%;}
/* end css.sty */

an>name].max_speed=max_speed or 10 end advtrains.trains={} advtrains.wagon_save={} --load initially advtrains.fpath=minetest.get_worldpath().."/advtrains" local file, err = io.open(advtrains.fpath, "r") if not file then local er=err or "Unknown Error" print("[advtrains]Failed loading advtrains save file "..er) else local tbl = minetest.deserialize(file:read("*a")) if type(tbl) == "table" then advtrains.trains=tbl end file:close() end advtrains.fpath_ws=minetest.get_worldpath().."/advtrains_wagon_save" local file, err = io.open(advtrains.fpath_ws, "r") if not file then local er=err or "Unknown Error" print("[advtrains]Failed loading advtrains save file "..er) else local tbl = minetest.deserialize(file:read("*a")) if type(tbl) == "table" then advtrains.wagon_save=tbl end file:close() end advtrains.save = function() --print("[advtrains]saving") advtrains.invalidate_all_paths() local datastr = minetest.serialize(advtrains.trains) if not datastr then minetest.log("error", "[advtrains] Failed to serialize train data!") return end local file, err = io.open(advtrains.fpath, "w") if err then return err end file:write(datastr) file:close() -- update wagon saves for _,wagon in pairs(minetest.luaentities) do if wagon.is_wagon and wagon.initialized then wagon:get_staticdata() end end --cross out userdata for w_id, data in pairs(advtrains.wagon_save) do data.name=nil data.object=nil if data.driver then data.driver_name=data.driver:get_player_name() data.driver=nil else data.driver_name=nil end if data.discouple then data.discouple.object:remove() data.discouple=nil end end --print(dump(advtrains.wagon_save)) datastr = minetest.serialize(advtrains.wagon_save) if not datastr then minetest.log("error", "[advtrains] Failed to serialize train data!") return end file, err = io.open(advtrains.fpath_ws, "w") if err then return err end file:write(datastr) file:close() advtrains.save_trackdb() end minetest.register_on_shutdown(advtrains.save) advtrains.save_and_audit_timer=advtrains.audit_interval minetest.register_globalstep(function(dtime) advtrains.save_and_audit_timer=advtrains.save_and_audit_timer-dtime if advtrains.save_and_audit_timer<=0 then local t=os.clock() --print("[advtrains] audit step") --clean up orphaned trains for k,v in pairs(advtrains.trains) do --advtrains.update_trainpart_properties(k) if #v.trainparts==0 then print("[advtrains][train "..k.."] has empty trainparts, removing.") advtrains.trains[k]=nil end end --save advtrains.save() advtrains.save_and_audit_timer=advtrains.audit_interval printbm("saving", t) end --regular train step local t=os.clock() for k,v in pairs(advtrains.trains) do advtrains.train_step(k, v, dtime) end printbm("trainsteps", t) endstep() end) function advtrains.train_step(id, train, dtime) --TODO check for all vars to be present if not train.velocity then train.velocity=0 end --very unimportant thing: check if couple is here if train.couple_eid_front and (not minetest.luaentities[train.couple_eid_front] or not minetest.luaentities[train.couple_eid_front].is_couple) then train.couple_eid_front=nil end if train.couple_eid_back and (not minetest.luaentities[train.couple_eid_back] or not minetest.luaentities[train.couple_eid_back].is_couple) then train.couple_eid_back=nil end --skip certain things (esp. collision) when not moving local train_moves=(train.velocity~=0) --if not train.last_pos then advtrains.trains[id]=nil return end if not advtrains.pathpredict(id, train) then print("pathpredict failed(returned false)") train.velocity=0 train.tarvelocity=0 return end local path=advtrains.get_or_create_path(id, train) if not path then train.velocity=0 train.tarvelocity=0 print("train has no path for whatever reason") return end local train_end_index=advtrains.get_train_end_index(train) --apply off-track handling: local front_off_track=train.max_index_on_track and train.index>train.max_index_on_track local back_off_track=train.min_index_on_track and train_end_index<train.min_index_on_track if front_off_track and back_off_track then--allow movement in both directions if train.tarvelocity>1 then train.tarvelocity=1 end if train.tarvelocity<-1 then train.tarvelocity=-1 end elseif front_off_track then--allow movement only backward if train.tarvelocity>0 then train.tarvelocity=0 end if train.tarvelocity<-1 then train.tarvelocity=-1 end elseif back_off_track then--allow movement only forward if train.tarvelocity>1 then train.tarvelocity=1 end if train.tarvelocity<0 then train.tarvelocity=0 end end if train_moves then --check for collisions by finding objects --front local search_radius=4 --coupling local couple_outward=1 local posfront=advtrains.get_real_index_position(path, train.index+couple_outward) local posback=advtrains.get_real_index_position(path, train_end_index-couple_outward) for _,pos in ipairs({posfront, posback}) do if pos then local objrefs=minetest.get_objects_inside_radius(pos, search_radius) for _,v in pairs(objrefs) do local le=v:get_luaentity() if le and le.is_wagon and le.initialized and le.train_id~=id then advtrains.try_connect_trains(id, le.train_id) end end end end --new train collisions (only search in the direction of the driving train) local coll_search_radius=2 local coll_grace=0 local collpos if train.velocity>0 then collpos=advtrains.get_real_index_position(path, train.index-coll_grace) elseif train.velocity<0 then collpos=advtrains.get_real_index_position(path, train_end_index+coll_grace) end if collpos then local objrefs=minetest.get_objects_inside_radius(collpos, coll_search_radius) for _,v in pairs(objrefs) do local le=v:get_luaentity() if le and le.is_wagon and le.initialized and le.train_id~=id then train.recently_collided_with_env=true train.velocity=-0.5*train.velocity train.tarvelocity=0 end end end end --check for any trainpart entities if they have been unloaded. do this only if train is near a player, to not spawn entities into unloaded areas train.check_trainpartload=(train.check_trainpartload or 0)-dtime local node_range=(math.max((minetest.setting_get("active_block_range") or 0),1)*16) if train.check_trainpartload<=0 then local ori_pos=advtrains.get_real_index_position(path, train.index) --not much to calculate print("[advtrains][train "..id.."] at "..minetest.pos_to_string(vector.round(ori_pos))) local should_check=false for _,p in ipairs(minetest.get_connected_players()) do should_check=should_check or ((vector.distance(ori_pos, p:getpos())<node_range)) end if should_check then --it is better to iterate luaentites only once --print("check_trainpartload") local found_uids={} for _,wagon in pairs(minetest.luaentities) do if wagon.is_wagon and wagon.initialized and wagon.train_id==id then if found_uids[wagon.unique_id] then --duplicate found, delete it if wagon.object then wagon.object:remove() end else found_uids[wagon.unique_id]=true end end end --print("found_uids: "..dump(found_uids)) --now iterate trainparts and check. then cross them out to see if there are wagons over for any reason for pit, w_id in ipairs(train.trainparts) do if found_uids[w_id] then --print(w_id.." still loaded") elseif advtrains.wagon_save[w_id] then --print(w_id.." not loaded, but save available") --spawn a new and initialize it with the properties from wagon_save local le=minetest.env:add_entity(ori_pos, advtrains.wagon_save[w_id].entity_name):get_luaentity() le:init_from_wagon_save(w_id) else print(w_id.." not loaded and no save available") --what the hell... table.remove(train.trainparts, pit) end end end train.check_trainpartload=2 end --handle collided_with_env if train.recently_collided_with_env then train.tarvelocity=0 if not train_moves then train.recently_collided_with_env=false--reset status when stopped end end if train.locomotives_in_train==0 then train.tarvelocity=0 end --apply tarvel(but with physics in mind!) if train.velocity~=train.tarvelocity then local applydiff=0 local mass=#train.trainparts local diff=math.abs(train.tarvelocity)-math.abs(train.velocity) if diff>0 then--accelerating, force will be brought on only by locomotives. --print("accelerating with default force") applydiff=(math.min((advtrains.train_accel_force*train.locomotives_in_train*dtime)/mass, math.abs(diff))) else--decelerating if front_off_track or back_off_track or train.recently_collided_with_env then --every wagon has a brake, so not divided by mass. --print("braking with emergency force") applydiff=(math.min((advtrains.train_emerg_force*dtime), math.abs(diff))) else --print("braking with default force") applydiff=(math.min((advtrains.train_brake_force*dtime), math.abs(diff))) end end train.last_accel=(applydiff*math.sign(train.tarvelocity-train.velocity)) train.velocity=train.velocity+train.last_accel else train.last_accel=0 end --move --TODO 3,5 + 0.7 train.index=train.index and train.index+((train.velocity/(train.path_dist[math.floor(train.index)] or 1))*dtime) or 0 end --structure of train table: --[[ trains={ [train_id]={ trainparts={ [n]=wagon_id } path={path} velocity tarvelocity index trainlen path_inv_level last_pos | last_dir | for pathpredicting. } } --a wagon itself has the following properties: wagon={ unique_id train_id pos_in_train (is index difference, including train_span stuff)