Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Doan Sephim

Pages: [1] 2 3 ... 36
1
Again, unless the documentation is wrong, FGets returns the number of bytes read, not the string pointer. So ReadNumber is reading from the wrong thing.

Ok, looks like the documentation might be wrong then... it returns the string pointer, so that part is fine.

Does the "sv plant" thing ring a bell? Are you using the str local variable anywhere else?
The "sv plant" thing kinda went over my head. I thought I'd read a few times to see if I could make sense of it, but I haven't been able to do that quite yet.

Edit: Oh, maybe I do get it now. It'd be reading from the text resource perhaps.... makes me wonder if this isn't just an artifact of terrible naming conventions on my part...I'll have to work these out a little bit to see if I can't fix it, now that I see where the error is coming in.

I also use the str variable in another script where I display the number and kinds of deaths. Here's the procedure:
Code: [Select]
(procedure (deathCountIterator integer)
(Display
(Format @str 650 integer)
dsCOORD 20 textDown
dsFONT 4
)
(= textDown (+ textDown 9))
)

Yes, it looks like this code is actually writing the text resource onto the str...

2
So this is weird. I simply moved the gDeaths array to the top of the variable list and everything seems to be working properly.

But other things are all screwy now...So is there something wrong with how I have declared [str 10]?

3
According to the docs, FGets takes 3 parameters:

http://scicompanion.com/Documentation/Kernels/FGets.html?highlight=fgets

And it returns the number of bytes read, not the string pointer.
Unless you're using some different kernel, or the docs are wrong, it doesn't look like this code works at all?
I run it a series of times:
Code: [Select]
(= fileHandle (FOpen "persist.tmp" 1))
(if (!= fileHandle -1)
(ReadTempFile 0)
(ReadTempFile 1)
(ReadTempFile 2)
(ReadTempFile 3)
(ReadTempFile 4)
(ReadTempFile 5)
(ReadTempFile 6)
(ReadTempFile 7)
)
(FClose fileHandle)
My understanding is that each call will return the next value down the line - which it does appear to do when working properly. Even when it's not "working properly" it still will make the value of the [gDeaths] variable arrays the corresponding numbers (it's just that the numbers are all wrong!)

Edit: from the attachment of the external file, it will set my arrays as follows: [gDeaths 0] = 2, [gDeaths 3] = 1, [gDeaths 6] = 1, and the rest will be 0.

4
I dunno if this helps, but those weird numbers are the following ascii letters:

svp[space]altn

which when you swap the order for each 16bit value (since SCI is little-endian), you get

"vs plant"

Sounds like maybe you overwrote the gDeath part of memory with a string? What variables come before the gDeath array in your global vars?
Thanks for the explanation.
the gDeath array is near the top, but looks like this:
Code: [Select]
(local
fileHandle
[str 10] ; Used to read from an external file and update several variables
[gDeaths 10] = [0 0 0 0 0 0 0 0 0 0]
And the procedure I'm using to "write-in" the variables from the external file is:
Code: [Select]
(procedure (ReadTempFile i)
(= [gDeaths i] (ReadNumber (FGets @str 8 fileHandle)))
)
Is there an issue with this?

5
My external file to keep track of deaths is not quite working properly, to say the least.
I've attached some pictures of the file open in the notepad and the first two look exactly as they should. The first number is the total times died, so the first one is 1, then 2 for the second, but then it goes to 29558 when it should be "3". The other numbers represent certain kinds of death, so there is a "1" in the first, two "1"s in the second picture, and then the numbers go crazy again. The "2" sticks out, but that is correct, as it means the player experienced the same "death" twice. But two of the huge number ones should still be 0.

Any idea how or what might be going on to get these numbers saved out?
My writing out of numbers code looks like this:
Code: [Select]
(= fileHandle (FOpen "persist.tmp" fCREATE))
(if (!= fileHandle -1)
(Format @str "%6d %6d %6d %6d %6d %6d %6d %6d" [gDeaths 0] [gDeaths 1] [gDeaths 2] [gDeaths 3] [gDeaths 4] [gDeaths 5] [gDeaths 6] [gDeaths 7])
(FPuts fileHandle @str)
)
(FClose fileHandle)
One question I do have is what the "6" in "%6d" stands for.

I don't think it's an error in my code to change the variable in the script itself, as my code for that is simply adding by ones:
Code: [Select]
(if (not [gDeaths 6])
(++ gUniqueDeaths)
)
(++ [gDeaths 6])
(= dyingScript (ScriptID DYING_SCRIPT))
(dyingScript
caller: 711
register:
{\nHungry things have to eat. But maybe next time try not letting the food be you!'}
)
(gGame setScript: dyingScript)
It feels like the numbers must be getting mangled in the saving "out" process, but I'm kinda at a loss.

6
SCI Syntax Help / Re: How to "look at" Inventory Items?
« on: June 14, 2022, 02:06:28 PM »
Doesn't there need to be a '/' before the word in the said property? Otherwise it's looking for "hammer" in the first part of the phrase you typed in.

The code needs to do this:
Code: [Select]
(Said 'look>')
followed by this:
Code: [Select]
(Said '/hammer')
which is basically the equivalent of
Code: [Select]
(Said 'look/hammer')
That could be. I will check it out.
Edit 1: Yes, that does help!

Edit 2: I'm getting the same result, which is a "Oops! You tried something we didn't think of" crash error. I was getting that before with Erik's code, so it's not the /hammer part. I wonder if he has more and/or less to his template that's fixing for this. I'll test around and see if I can determine exactly what's causing the crash.

Edit 3: The part that is causing the crash is the "(i ownedBy: gEgo)" and the "(i showSelf:)" I'm guessing variables cannot be used in this way? So any idea what's allowing it to work with Erik's template? He put "i" as a variable to the changeState method, and I followed that example in my code as well.

Good news is that now it's identifying the typed command by the player, now all that's left is how to spit out the correct description.

Edit 4: So I apparently did not put &tmp beofre the i in the method when declaring the variable. Everything now seems to work correctly. Looks like this one is solved. Erik's code works exactly as intended, but Troflip, THANK YOU, I would not have ever thought of the said properties needing the "/" - and that was clearly a huge component of my problems.

7
SCI Syntax Help / Re: How to "look at" Inventory Items?
« on: June 13, 2022, 09:14:26 PM »
What does the said property look like for your inventory items?
Something like this:
Code: [Select]
(instance Hammer of Iitem ; Item 2
(properties
said 'hammer'
description 2
owner 0
view 612
loop 0
cel 0
script 0
name "Hammer"
)
)

8
SCI Syntax Help / [Solved] SCI0 How to "look at" Inventory Items?
« on: June 12, 2022, 11:22:17 PM »
Here's my problem:
When the player types "look at widget," how do I open that item [the widget] as if from the inventory menu? I've looked at the Inv script as well as the following bit of code from ErikorOakford's SCI0 template:
Code: [Select]
((Said 'look[<at]>')
(cond
;look at inventory items
((= i (inventory saidMe:))
(if (i ownedBy: ego)
(i showSelf:)
else
(DontHave)
)
)
But I've been unable to produce anything beyond opening up the menu with all the items listed by using the same command as in the menubar:
Code: [Select]
(gInv showSelf: gEgo) That's nice and all, but I'd like to zero in on the particular item "looked" at by the plater.
Erik's script looks like it should work (and I'm sure it does in his template), but I'm using the standard template, and even correcting for a few differences in naming conventions, I'm still not returning anything that runs.
I know it's actually a fairly simple command, something already there in the template, I'm just not fitting the pieces together and need a hand.
Thanks.

9
SCI Syntax Help / Re: SCI0 - gEgo and barriers
« on: May 25, 2022, 10:56:27 AM »
Going by the later StopWalk's doit, it checks (if (client isStopped:). That's available in the SCI0 template as well, and checks if the actor's mover actually moved. So if you want to detect walking into a barrier, that's how you might do it.
Seems easy enough. I just added "gEgo setMotion: NULL" to trigger from that if statement and that does the trick. Thanks

10
SCI Syntax Help / SCI0 - gEgo and barriers
« on: May 25, 2022, 09:26:10 AM »
Does anyone know where to look to find the programming controlling when gEgo hits a barrier? I find it curious that when gEgo hits a barrier and stops that the command to continue in that direction (say if the barrier is removed) is still active. I would think that movement would be set to null upon hitting a barrier and I'd like to implement this.

So, can anyone point me in the right direction and/or explain any potential problems of implementing such a change/

11
SCI Syntax Help / Re: SCI0 - Globalizing my local death sheet Script
« on: February 21, 2022, 09:03:23 PM »
Great! That worked perfectly once I incorporated my iteration code.

I think the thing I was really missing out on was what class to make it. I think I was confused when I tried to follow the QfG1 script's direction when I also made it of the object class, but Companion didn't like that because I didn't realize in the template game the class is Obj (and the capital O matters!)

Thanks for helping me troubleshoot this. It feels really good to have this squared away.

12
SCI Syntax Help / Re: SCI0 - Globalizing my local death sheet Script
« on: February 21, 2022, 04:41:37 PM »
No, the iteration is working properly. It's only showing the ones that have their conditions met.

The thing I'm having problems with is writing the code to properly display them in a window, and then closing that window. I build the code in a random roomscript and it works, but I'm not able to make it its own script (so that I can trigger it from say, the menubar)

13
SCI Syntax Help / Re: SCI0 - Globalizing my local death sheet Script
« on: February 21, 2022, 03:32:31 PM »
Okay, rewriting the whole script and editing it piece by piece isn't going to work for me with all the different syntax and especially different classes that I can't access on my end. I'm just going to try and focus on the part that I'm having the most difficulty with, and that is the process of iterating through a series of variables and displaying something on those that are true. This seems to be the relevant code:
Code: [Select]
(method (init &tmp i temp1 y fgColour totalWeight [str 40])
(super init:)
(= theWindow
(NewWindow nsTop nsLeft nsBottom nsRight {} 0 -1 vBLUE vWHITE)
)
(Display 206 1 p_at 10 8 p_mode teJustLeft p_font 300 p_color vBLUE)
;You Are Carrying:
(= totalWeight (WtCarried))
(= i 1)
(= y 24)
(while (<= i 41)
(if (and (> [invNum i] 0) (> i 2))
(if (<= y 160)
(DisplayInventoryItem i 10 y)
)
(= y (+ y 9))
)
(++ i)
)
(cond
((== y 24)
(Display 206 2 p_at 40 (+ y 5) p_mode teJustLeft p_font 300 p_color vBLUE)
;Nothing
)
((>= y 174)
(Display 206 3 p_at 40 172 p_mode teJustLeft p_font 300 p_color vBLUE)
;. . . and more
)
)
this while loop is actually very similar to how I had tried to do this with my for loop. It'll make a new window than display things accordingly, which I think is the same thing I tried...so I guess I'll just have to figure out what the major differences are. This is so much headache for something that seems so simple and easy.

14
SCI Syntax Help / Re: SCI0 - Globalizing my local death sheet Script
« on: February 21, 2022, 03:05:54 PM »
Keep in mind I'm wrong at least half the time, but (use inv) might be the SCI0 template equivalent of (use Invent). Maybe try commenting out ;(use Invent) and see if it compiles without it. That would at least help identify what it needs from Invent.

You will probably need to change (include game.sh) to (include sci.sh). That should make the dsCOORD, etc. compile.
That's funny, I just had that issue :D At the moment I have the following:

Code: [Select]
(include sci.sh)
(include game.sh)
(use Main)
(use User)
(use SysWindow)
and that fixed the dsWHATEVER problem you anticipated I was having XD It took me longer than I am comfortable sharing before I realized it was probably my includes causing the issue.

15
SCI Syntax Help / Re: SCI0 - Globalizing my local death sheet Script
« on: February 21, 2022, 02:43:42 PM »
Thanks for the links! This looks fruitful, albeit a bit above my knowledge level, but I'm able to at least make out what's going on. Converting it and structuring for my own use...we'll see  ;)
Thanks again for the links

If I were to make my own script, I would clearly use "Main" and "System", but I don't know what to do about "Invent" or if I'd need to include other scripts from the template

Pages: [1] 2 3 ... 36

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

Page created in 0.13 seconds with 21 queries.