Changelog
- Fixed crash bug reported here
- Fixed multiple shuttles being sent to stations with the same name
- Fixed certain chars in statioins names would crash
- Distance check is now done so that it's the train nearest the station not the player
Well it's supposed to happen in the sense that there is no code to make it not happen. However I hope to in the future make is so that it does not happen.Jackielope wrote:Is the Shuttle Train button on the top left supposed to show up before having researched Shuttle Trains? I recently added the mod to my list (and I'll also be supporting it with my 8L Train Project mod) so it has been brought into a map that has everything else researched. The button is also showing up on a save that has only just finished researching trains but hasn't built any yet.
Thaks for letting me know about the tsack size of only 1, that was an oversight and has been fixed for next releaseJackielope wrote:And thank you for making this mod! One thing I am really hoping can work with this is having a little electric monorail system or whatever that only transports the player character. Useful for going around the base.
I noticed you've got a bit of a problem in the code though: In the item.lua file you've got the stack size as 1. The vanilla game has locomotives stacking to 5. I've already changed the number in my own copy of your mod and that fixes the issue.
As for coding it so the button doesn't pop up until after the research is done, I'm not sure how to do it myself but I do know Choumiko and Outsider know how to do that since they both have mods that add a button on the top left after the mod has been researched. Choumiko has done work on YARM, FARL, SmartTrains, and TheFATController. Outsider has the Advanced Logistics Systems mod. Before directly asking them for some help it'd probably be worthwhile to dig through the coding to hopefully see what it would take to make the button only pop up after the research.
that's actually fairly easy : when creating the GUI, check if the player's force has the research complete (player.force.technologies["tech_name"].researched)simwir wrote: Thaks for letting me know about the tsack size of only 1, that was an oversight and has been fixed for next release
I will be sure to check out their code to see how they did it.
I don't really know how forces work so that might be part og it, but i did try to check you are mentioning. In the branch Call Button on line 60 of the control.lua i run this check (it's in a comment but let's pretend)StanFear wrote:that's actually fairly easy : when creating the GUI, check if the player's force has the research complete (player.force.technologies["tech_name"].researched)
if it is not, just create the GUI for all players of the force when a tech is researched (using event on_research_finished)
You might have to do a little thinking if you want to handle player changing forces
Code: Select all
player.force.technologies["shuttleTrain_tech"].researched
Code: Select all
/c game.player.force.technologies["shuttleTrain_tech"].researched = true
Ok i will take a look at thatRoktaal wrote:Check my Mod Iconizer. It handles research in a fairly simple way altho it doesn't handle players changing force
Code: Select all
script.on_event(defines.events.on_research_finished, function(event)
for player_index, player in pairs(game.players) do
addPlayerGui(player, event.research.name)
end
end)
Code: Select all
function addPlayerGui(player, research_name)
if (player.vehicle == nil or player.vehicle ~= nil and player.vehicle.name ~= "shuttleTrain") and player.gui.top.shuttleFrame == nil then
if research_name == "shuttleTrain_tech" or player.force.technologies["shuttleTrain_tech"].researched then
player.gui.top.add{type="frame", name="shuttleFrame", direction = "vertical"}
player.gui.top.shuttleFrame.add{type="button", name="shuttleTop", style="st_top_image_button_style" }
end
end
end
wow, this is overkillRoktaal wrote:This is a simple solution:
I've added
and changed function addPlayerGui toCode: Select all
script.on_event(defines.events.on_research_finished, function(event) for player_index, player in pairs(game.players) do addPlayerGui(player, event.research.name) end end)
This was enough to make the button appear only when the tech is researched.Code: Select all
function addPlayerGui(player, research_name) if (player.vehicle == nil or player.vehicle ~= nil and player.vehicle.name ~= "shuttleTrain") and player.gui.top.shuttleFrame == nil then if research_name == "shuttleTrain_tech" or player.force.technologies["shuttleTrain_tech"].researched then player.gui.top.add{type="frame", name="shuttleFrame", direction = "vertical"} player.gui.top.shuttleFrame.add{type="button", name="shuttleTop", style="st_top_image_button_style" } end end end
...but my OCD kicked in so I went further and removed the frame and redesigned button style. My personal preference is to avoid as much elements as possible so having only a button is better than having a button inside a frame, but thats my personal preference.
Good point. This should be better...StanFear wrote:first, here, you're adding the button to all player even those not in the force that did the research
Code: Select all
script.on_event(defines.events.on_research_finished, function(event)
addPlayerGui(game.get_player(event.player_index), event.research.name)
end)
For no particular reason except that I don't like doing anything inside event handlers. I know it's the same, it's just personal preference.StanFear wrote:seccound, instead of passing the tech name as a parameter, why don't you do the check in the on_research_finished ?
errr ... sorry but nop, the event from on_research_finished does not contain a player index ... (I'm working on this issue btw)Roktaal wrote:Good point. This should be better...StanFear wrote:first, here, you're adding the button to all player even those not in the force that did the researchCode: Select all
script.on_event(defines.events.on_research_finished, function(event) addPlayerGui(game.get_player(event.player_index), event.research.name) end)
indeed...I failedStanFear wrote:errr ... sorry but nop, the event from on_research_finished does not contain a player index ... (I'm working on this issue btw)Roktaal wrote:Good point. This should be better...StanFear wrote:first, here, you're adding the button to all player even those not in the force that did the researchCode: Select all
script.on_event(defines.events.on_research_finished, function(event) addPlayerGui(game.get_player(event.player_index), event.research.name) end)
You didn'tRoktaal wrote:indeed...I failedStanFear wrote:errr ... sorry but nop, the event from on_research_finished does not contain a player index ... (I'm working on this issue btw)Roktaal wrote:Good point. This should be better...StanFear wrote:first, here, you're adding the button to all player even those not in the force that did the researchCode: Select all
script.on_event(defines.events.on_research_finished, function(event) addPlayerGui(game.get_player(event.player_index), event.research.name) end)
Didn't have time to test it. Just wrote it out of my head
But, while in the event, checking for the researched value of the technology returns false...orzelek wrote:You didn'tRoktaal wrote:indeed...I failedStanFear wrote:errr ... sorry but nop, the event from on_research_finished does not contain a player index ... (I'm working on this issue btw)Roktaal wrote:Good point. This should be better...StanFear wrote:first, here, you're adding the button to all player even those not in the force that did the researchCode: Select all
script.on_event(defines.events.on_research_finished, function(event) addPlayerGui(game.get_player(event.player_index), event.research.name) end)
Didn't have time to test it. Just wrote it out of my head
Research event has technology and it gives you access to it's force. Through it you can access all the players that belong to it's force - can modify all players that were affected by the research.
If you can reproduce it I'd go and post a bug report.StanFear wrote: Oh, and actually, I tried to access the players, sometimes the player list was empty...
Hmm yeah, it should probably do that. I've added it as a feature request on the github pageEonasdan wrote:Could you please make the shuttle go back to manual drive mode after it reaches a station?
As it is now, once the shuttle reaches the requested station, you have to go into the train and click "Stop the train" before it is player drive-able.
Thanks!
What purpose would the small train have? Is the train size really a problem? Would it then also have a lower top speed or is there no drawbacks to a smaller train? Not really sure I see where the need is, but feel free to elaboratebchmura wrote:Hey, thanks for the mod! being able to easily suggest a destination will save me countless errors on turning the wrong way cause the train is going down the screen
I had a few ideas of what the mod may give me that I'll throw out as suggestions:
[*] A small personal shuttle train - game mechanics wise: Smaller sprite on screen, less resources to build, takes less damage, less fuel capacity, less fuel use.
[*] Electric version of the above, basically uses electricity from the grid and has a built in "accumulator" for going off grid for short distances.
I have some other ideas for train mods, but these fit in with what you are doing. I have a programming background and would be willing to try to make these for inclusion in your mod - here is the catch, I have no graphics skills at all. Prepared to be horrified level of skill I can ask around and see if anyone I know in that skill set would be willing to help me out with that part. In the meantime i can crop existing images down... maybe half of your image. anyway...
let me know what you think & thanks again