[MOD 0.13.x] Shuttle Train v1.1.0

Topics and discussion about specific mods
simwir
Inserter
Inserter
Posts: 23
Joined: Wed Mar 16, 2016 7:24 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by simwir »

Mod is now updated with the changes by Stanfear

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

User avatar
Jackalope_Gaming
Fast Inserter
Fast Inserter
Posts: 230
Joined: Wed Oct 07, 2015 10:11 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by Jackalope_Gaming »

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.

simwir
Inserter
Inserter
Posts: 23
Joined: Wed Mar 16, 2016 7:24 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by simwir »

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.
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.

I'm happy that you are adding support for my mod :D

User avatar
Jackalope_Gaming
Fast Inserter
Fast Inserter
Posts: 230
Joined: Wed Oct 07, 2015 10:11 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by Jackalope_Gaming »

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.

simwir
Inserter
Inserter
Posts: 23
Joined: Wed Mar 16, 2016 7:24 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by simwir »

Jackielope 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.
Thaks for letting me know about the tsack size of only 1, that was an oversight and has been fixed for next release :D

I will be sure to check out their code to see how they did it.

User avatar
StanFear
Fast Inserter
Fast Inserter
Posts: 236
Joined: Sun Dec 15, 2013 2:49 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by StanFear »

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 :D

I will be sure to check out their code to see how they did it.
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

User avatar
Roktaal
Long Handed Inserter
Long Handed Inserter
Posts: 79
Joined: Sat Mar 26, 2016 6:42 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by Roktaal »

Check my Mod Iconizer. It handles research in a fairly simple way altho it doesn't handle players changing force

simwir
Inserter
Inserter
Posts: 23
Joined: Wed Mar 16, 2016 7:24 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by simwir »

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
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)

Code: Select all

player.force.technologies["shuttleTrain_tech"].researched
But it keeps returning false even if the research is complete. If i run the console command:

Code: Select all

/c game.player.force.technologies["shuttleTrain_tech"].researched = true
It will show as researched in the research menu, but not enable the button :/
Roktaal wrote:Check my Mod Iconizer. It handles research in a fairly simple way altho it doesn't handle players changing force
Ok i will take a look at that :D

User avatar
Roktaal
Long Handed Inserter
Long Handed Inserter
Posts: 79
Joined: Sat Mar 26, 2016 6:42 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by Roktaal »

This is a simple solution:
I've added

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)
and changed function addPlayerGui to

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
This was enough to make the button appear only when the tech is researched.

...but my OCD kicked in :mrgreen: 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.

User avatar
StanFear
Fast Inserter
Fast Inserter
Posts: 236
Joined: Sun Dec 15, 2013 2:49 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by StanFear »

Roktaal wrote:This is a simple solution:
I've added

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)
and changed function addPlayerGui to

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
This was enough to make the button appear only when the tech is researched.

...but my OCD kicked in :mrgreen: 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.
wow, this is overkill :)
first, here, you're adding the button to all player even those not in the force that did the research
seccound, instead of passing the tech name as a parameter, why don't you do the check in the on_research_finished ?

User avatar
Roktaal
Long Handed Inserter
Long Handed Inserter
Posts: 79
Joined: Sat Mar 26, 2016 6:42 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by Roktaal »

StanFear wrote:first, here, you're adding the button to all player even those not in the force that did the research
Good point. This should be better...

Code: Select all

script.on_event(defines.events.on_research_finished, function(event)
   addPlayerGui(game.get_player(event.player_index), event.research.name)
end)
StanFear wrote:seccound, instead of passing the tech name as a parameter, why don't you do the check in the on_research_finished ?
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.

User avatar
StanFear
Fast Inserter
Fast Inserter
Posts: 236
Joined: Sun Dec 15, 2013 2:49 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by StanFear »

Roktaal wrote:
StanFear wrote:first, here, you're adding the button to all player even those not in the force that did the research
Good point. This should be better...

Code: Select all

script.on_event(defines.events.on_research_finished, function(event)
   addPlayerGui(game.get_player(event.player_index), event.research.name)
end)
errr ... sorry but nop, the event from on_research_finished does not contain a player index ... (I'm working on this issue btw)

User avatar
Roktaal
Long Handed Inserter
Long Handed Inserter
Posts: 79
Joined: Sat Mar 26, 2016 6:42 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by Roktaal »

StanFear wrote:
Roktaal wrote:
StanFear wrote:first, here, you're adding the button to all player even those not in the force that did the research
Good point. This should be better...

Code: Select all

script.on_event(defines.events.on_research_finished, function(event)
   addPlayerGui(game.get_player(event.player_index), event.research.name)
end)
errr ... sorry but nop, the event from on_research_finished does not contain a player index ... (I'm working on this issue btw)
indeed...I failed
Didn't have time to test it. Just wrote it out of my head

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by orzelek »

Roktaal wrote:
StanFear wrote:
Roktaal wrote:
StanFear wrote:first, here, you're adding the button to all player even those not in the force that did the research
Good point. This should be better...

Code: Select all

script.on_event(defines.events.on_research_finished, function(event)
   addPlayerGui(game.get_player(event.player_index), event.research.name)
end)
errr ... sorry but nop, the event from on_research_finished does not contain a player index ... (I'm working on this issue btw)
indeed...I failed
Didn't have time to test it. Just wrote it out of my head
You didn't :D
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.

User avatar
StanFear
Fast Inserter
Fast Inserter
Posts: 236
Joined: Sun Dec 15, 2013 2:49 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by StanFear »

orzelek wrote:
Roktaal wrote:
StanFear wrote:
Roktaal wrote:
StanFear wrote:first, here, you're adding the button to all player even those not in the force that did the research
Good point. This should be better...

Code: Select all

script.on_event(defines.events.on_research_finished, function(event)
   addPlayerGui(game.get_player(event.player_index), event.research.name)
end)
errr ... sorry but nop, the event from on_research_finished does not contain a player index ... (I'm working on this issue btw)
indeed...I failed
Didn't have time to test it. Just wrote it out of my head
You didn't :D
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.
But, while in the event, checking for the researched value of the technology returns false...
Anyways, this has been solved (in a pending merge)

Oh, and actually, I tried to access the players, sometimes the player list was empty...

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by orzelek »

StanFear wrote: Oh, and actually, I tried to access the players, sometimes the player list was empty...
If you can reproduce it I'd go and post a bug report.
Considering that in single player you are there in the force I'd expect that there is always a player in there.

Eonasdan
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat May 07, 2016 4:45 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by Eonasdan »

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!

simwir
Inserter
Inserter
Posts: 23
Joined: Wed Mar 16, 2016 7:24 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by simwir »

Eonasdan 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!
Hmm yeah, it should probably do that. I've added it as a feature request on the github page

bchmura
Burner Inserter
Burner Inserter
Posts: 8
Joined: Fri May 27, 2016 3:22 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by bchmura »

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

simwir
Inserter
Inserter
Posts: 23
Joined: Wed Mar 16, 2016 7:24 pm
Contact:

Re: [MOD 0.12.x] Shuttle Train v1.0.1

Post by simwir »

bchmura 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
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 elaborate :)

As for the electric I really like the idea, I just have no idea how it would be done. It seems like there are some in the 5dim's mod, but haven't looked at how it's implemented.

As for art, I my self is not very good at graphics. When I first released the mod it was just with standard train textures, the green train texture that's on the trains now are from Roktaal. If you want to help out with the mod you totally can, just fork the github page, and make a pull request when you have a feature you think the mod needs. :)
You could also create issues over there for the features. I have created one for the electric trains for now.

Post Reply

Return to “Mods”