Author Topic: date in LSL5's instance Boarding_Pass of InvI  (Read 838 times)

0 Members and 1 Guest are viewing this topic.

Offline miracle.flame

date in LSL5's instance Boarding_Pass of InvI
« on: July 06, 2024, 09:38:30 AM »
Here's the Look method of a boarding pass
Code: [Select]
(method (doVerb theVerb invItem &tmp [temp0 200] temp200 temp201 temp202 temp203)
(switch theVerb
(2 ; Look
(= temp202 (& (= temp200 (GetTime 3)) $001f)) ; SysDate
(= temp201 (& (>> temp200 $0005) $000f))
(= temp203 (+ (>> temp200 $0009) 1980))
(Format ; "This boarding pass good for one First Class Seat on AeroDork Flight #1, %s to %s, seat %d%c, %s %d, %d only."
@temp0
19
30
(switch gLarryLoc
(0 {L.A.})
(1 {New York})
(2 {Atlantic City})
(3 {Miami})
)
(switch state
(0 {L.A.})
(1 {New York})
(2 {Atlantic City})
(3 {Miami})
)
(/ gAirplaneSeat 100)
(mod gAirplaneSeat 100)
[local0 temp201]
temp202
temp203
)
(TPrint @temp0 80 name)

I was about to change the formatting of the text to swap day and month inside 19.tex file as "AeroDork Flight #1, %s to %s, seat %d%c, %d. %s, %d only." so that it goes d. M, yyyy but that messed up and resulted in error 5.tex not found. I believe it can be done by altering the code itself but I have no clue what needs to be done. Can you help please?



Offline Kawa

Re: date in LSL5's instance Boarding_Pass of InvI
« Reply #1 on: July 06, 2024, 10:17:10 AM »
You cannot change the order (nor type!) of the placeholders in the text string without changing the arguments that follow.

For the record, local0 is months, while temp201 to 203 are m, d, y, extracted from the current system date. I'll refer to them as such from here on.

The pass text is formatted as follows:
  • String, the current location determined by an inline switch
  • String, the target location determined by another inline switch
  • Number, part of the seat number
  • Letter, part of the seat number (ASCII value)
  • String, today's month name according to the local array
  • Number, today's day
  • Number, today's year
And that is indeed the order the rest of the parameters appear in. Two switches, two bits of inline math about seats, a lookup in an array of strings, and two numbers.

So if you want to change this from "month day, year" to "day month, year", you need to not only change the placeholders around to match (from %s %d, %d to %d %s, %d) but you also need to move the arguments around so they go d [months m] y (or temp202 [local0 temp201] temp203 I guess) to match.

Offline miracle.flame

Re: date in LSL5's instance Boarding_Pass of InvI
« Reply #2 on: July 06, 2024, 11:00:49 AM »
OK so I had to swap lines
[local0 temp201]
temp202
and that worked with swapped placeholders! Great! Thanks!


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.056 seconds with 22 queries.