Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Miscellaneous > Archive > CtP2-Creation/AI/Mods/Scenarios-Archive > SLIC oddities
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!

bottom of page
  
Author
Thread    < Last Thread     Next Thread > Post New Thread     Post A Reply
mapfi is offline mapfi
Prince
Zurich, Switzerland
Jul 2002
time: 06:22
  Old Post 07-10-2002 22:25
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
SLIC oddities Support Apolyton, buy Alpha Centauri

I've only recently started modding and there are already four 'screw-ups' of this script language that have cost me hours of error searching. So I hope this thread will save other modders time and I also hope that others can contribute to this (or maybe not - since there are enough odd things to SLIC as it is)

Newbies to modding should not be frightened by this thread. SLIC is after all rather easy and Locutus' and IW's guides help a lot! Check this one out:
http://apolyton.net/forums/showthre...?threadid=33181

If you have questions relating to these issues or have another opinion/experience I think it'd be better to start a new thread or PM the author so he can edit his post since I'd rather like to see this thread stay tidy. If it evolves (God forbid) we might ask Locutus to top it (as he should top the 'Getting started with slic' or some tidied version of that one)

Last edited by mapfi on 07-10-2002 at 23:27

mapfi is offline mapfi
Prince
Zurich, Switzerland
Jul 2002
time: 06:22
  Old Post 07-10-2002 22:25
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Support Apolyton buy from Amazon

1.Local variables
It's clear to every programmer that a global variable is available to all parts of the code and always retains it's value. Local variable are only available in the code bit they are declared within. In SLIC such a local variable in a eventhandler will keep its value though. This means that next time the code fires up, the value is still there. So always make sure you reset it if your code doesn't overwrite it in the beginning for sure!

Discovered here: http://apolyton.net/forums/showthre...?threadid=59742

Last edited by mapfi on 07-10-2002 at 22:38

mapfi is offline mapfi
Prince
Zurich, Switzerland
Jul 2002
time: 06:22
  Old Post 07-10-2002 22:27
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Support Apolyton, buy Civilization III: Complete

2.Calculations
Since SLIC only knows integers one has to be careful with division that will return a double. The available guides will tell you that no rounding takes place but digits are simply cut off. So 5/2 will give you 2, so will 4*7/10. Now when you work with variables a SLIC oddity will finish the last one off. Lets say a=4 and b=10, you'd assume that a*7/b will give you 2 as well. It doesn't! SLIC calculates variable first so you get a/b=0.4 which is 0, and then 0*7, still 0! So make sure you write (a*7)/b, which will return 2.

Discovered here: http://apolyton.net/forums/showthre...30&pagenumber=3

Last edited by mapfi on 07-10-2002 at 22:51

mapfi is offline mapfi
Prince
Zurich, Switzerland
Jul 2002
time: 06:22
  Old Post 07-10-2002 22:28
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Get a bigger avatar today!

3.Random numbers
While I wonder of what kind and what the period of SLIC's random number generator is (I might spend time on finding out someday) there's a something simple that is easily misunderstood because it defies logic: random(x); returns an integer starting at/with 0 and ending at/with x-1!
(You're not alone on this if you have believed otherwise for years...)

Discovered here: http://apolyton.net/forums/showthre...30&pagenumber=3

Last edited by mapfi on 07-10-2002 at 22:59

mapfi is offline mapfi
Prince
Zurich, Switzerland
Jul 2002
time: 06:22
  Old Post 07-10-2002 22:28
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations: Deluxe Edition

4.built-in player[] array
Players and integers are more or less the same with the important difference that the built-in player variable allows you to access strings like player[0].civ_name_singular, very useful for messages. Known events use player[0] and player[1], some hidden events or unfinished diplomacy stuff might use player[2] so anything else is save. The array has unlimited size.
Now if you want to use this for a message the following restriction applies:
Immeadetly after assigning player[3] a value you have to send the message. Any additional line of code will render the value inaccessable. So unfortunately you can't have a message using two of those player[] array values. The moment you assign the second one the first one is lost, no matter that you're using a different index.
Unless in the following situation: The event uses player[0]. In that case you can first assign the index 0 and then the a different one and both will be available for the following message.

Discovered here: http://apolyton.net/forums/showthre...?threadid=63901

Last edited by mapfi on 12-10-2002 at 02:54

mapfi is offline mapfi
Prince
Zurich, Switzerland
Jul 2002
time: 06:22
  Old Post 12-10-2002 03:43
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations

5a.AlertBox
An AlertBox effectively halts the game until a user input (klicking a button) - that's what the documentation says.
However, even though the human player receives the message more or less immedeately, the game unfortunately doesn't stop till the beginning of his turn.

5b.Messages
To have messages appearing on the screen you need the line show() in your code. However sometimes this still doesn't work. The frustarting thing in this case is that you usually miss what change in the code caused the fault or fixed it.
IW suggested it to be the case that this happens when two messages fire at the same time (read here: http://apolyton.net/forums/showthre...?threadid=63142). I hope this is the only case. Thanks IW.
Another cause can be what Pedrunn describes in the following post, I've experienced the same but just couldn't pin it down.

Last edited by mapfi on 18-10-2002 at 16:08

Pedrunn is offline Pedrunn
King
of Natal, Brazil
Jul 2001
time: 02:22
  Old Post 13-10-2002 16:01
Edit/Delete Message Reply w/Quote
#7 Report this post to a moderator
Lose 30 kilos (of popups)

6. Showing Numbers in messages

If you want to have a number from a variable showing up in the messages. As usual you write the variable between {} in the message field. But you must be aware that this variable has to be a global variable otherwise the message although it will be in the message tab it not only wont show up but it wont open when you click on it in the message tab.

This is from my experience. Dont know any thread about it.

ahenobarb is offline ahenobarb
Prince

Nov 2001
time: 05:22
  Old Post 15-10-2002 00:04
Edit/Delete Message Reply w/Quote
#8 Report this post to a moderator
Avatar Enlargement: We've got the solution

6b. Message Duration Command

SLIC documentation says:

VOID Duration(turns)
Kill this message automatically in n turns.

However, this command does not work. Duration should say how long a message remains in the message box before it can be deleted. however, it does not do this at all, the message stays turn after turn unless you left click it.

Last edited by ahenobarb on 19-10-2002 at 23:33

mapfi is offline mapfi
Prince
Zurich, Switzerland
Jul 2002
time: 06:22
  Old Post 18-10-2002 16:06
Edit/Delete Message Reply w/Quote
#9 Report this post to a moderator
Browse Apolyton AD-FREE

7. Functions, accessing variable members
In some cases, using members of unit, army, city, and location variables that are function parameters may not always work as expected. There is, however, a workaround. Copy the function parameter to a local variable and use that variable instead. Example:

code:
// This version may fail sometimes! int_f DoesAHumanOwnThisUnit(unit_t theUnit) { if(IsHumanPlayer(theUnit.owner)) { return 1; } return 0; } // This version should always work int_f DoesAHumanOwnThisUnit(unit_t theUnit) { unit_t copiedUnit; copiedUnit = theUnit; if(IsHumanPlayer(copiedUnit.owner)) { return 1; } return 0; }

Ok, this has been known from start but it's easily forgotten
http://apolyton.net/ctp2/modificati...sion/slic.shtml

Locutus is offline Locutus
ACS CTP1/2 Manager & Civ4 Co-Manager
Hengelo, The Netherlands
Nov 1999
time: 06:22
  Old Post 17-11-2002 04:56 Visit Locutus<br><img src=/forums/images/staff-icon.gif>'s homepage!
Edit/Delete Message Reply w/Quote
#10 Report this post to a moderator
Suffering from ads?

Not really an oddity but something that probably few people know about or will find out on their own, so I decided to just add it here:

If you want to start a on new line in a text message (i.e. you would like to hit 'Enter'), use '\n'. The next sign will be placed on a new line. Tab is also available: \t.

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:22.
Apolyton Time is 00:22.
    top of page
Rate This Thread:
archivepost
Forum Jump:
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0366 seconds (88.70% PHP - 11.30% MySQL) with 31 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net