Post new topic    
Liquid Metal Slime
Send private message
Else If 
 PostSun Sep 09, 2012 12:42 am
Send private message Reply with quote
Here is some sample code taken directly from the plotscripting dictionary:

Code:
plotscript, test, begin
if (inventory (item:apple)) then (
  show text box (10)  # "Apples! My favourite!"
) else if (inventory (item:orange)) then (
  show text box (11)  # "My, what a tasty looking orange..."
) else if (inventory (item:pear)) then (
  show text box (12)  # "Perhaps if you gave me that pear..."
) else (
  show text box (13)  # "Come back when you have something tasty for me!"
)
end


Trying to compile this in while result in an error in this line:

") else if (inventory (item:orange)) then ("

"Unrecognized name elseif. It has not been recognized as a script, constant, variable, or anything else."

What's up with this?
Super Slime
Send private message
 
 PostSun Sep 09, 2012 1:47 am
Send private message Reply with quote
I think else if is supported in the nightly versions. The wiki is probably not that current, so it's probably a mistake.
Mega Tact v1.1
Super Penguin Chef
Wizard Blocks
Liquid Metal King Slime
Send private message
 
 PostSun Sep 09, 2012 5:46 am
Send private message Reply with quote
That is correct. "else if" is not supported in the Alectormancy release, but TMC just recently added it to the nightly wip versions.

I assume you were reading http://HamsterRepublic.com/ohrrpgce/docs/plotdict.xml which documents the nightly wip version, rather than the current stable version.
Metal Slime
Send private message
 
 PostSun Sep 09, 2012 10:20 am
Send private message Reply with quote
Oh wow this is incredibly great news.

Slightly late, since I just wrote a ton of code just a couple days ago that could have benefited from else if

But this is a good reason to refactor all my stuff in general.
Liquid Metal Slime
Send private message
 
 PostSun Sep 09, 2012 11:40 pm
Send private message Reply with quote
That sucks. I updated to the nightly version, but I can't use it because of some new features that are counter-productive for my current project. For instance, now shops won't let you price items differently than their price in the master items list. Good thing I backed up my data before I updated.

So how can I do the following script without using else if. The script checks to see if a tag is on, shows a randomly selected text box, turns that tag on if its not, and then ends the script. It does this 5 times, turning on one new tag each time.

Code:

plotscript, mega1, begin
suspend player
if (checktag (88)==false) then (
seed random
ranvar := random (192,197) 
show text box (ranvar)
wait for text box
set tag (88,on)
) else if (checktag (89)==false) then (
seed random
ranvar := random (192,197) 
show text box (ranvar)
wait for text box
set tag (89,on)
) else if (checktag (90)==false) then (
seed random
ranvar := random (192,197) 
show text box (ranvar)
wait for text box
set tag (90,on)
) else if (checktag (91)==false) then (
seed random
ranvar := random (192,197) 
show text box (ranvar)
wait for text box
set tag (91,on)
) else if (checktag (92)==false) then (
show text box (198)
wait for text box
get item (68,1)
set tag (92,on)
) else if (checktag (92)==true) then (
show text box (199)
wait for text box
) resume player
end
Metal Slime
Send private message
 
 PostMon Sep 10, 2012 12:02 am
Send private message Reply with quote
Code:

if () then (

) else (

  if () then (

  ) else (
 
  )

)


And so on. Really, "else if" is just a shortcut for this, but it looks so much nicer.
Liquid Metal Slime
Send private message
 
 PostMon Sep 10, 2012 1:21 am
Send private message Reply with quote
That did the trick. Thanks so much Mystic!
Liquid Metal King Slime
Send private message
 
 PostMon Sep 10, 2012 3:47 am
Send private message Reply with quote
Willy Elektrix wrote:
That sucks. I updated to the nightly version, but I can't use it because of some new features that are counter-productive for my current project. For instance, now shops won't let you price items differently than their price in the master items list. Good thing I backed up my data before I updated.


Oh! That is definitely not a feature, it is a bug, and you are the first person to report it.

What other problems did you have with the nightly other than the shop-price-bug?
Metal King Slime
Send private message
 
 PostMon Sep 10, 2012 4:15 am
Send private message Reply with quote
If you are using a stable release, you should read the copy of plotdictionary.html that came with the version you are using, not the plotdict.xml linked from the wiki. Maybe I need to increase the font size on that note.

You shouldn't call "reseed random". It's not harmful in this script, but there's no point doing so.reseed random is a very advanced command that almost nobody needs.

Also, I suggest writing just "show text box (random (192, 197))"
Metal Slime
Send private message
 
 PostMon Sep 10, 2012 5:54 am
Send private message Reply with quote
Bob the Hamster wrote:
Willy Elektrix wrote:
That sucks. I updated to the nightly version, but I can't use it because of some new features that are counter-productive for my current project. For instance, now shops won't let you price items differently than their price in the master items list. Good thing I backed up my data before I updated.


Oh! That is definitely not a feature, it is a bug, and you are the first person to report it.

What other problems did you have with the nightly other than the shop-price-bug?


I think I've found a bug as well.

If you import an image (for me, box edge) it imports fine. But if you click the "palette" button to look at all the palettes, the image previews are for the image previously in this slot, not the newly imported one. It's very minor, since you can just exit and come back, but it's still a bug.
Liquid Metal Slime
Send private message
 
 PostFri Sep 14, 2012 11:53 pm
Send private message Reply with quote
Bob the Hamster wrote:
Willy Elektrix wrote:
That sucks. I updated to the nightly version, but I can't use it because of some new features that are counter-productive for my current project. For instance, now shops won't let you price items differently than their price in the master items list. Good thing I backed up my data before I updated.


Oh! That is definitely not a feature, it is a bug, and you are the first person to report it.

What other problems did you have with the nightly other than the shop-price-bug?


That's the only one I can remember. Maybe there weren't any others? I'm sorry. I assumed it was intentional since auto-updating the prices in shops from the master list might occasionally be useful.

TMC wrote:
If you are using a stable release, you should read the copy of plotdictionary.html that came with the version you are using, not the plotdict.xml linked from the wiki. Maybe I need to increase the font size on that note.

You shouldn't call "reseed random". It's not harmful in this script, but there's no point doing so.reseed random is a very advanced command that almost nobody needs.

Also, I suggest writing just "show text box (random (192, 197))"


Thanks for the advice. My only other code-writing experience has been with Basic, wherein not using the RANDOMIZE command would make RANDOM return the same variables over and over.
Display posts from previous: