Page 3 of 5 FirstFirst 12345 LastLast
Results 41 to 60 of 105

Thread: The S2 Script-o-Rama

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Re: The S2 Script-o-Rama

    Quote Originally Posted by Seikales View Post
    Just check

    if conditions.Factionname(klan, context) then

    without any other condition and klan is a variable name. Tell me what you get. I tried it stand alone that way and it didn't work until I wrote

    if conditions.FactionName(klan, context) == true then

    I know it is strange but I don't see any mistake in the code. Anyhow, try it if you wish.

    About random numbers: I read on the web that the os.time function won't return millisecond information unless you use extra libraries. Is that a mistaken information then?
    I can't try right now, I don't have access to S2 atm.
    I used os.clock, not os.time
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  2. #2
    Thorn's Avatar Artifex
    Join Date
    Jan 2005
    Location
    Here
    Posts
    2,194

    Default Re: The S2 Script-o-Rama

    I'm trying to change some diplomatic agreement effects, but I cant find their effects..

    I'm looking mainly for make protectorade/ally events, where could I find them?

  3. #3

    Default Re: The S2 Script-o-Rama

    Quote Originally Posted by Thorn View Post
    I'm trying to change some diplomatic agreement effects, but I cant find their effects..

    I'm looking mainly for make protectorade/ally events, where could I find them?
    Most diplomatic stuff is hardcoded. Any diplomacy editing via scripts would involve setting up a listener (for when certain factions attain the wanted diplomatic stance towards each other) and when the conditions are met, apply some sort of effect. Though apply db based effects from scripting isn't straightforward.
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  4. #4
    Thorn's Avatar Artifex
    Join Date
    Jan 2005
    Location
    Here
    Posts
    2,194

    Default Re: The S2 Script-o-Rama

    Quote Originally Posted by T.C. View Post
    Most diplomatic stuff is hardcoded. Any diplomacy editing via scripts would involve setting up a listener (for when certain factions attain the wanted diplomatic stance towards each other) and when the conditions are met, apply some sort of effect. Though apply db based effects from scripting isn't straightforward.
    Well that could work, I just want to give military access to allies and protectorates, making it that way I could even make it happens only between AI factions to avoid posible human exploits..

    When you said a listener you mean a background process like a trigger that is waiting for some conditions to be executed?

  5. #5

    Default Re: The S2 Script-o-Rama

    Quote Originally Posted by Thorn View Post
    Well that could work, I just want to give military access to allies and protectorates, making it that way I could even make it happens only between AI factions to avoid posible human exploits..

    When you said a listener you mean a background process like a trigger that is waiting for some conditions to be executed?

    Well that's actually easy enough to do. Have you any experience scripting? if so, I can point you in the right direction. If not I could write it up quick enough.
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  6. #6
    Thorn's Avatar Artifex
    Join Date
    Jan 2005
    Location
    Here
    Posts
    2,194

    Default Re: The S2 Script-o-Rama

    Quote Originally Posted by T.C. View Post
    Well that's actually easy enough to do. Have you any experience scripting? if so, I can point you in the right direction. If not I could write it up quick enough.
    Thanks, I have some experience, I'm just a bit lost after a few years without doing it (since M2TW) so any help would be appreciate.

    I have been trying to find a function to know when an alliance/protectorate/vassalage is done to give military access to factions involved.

  7. #7

    Default Re: The S2 Script-o-Rama

    Quote Originally Posted by Thorn View Post
    Ouch, I was editing my post when you answered, I was adding this:

    About "shutting" down previous status, that would make non allied factions loose their agreements.. or you can only ask for military access when allied?

    To make it works with protectorates we should add if TCS_Diplomacy_Variable_Check == "Allied" or TCS_Diplomacy_Variable_Check == "Protector" or TCS_Diplomacy_Variable_Check == "Patron" , isn't it?
    It doesn't cause already existing statuses to be lost, it simply blocks the diplomatic offering.

    As I said above, the Protectorate information comes from a different function that outputs a large string such as this:

    Code:
    Protectorate
    
    Trade agreement
    
    Grants military access (indefinite)
    
    Has military access to your lands (indefinite)
    As that's all the one string, it's very hard to pick out the relevant information.

    Remember, I'm speaking from a NTW standpoint here. Things may be different in S2, but you'll have to log the functions yourself. There's a section in the OP about that if you are interested
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  8. #8
    Thorn's Avatar Artifex
    Join Date
    Jan 2005
    Location
    Here
    Posts
    2,194

    Default Re: The S2 Script-o-Rama

    Quote Originally Posted by T.C. View Post
    It doesn't cause already existing statuses to be lost, it simply blocks the diplomatic offering.

    As I said above, the Protectorate information comes from a different function that outputs a large string such as this:

    Code:
    Protectorate
    
    Trade agreement
    
    Grants military access (indefinite)
    
    Has military access to your lands (indefinite)
    As that's all the one string, it's very hard to pick out the relevant information.

    Remember, I'm speaking from a NTW standpoint here. Things may be different in S2, but you'll have to log the functions yourself. There's a section in the OP about that if you are interested
    Oh.. I see.., but then protectorate grants military access by default... I should take a look on that, because then the problem is the dumb AI not helping its allies...

    I can see a full Imagawa stack waiting at Tokugawas frontier while Oda armies are invading it, so I thought they had no military access, but maybe I'm wrong.

    Thanks for the info

  9. #9

    Default Re: The S2 Script-o-Rama

    I am using the following random number generation method, which seems to work very good. It is partially your method, so thanks T.C.
    '
    Code:
    local num1,num2,num3,num4
    num1 = os.clock()
    num2 = math.modf(num1)
    num3 = math.ceil((num1-num2)*10000)
    math.randomseed(num3)
    num4 = math.random(a,b)

  10. #10

    Default Re: The S2 Script-o-Rama

    Quote Originally Posted by Seikales View Post
    I am using the following random number generation method, which seems to work very good. It is partially your method, so thanks T.C.
    '
    Code:
    local num1,num2,num3,num4
    num1 = os.clock()
    num2 = math.modf(num1)
    num3 = math.ceil((num1-num2)*10000)
    math.randomseed(num3)
    num4 = math.random(a,b)

    Just so you know, you don't need to explicitly declare the variables as you have in the first line when there is no danger of them being referenced before being assigned
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  11. #11

    Default Re: The S2 Script-o-Rama

    Three questions (Ugh. Shameful display - sorry for the bother. I knew I should have taken more compsci when I had the chance...)

    - If I want to get into the details of the event.lua script, how do I go about doing that? In particular, I'd like to see how a few of the events are designed.

    - If I wish to code in my own custom event (mostly just displaying text for narrative purposes), is there an approximately hard-coded event that I can clone and modify?

    - How do I code dilemmas? Is it basically just a mission with yes/no and different parameters assigned to each, or is a dilemma a different thing altogether?

  12. #12

    Default Re: The S2 Script-o-Rama

    Quote Originally Posted by Ying, Duke of Qin View Post
    Three questions (Ugh. Shameful display - sorry for the bother. I knew I should have taken more compsci when I had the chance...)

    - If I want to get into the details of the event.lua script, how do I go about doing that? In particular, I'd like to see how a few of the events are designed.

    - If I wish to code in my own custom event (mostly just displaying text for narrative purposes), is there an approximately hard-coded event that I can clone and modify?

    - How do I code dilemmas? Is it basically just a mission with yes/no and different parameters assigned to each, or is a dilemma a different thing altogether?

    You need to start with some basic stuff until you get familiar with Lua; what you are asking is very complex and would take me a while to write. If you have no experience with Lua I doubt it would make any sense at all to you.
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  13. #13

    Default Re: The S2 Script-o-Rama

    Mm, as always, I tend to be a bit overly ambitious when coming to these things. Blame it on the fangirling. But pretty please? I promise I'm teachable .

    You need to start with some basic stuff until you get familiar with Lua; what you are asking is very complex and would take me a while to write. If you have no experience with Lua I doubt it would make any sense at all to you.
    I've tried your tutorials, and downloaded/wrote a number of scripts to play with. I can do a lot of the simple things (giving units, adding money, even custom battles with a bit of help from .Mitch.). What else should I be trying out?

    I think I've actually made some headway. All of the event text and things are located conveniently in the local_INSERTLANGUAGEHERE. There is one for the titles (event_log_descriptions, message_event_log_descriptions) and another event for the text itself. Given what I'm trying to do is mostly narrative-based, I'd really like to know how an event is actually put together.

    Thanks again!

  14. #14

    Default Re: The S2 Script-o-Rama

    I misread what you were trying to do, it's fairly simple after all

    Well if I was building an event for Napoleon I'd add an entry in the events table in the db. Then you'd have to add an entry in data/events.lua. That's for a historic event.

    You can't build a custom event such as OnFactionTurnStart, but you can use these events to be very specific, mainly by using stuff like context.string as an argument. But you'd have to log context.string first to see what it's output is.

    You'll need to be a bit clearer about this, I'm not sure what you're getting at:

    - If I want to get into the details of the event.lua script, how do I go about doing that? In particular, I'd like to see how a few of the events are designed.
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  15. #15

    Default Re: The S2 Script-o-Rama

    Thanks for the help, T.C! I'll be fiddling around when I get home tonight.

    You can't build a custom event such as OnFactionTurnStart, but you can use these events to be very specific, mainly by using stuff like context.string as an argument. But you'd have to log context.string first to see what it's output is.
    Ah. Alright. Man, this isn't making our lives easier at all...

    You'll need to be a bit clearer about this, I'm not sure what you're getting at:
    Oh. What I mean is that I'd like to see for myself regarding the functionality of a few of events cited there - DummyEvent, DuelDemanded/DuelFought, the differences between HistoricalEvents, Historical_Events and HistoricalCharacters. That sort of thing. I went into the scripting.lua file but couldn't find any details as to where they were, nor can I find examples (sometimes you can find a lot of things in the tutorial's scripting. )

  16. #16

    Default Re: The S2 Script-o-Rama

    I think for any serious scripting effort, we need a list of functions we can call (including effects etc.) from a script. I believe for coding ease, a lot of functions were allowed for script calls. We just have to find them out

    But I have no clue how. What are the chances that CA releases this information to us?

  17. #17

    Default Re: The S2 Script-o-Rama

    Quote Originally Posted by Seikales View Post
    I think for any serious scripting effort, we need a list of functions we can call (including effects etc.) from a script. I believe for coding ease, a lot of functions were allowed for script calls. We just have to find them out

    But I have no clue how. What are the chances that CA releases this information to us?
    http://www.twcenter.net/forums/showthread.php?t=425548

    http://www.twcenter.net/forums/showthread.php?t=428786


    If you know how, you can get lua to tell you all sorts of stuff
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  18. #18

    Default Re: The S2 Script-o-Rama

    You gotta tell us how to use getfenv() mate You need to do this!!!

    The links are very promising, but tons of information there is missing, since it is probably too much to write or inaccessible. What are our options?

  19. #19

    Default Re: The S2 Script-o-Rama

    Quote Originally Posted by Seikales View Post
    You gotta tell us how to use getfenv() mate You need to do this!!!

    The links are very promising, but tons of information there is missing, since it is probably too much to write or inaccessible. What are our options?
    Let me know if you don't understand any of this:

    Code:
            local test123 = getfenv()
    	io.output(io.open("data/Region Turn Log.txt","w"))
    	for k, v in pairs(test123) do
    		io.write(tostring(k).."\t"..tostring(v).."\n")
    		if type(test123[k]) == "table" then
    			for K, V in pairs(test123[k]) do
    				io.write("\t\t"..tostring(K).."\t"..tostring(V).."\n")
    			end
    		end
    	
    	end
    My Tools, Tutorials and Resources

    Was running out of space, so see the full list here!

    Consider the postage stamp: its usefulness consists in the ability to stick to one thing till it gets there.- Josh Billings
    The creatures outside looked from pig to man, and from man to pig, and from pig to man again; but already it was impossible to say which was which.- George Orwell

  20. #20

    Default Re: The S2 Script-o-Rama

    Will check it out. So far it looks OK. Will return once I try it.

Page 3 of 5 FirstFirst 12345 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •