Jump to content

Any way around the 512 charters per line limit?


DarkAthena

Recommended Posts

I've got my script mostly working except that my onActivate block needs the first If line to be longer than 512 characters. Is there any way around this or a way to split the line? I've Googled around looking for an answer and haven't found anything helpful.

 

Thank you in advance!

Link to comment
Share on other sites

I wasn't even aware that there was a 512 character limit as I've never exceeded it before...

 

But post the code up and I'm sure there's a way to shorten it.

 

 

It's the Player.GetItemCount that's taking up the most space. Even with my items renamed to two-letter names it's still exceeding the limit. I have 17 items that I'm trying to add to the game and Player.GetItemCount typed 17 times is 323 characters, not counting the parenthesis or the >= or the spaces. Here is an example:

 

If (Player.GetItemCount Az >= 1) || (Player.GetItemCount Boet >= 1)

MessageBox "What do you want to do?" "Add", "Remove", "Nothing"

 

Only I need to list all 17 items on the first line before the MessageBox line because the script doesn't work if I try and split the items between two lines. Other than this 512 limit, the script works how I want it to work.

 

Thank you in advance!

Link to comment
Share on other sites

Can't see why multiple lines wouldn't work. Maybe for readability reasons use an additional variable, like:

 

set found to 0
if ( player.getitemcount aa > 0 ) || ...
set found to 1
elseif ( player.getitemcount xx > 0 ) || ...
set found to 1
elseif ...

endif

if found
messagebox (...)
endif

Edited by Maskar
Link to comment
Share on other sites

Or most easily :biggrin:

 

set i to (player.getitemcount aa) + (player.getitemcount xx) + .. ; or split into 2 or more lines

if ( i > 0 )
 ; do your stuff
endif

[/quote

 

So maybe something like this?

 

 

scn KateItemScript

Short Button  ;Which button was selected?
Short kCount  ;How many items are in the display case?
Short i  ;First item
Short m  ;Second item

Begin GameMode
set i to (Player.GetItemCount Az)
set m to (Player.GetitemCount xx)
End

Begin OnActivate
If (m >= 1) || (i >=1) && (kCount >= 1)
         MessageBox "What do you want to do with your items?" "Add", "Remove", "Nothing"
    ElseIf (m < 1) && (i < 1) && (kCount < 1)
         MessageBox "You have no items to add to the display case."
    ElseIf (m < 1) || (i < 1) && (kCount >= 1)
         MessageBox "Remove items from the display case?" "Yes", "No"
    ElseIf (m >= 1) || (i >= 1) && (kCount < 1)
         MessageBox "Add your items to the display case?" "Yes", "No"
    EndIf
EndIf
End

;Adding items to display case
Begin GameMode
Set Button to GetButtonPressed
If (Button == 0) && (m >= 1) || (i >= 1) 
    If kCount < 1
         ItemRef1.Enable
         Player.RemoveItem aa, 1
         Set kCount to kCount +1
    ElseIf kCount == 1
         ItemRef2.Enable
         Player.RemoveItem xx, 1
         Set kCount to kCount +1
    EndIf
EndIf
End

 

I'd like to be able to remove the items as well, by name, but there are 17 items and the message boxes only allow 10 choices, so I'd have to break the menu up, but I have no idea how to do that. I've read the tutorials on the Wiki, but I'm still rather new to scripting and it didn't make much sense to me.

 

I currently have a working script that will just add everything to the display case when I walk in the room, no interaction required, but it doesn't fit with the feel of the game and how things work in-game.

 

I can't seem to figure out how to get the script to even let me remove an item from the case.

 

I really, really appreciate all your help! Please let me know your ideas!

 

Thank you again, in advance!

Link to comment
Share on other sites

With the condition "Button == 0" (first button) you never check for the remove button. That would require a check for "Button == 1" (2nd button) as well.

 

I also don't understand the logic in the 2nd GameMode block. What is "kCount < 1" and "kCount == 1" supposed to do? (At least it should be "kCount >= 1", but I don't see the reason for that condition".

 

2 minor things, no errors, but unefficient:

- Don't make on Begin Gamemode just for 2 getitemcount commands. Integrate that into the 2 blocks using those values

- You should set a variable in the OnActivate Block, and execute the "Set Button to GetButtonPressed" and following commands only based on this variable. It doesn't make sense to always for input on every tick.

 

And one last advice: make a habit on using more brackets on conditional expressions.

(m >= 1) || ( (i >=1) && (kCount >= 1) )
; instead of 
(m >= 1) || (i >=1) && (kCount >= 1)

 

In all script languges I know, "&&" has precedence over "||", and there your condition would evaluate wrong results. Only in the CS languge "||" has precedence over "&&", and therefore you were lucky the condition was ok. But did you know? :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...