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 beginner needs help
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
Jonny is offline Jonny
Emperor
Nashville, Tennessee, USA
Nov 2000
time: 23:14
  Old Post 30-06-2001 04:02
Edit/Delete Message Reply w/Quote
#1 Report this post to a moderator
SLIC beginner needs help Lose 30 kilos (of popups)

In my first attempt to write SLIC, I am trying to write code that will create a unit whenever & wherever you build a city. The unit you get will depend on technology as well as make the city start at an increased size. I am getting an error message that points to a syntax error in line 23 (I think where the unit creating process begins) and I can't figure it out. Please help! Here is the code:

code:
//Quickstart Mod SLIC //events HandleEvent(CreateCity) 'citycreate' post { int_t a; //set value of a a = 1; if(hasAdvance(player[0], AdvanceDB(ADVANCE_FEUDALISM))) { a = 2; } if(hasAdvance(player[0], AdvanceDB(ADVANCE_GUNPOWDER))) { a = 3; } if(hasAdvance(player[0], AdvanceDB(ADVANCE_ADV_INFANTRY_TACTICS))) { a = 4; } //make free unit if(a = 1) { CreateUnit(player[0], UnitDB(UNIT_HOPLITE), city[0].location, 0); } if(a = 2) { CreateUnit(player[0], UnitDB(UNIT_PIKEMEN), city[0].location, 0); } if(a = 3) { CreateUnit(player[0], UnitDB(UNIT_INFANTRYMAN), city[0].location, 0); } if(a = 4) { CreateUnit(player[0], UnitDB(UNIT_MARINE), city[0].location, 0); } //increase city size to 3 (5 if build with urban planner) {AddPops(city[0], 4); } }


This is my first attempt at SLIC and I wouldn't be suprised if there are many errors.

Immortal Wombat is offline Immortal Wombat
Prince
in perpetuity
Dec 2000
time: 05:14
  Old Post 30-06-2001 20:18 Visit Immortal Wombat's homepage!
Edit/Delete Message Reply w/Quote
#2 Report this post to a moderator
Lose 30 kilos (of popups)

Firstly, the way I would suggest coding SLIC is to rip as much coding as you can from other people's code

This is very similar to a simplified version of Locutus' militia code, but I can see that doing it from scratch is a good way to get used to handling SLIC.
(His GetAge function is very useful for all sorts of things btw, and easily changed to suit your needs)

The syntax error occurs because "=" is SLIC is a definer. It makes a = 1. To compare (ie. for use in "if" statements), you have to use ==.
eg.

code:
... if(a == 3){ ...


Also, I dont think the AddPops bit needs the surrounding {}.

Its good to see someone else learning SLIC. From having no experience in programming, I managed to slowly learn techniques, and its very fun once you get going

Jonny is offline Jonny
Emperor
Nashville, Tennessee, USA
Nov 2000
time: 23:14
  Old Post 03-07-2001 00:26
Edit/Delete Message Reply w/Quote
#3 Report this post to a moderator
Support Apolyton, buy Alpha Centauri

I did that, and I don't get any more error messages. However, the code still has no effect. I think that the code doesn't know when I build a city.

Peter Triggs is offline Peter Triggs
Prince
Gone Fishin, Canada
Jan 2000
time: 05:14
  Old Post 03-07-2001 02:20
Edit/Delete Message Reply w/Quote
#4 Report this post to a moderator
Support Apolyton, buy Galactic Civilizations

You should be getting error messages; I think you've got debugslic=No. Go to ...\ctp2_program\ctp\userprofile.txt and set debugslic=Yes. (There are other profiles, but I think this is the crucial one.) If you're writing a SLIC program you need to have it on this setting while you're debugging it.

Now you should get the error message about 'function HasAdvance wrong kind of argument' thingy. There's an error in the SLIC function documentation: the function HasAdvance takes a string ID argument as in

quote:


HasAdvance(player[0], ID_ADVANCE_FEUDALISM)


And, yes, this sort of thing is enough to drive you bonkers.

If you don't have it already, go to Locutus's site and get a copy of EditPlus2. Make sure you also get his slic4ep2.zip. This contains some files that you load into EditPlus so that it will handle SLIC (the most important one is slic.stx). I can't remember the details but the EditPlus Help system should tell you how to do it. Once you get this set up, it's absolutely invaluable. (And you soon get used to Locutus's psychedelic colour scheme for SLIC syntax highlighting. )

You might also e-mail Locutus, he hasn't posted here for ages. Ask him how his introduction to SLIC is coming along and *beg* him for a copy of it. It's just what you need and the only alternative I can think of is to download some C-tutorials from the Net and wade through them. The trouble is that C has many features that aren't present in SLIC, so this would be a very inefficient and difficult way of approaching SLIC.

Cube is offline Cube
Warlord
El Paso, Tx
Nov 2000
time: 22:14
Question  Old Post 03-07-2001 03:02
Edit/Delete Message Reply w/Quote
#5 Report this post to a moderator
Support Apolyton, buy Civilization III: Complete

I can understand the unit when you build a city, but why do you want to increase the city size?

Immortal Wombat is offline Immortal Wombat
Prince
in perpetuity
Dec 2000
time: 05:14
  Old Post 03-07-2001 04:10 Visit Immortal Wombat's homepage!
Edit/Delete Message Reply w/Quote
#6 Report this post to a moderator
Support Apolyton, buy Civilization III: Complete

Yay! I knew I didn't make that avatar in vain Thanks Cube.

Anyway...
The increase in city size is too make the city more productive and richer in the early game, to make it a proper quick-start.

Dutcheese did a very good quick-start for CTP if you want to look at that Jonny.

That Editplus thing really is useful. I didn't like the colour at first, but its much harder to code without it now

Dale is offline Dale
King
Sir! Why do you keep clicking on me?
Dec 2000
time: 15:14
  Old Post 03-07-2001 04:27
Edit/Delete Message Reply w/Quote
#7 Report this post to a moderator
Support Apolyton, buy Call to Power 2

Also be careful when using passed variables too. There's always the potential for accidently changing these. My suggested script (usual disclaimer: not tested, so don't expect it to work the first time ).......

code:
HandleEvent(CreateCity) 'citycreate' post { int_t a; int_t playerNum; city_t tmpCity; location_t tmpLoc; a = 0; //It is possible not to have advance for Hoplites at start of game. IE. first city built. playerNum = g.player; tmpCity = city[0]; tmpLoc = location[0]; // The way you had it, the script was processing many lines, as opposed to this scripts couple of lines before dropping out. if(HasAdvance(playerNum, ID_ADVANCE_ADV_INFANTRY_TACTICS)) { a = 4; } elseif(HasAdvance(playerNum, ID_ADVANCE_GUNPOWDER)) { a = 3; } elseif(HasAdvance(playerNum, ID_ADVANCE_FEUDALISM)) { a = 2; } elseif(HasAdvance(playerNum, ID_ADVANCE_BRONZEWORKING)) { // Or whatever gives Hoplites a = 1; } if(GetUnitsAtLocation(tmpLoc) < 12) { // Could be a 12-stack finding city in ruins if(a == 1) { CreateUnit(playerNum, UnitDB(UNIT_HOPLITE), tmpLoc, 0); } elseif(a == 2) { CreateUnit(playerNum, UnitDB(UNIT_PIKEMEN), tmpLoc, 0); } elseif(a == 3) { CreateUnit(playerNum, UnitDB(UNIT_INFANTRYMAN), tmpLoc, 0); } elseif(a == 4) { CreateUnit(playerNum, UnitDB(UNIT_MARINE), tmpLoc, 0); } } AddPops(tmpCity, 4); }

Last edited by Dale on 03-07-2001 at 04:32

Cube is offline Cube
Warlord
El Paso, Tx
Nov 2000
time: 22:14
  Old Post 03-07-2001 05:22
Edit/Delete Message Reply w/Quote
#8 Report this post to a moderator
Support Apolyton, buy Alpha Centauri

Yay! I knew I didn't make that avatar in vain well I didn't know you made the avatar, I was thinking of using a unit, but then i came across it and thought it was cool.

you don't include the machine gunner or hover infantry in the code, and I think they should be in there. I personally think it takes away from the begining of a city and watching it grow and build units.

Locutus is offline Locutus
ACS CTP1/2 Manager & Civ4 Co-Manager
Hengelo, The Netherlands
Nov 1999
time: 06:14
  Old Post 04-07-2001 03:24 Visit Locutus<br><img src=/forums/images/staff-icon.gif>'s homepage!
Edit/Delete Message Reply w/Quote
#9 Report this post to a moderator
Lose 30 kilos (of popups)

Behold, for the return of the Borg! I had to go back to my unimatrix and kill some of those Species 8472 bastards but now I'm back and better than ever Resistance is futile, you WILL be assimilated

Sorry 'bout that, I'm afraid I've been watching a bit too many old ST episodes lately Actually I've been extremely busy with some real-life affairs and stuff (school, work, social live, you know the drill) but I'm slowly getting back to CtP. (BTW, I apologize for all unanswered emails, I'll deal with those later).

It's good to see people are still interested in SLIC though SLIC certainly has it's curiosities (to put it mildly) but it's still a great tool for modmakers and a nice toy for programmers (Ah, who am I kidding, it's really a piece of sh*t! But I still love it ).

I should have some instructions around on how to install those EditPlus files, I'll see if I can find them and post those on my website too. Well, Peter, I'd love to take the credit for that color scheme but I think that's not my work Unless I'm mistaken the syntax files only transfer the syntax info, not the color info. To get a color scheme that's perhaps easier on the eye you'll have to change the colors yourself (Tools->Preferences->Settings&Syntax->Syntax Colors, in case anyone hadn't figured that out yet). Not that my own personal color scheme is some much better but it's still an improvement

I plan on continuing my work on that SLIC documentation very shortly, I'm even considering putting what I already have on my website: it would be a shame to let such potentially useful info go to waste (God knows how long it'll still be before I'll finally finish it, it should have been done months ago). Esp. people like Johnny, who are absolute newbies in the world of programming, it should be very useful even if it's not finished yet. The best advice I can give though is, as IW already said, to study other people's code. My Militia code is indeed very similar to this.

The only potential problem I see with the code (Dale's version that is) is that 'createcity' is a very general name and it's possible that an eventhandler with such a name already exists. If so, the first occurence of the handler will be used and all subsequent handlers ignored. Better to call it JOHN_CreateCity or something like that, put a unique prefix in front of the name.

Last edited by Locutus on 22-09-2001 at 11:32

Dale is offline Dale
King
Sir! Why do you keep clicking on me?
Dec 2000
time: 15:14
  Old Post 04-07-2001 03:56
Edit/Delete Message Reply w/Quote
#10 Report this post to a moderator
Remove this text

Locutus:
Good to see ya back mate! Hope you continue the good SLIC work. It's been a bit lonely round here without our number 1 SLICer.

Immortal Wombat is offline Immortal Wombat
Prince
in perpetuity
Dec 2000
time: 05:14
  Old Post 04-07-2001 16:09 Visit Immortal Wombat's homepage!
Edit/Delete Message Reply w/Quote
#11 Report this post to a moderator
Support Apolyton buy from Amazon

Welcome back. That big Locutus shaped hole in the forums was getting unnerving

Locutus is offline Locutus
ACS CTP1/2 Manager & Civ4 Co-Manager
Hengelo, The Netherlands
Nov 1999
time: 06:14
  Old Post 04-07-2001 17:03 Visit Locutus<br><img src=/forums/images/staff-icon.gif>'s homepage!
Edit/Delete Message Reply w/Quote
#12 Report this post to a moderator
Put an end to popups!

Thanks guys, you sure know how to make a guy feel at home

  < Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:14.
Apolyton Time is 00:14.
    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.0418 seconds (89.78% PHP - 10.22% 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