Updating the wiki mission scripting tutorial

zonkmachine
Posts: 37
Joined: Mon Sep 20, 2021 3:18 pm

Re: Updating the wiki mission scripting tutorial

Post by zonkmachine »

I'm looking over the tutorial again and it's seeing issues since last time.

After #5619 / Implement manual docking with orbital, some of the script examples has stopped working.
We use onShipDocked to connect the simpler test scripts to the game. and this seem to no longer work.

Just save this in data/modules/ and start Pioneer.

Code: Select all

print("This message will show up in the log")

local Comms = require 'Comms'
local Event = require 'Event'

local onShipDocked = function ()
    Comms.Message ('This message will not show up in comms')
end

Event.Register("onShipDocked", onShipDocked)
impaktor
Posts: 1003
Joined: Fri Dec 20, 2013 9:54 am
Location: Tellus
Contact:

Re: Updating the wiki mission scripting tutorial

Post by impaktor »

This is not just an artifact of "onShipDocked" event not being triggered if starting a new game with ship already docked? (I beleive that change was made "recently")

Anyway, I applaude the effort of bringing the wiki more up to date
zonkmachine
Posts: 37
Joined: Mon Sep 20, 2021 3:18 pm

Re: Updating the wiki mission scripting tutorial

Post by zonkmachine »

impaktor wrote: Fri Jul 05, 2024 6:39 pm This is not just an artifact of "onShipDocked" event not being triggered if starting a new game with ship already docked?
git bisect pointed to this PR but maybe that's where it happened. Any idea what other event could act as a substitute?
impaktor
Posts: 1003
Joined: Fri Dec 20, 2013 9:54 am
Location: Tellus
Contact:

Re: Updating the wiki mission scripting tutorial

Post by impaktor »

We have onGameStart, and plenty of other, like onShipFiring, see list of all events in margin here:

https://codedoc.pioneerspacesim.net/#LuaClass:Event

You could just add a note (and test that it is true): message will be shown next time player initiates docking / landing.
zonkmachine
Posts: 37
Joined: Mon Sep 20, 2021 3:18 pm

Re: Updating the wiki mission scripting tutorial

Post by zonkmachine »

impaktor wrote: Fri Jul 05, 2024 8:48 pm We have onGameStart, ...
onGameStart doesn't quite work. From the beginning of this topic:
https://forum.pioneerspacesim.net/viewt ... 6836#p6836

I see that sturnclaw already recommended creating a timer and I'll look into that method but I would like to try and find a simpler method for someone starting out with scripting.

It's mentioned in the tutorial here:
https://wiki.pioneerspacesim.net/wiki/I ... r_an_event

In my mind what would be needed is an event from when the game clock starts running. What onGameStart sounded like to me when I started out.
impaktor wrote: Fri Jul 05, 2024 8:48 pm You could just add a note (and test that it is true): message will be shown next time player initiates docking / landing.
Yes, that's good.
impaktor
Posts: 1003
Joined: Fri Dec 20, 2013 9:54 am
Location: Tellus
Contact:

Re: Updating the wiki mission scripting tutorial

Post by impaktor »

how about a counter: "number of shots fired", using onShipFired
zonkmachine
Posts: 37
Joined: Mon Sep 20, 2021 3:18 pm

Re: Updating the wiki mission scripting tutorial

Post by zonkmachine »

impaktor wrote: Sat Jul 06, 2024 10:39 am how about a counter: "number of shots fired", using onShipFired
Great idea!
zonkmachine
Posts: 37
Joined: Mon Sep 20, 2021 3:18 pm

Re: Updating the wiki mission scripting tutorial

Post by zonkmachine »

I would consider splitting onGameStart into two different events. In my mind when I see onGameStart I think of game time 0, when the clock start ticking away. Maybe split it into onGameLoad, for when a game is loaded, and onGameStart, which would be akin to a default timer set to go off at time 0? At least I think it would make sense for the scripting tutorials.
impaktor
Posts: 1003
Joined: Fri Dec 20, 2013 9:54 am
Location: Tellus
Contact:

Re: Updating the wiki mission scripting tutorial

Post by impaktor »

Btw, wiki code examples and such will sooner or later become obsolete.

I'd advice to add to the modding wiki, to encourage the student to look at simple modules we have, like the Advice module, 100 lines of code. then look at DonateToCranks for some menu interactions, and DeliverPackage for missions.
zonkmachine
Posts: 37
Joined: Mon Sep 20, 2021 3:18 pm

Re: Updating the wiki mission scripting tutorial

Post by zonkmachine »

impaktor wrote: Tue Jul 09, 2024 8:20 pm Btw, wiki code examples and such will sooner or later become obsolete.
Why, what? You mean the move to markdown?
Post Reply